Skip to content

Define Keep's authenticated reconstruction contract - #77

Open
flyingrobots wants to merge 3 commits into
mainfrom
docs/authenticated-reconstruction-contract
Open

Define Keep's authenticated reconstruction contract#77
flyingrobots wants to merge 3 commits into
mainfrom
docs/authenticated-reconstruction-contract

Conversation

@flyingrobots

@flyingrobots flyingrobots commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Problem

Keep's core law promises exact named bytes or refusal, but the repository did
not have one governed invariant stating whole-object versus range proof scope,
ordinary Write failure visibility, receipt durability, or the distinction
between evidenced content refusals and operational failures.

Invariant affected

For a requested content identity, Keep returns authenticated exact bytes and a
receipt, returns a precise evidenced content refusal, or returns an operational
failure that makes no content claim. A failed ordinary writer may retain an
untrusted prefix; only a complete success receipt authenticates the emitted
sequence.

Approach

  • Add the normative authenticated-reconstruction contract.
  • Add its colocated rationale and stable requirement ledger.
  • Keep complete-object and exact-range proof scopes separate.
  • Require range receipts to use a layout-to-target binding admitted by the
    selected store view and state that ranges verify no profile boundaries.
  • Separate success, evidenced refusal, and operational failure.
  • Add deterministic whole-object and range writers that accept a nonempty
    prefix and then fail, verifying exact error coordinates and no receipt.
  • State durable pinned-view and retained-evidence obligations as planned gaps.
  • Link the contract from the public README.

Alternatives rejected

  • Treat every typed error as an evidenced refusal.
  • Promise that failure leaves an arbitrary Write untouched.
  • Combine whole and range reads behind an optional range.
  • Trust structural layout admission as a target binding.
  • Describe current segment/catalog machinery or planned retention as a
    complete durable logical-read API.

Failure modes

The contract covers untrusted output prefixes, incomplete views, unreadable or
inconsistent evidence, unsupported durable claims, exact-layout unavailability,
and the distinction between content evidence and operational failure.

Tests

  • cargo fmt --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test --all-targets --all-features
  • cargo test --test streaming_cas
  • cargo test --test range_read_failures
  • PATH="scripts/documentation-tools/node_modules/.bin:$PATH" cargo xtask documentation-integrity-check
  • git diff --check

Benchmark impact

No production path changes. The new deterministic writer fixtures affect tests
only; the all-target validation benchmark binaries completed successfully.

Format and API compatibility

No durable format, canonical bytes, identity law, or public Rust API changes.

Recovery implications

The contract requires future durable receipts to bind one immutable view and
protect the supporting evidence closure. Retention remains planned; the page
does not promote current lower-level durable machinery into a logical read API.

Security implications

Operational failure, partial proof, stale physical existence, or an uncommitted
caller layout cannot be promoted into a stronger content claim. Authenticated
bytes still do not prove authorship, authorization, provenance, or meaning.

Cross-repository consumer

Echo's experimental boundary is flyingrobots/echo#721; live implementation and
cutover work is flyingrobots/echo#722. Echo vocabulary remains outside Keep
core.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

Summary by CodeRabbit

  • Documentation
    • Added a normative contract describing authenticated reconstruction behavior.
    • Documented proof scope, exact-byte outputs, identity coordinates, evidence requirements, receipts, and output visibility.
    • Clarified supported complete-object and exact-range reconstruction scenarios.
    • Explained typed refusals, operational failures, receipt validity, and limitations of the current non-durable storage behavior.
    • Linked the correctness-first storage promise to the authenticated reconstruction contract.

Walkthrough

The PR adds a normative authenticated reconstruction contract for Keep. It documents proof scopes, exact-byte output, receipts, refusal and failure behavior, ReferenceStore limits, future durable requirements, and consumer constraints.

Changes

Authenticated reconstruction

Layer / File(s) Summary
Contract foundations
README.md, docs/invariants/authenticated-reconstruction/README.md
The repository links the new contract. The contract defines proof scope, exact-byte results, identity coordinates, and evidence limits.
Reconstruction behavior
docs/invariants/authenticated-reconstruction/README.md
The contract specifies complete-object and exact-range reconstruction, sink behavior, and ReferenceStore verification.
Outcomes and durability
docs/invariants/authenticated-reconstruction/README.md
The contract defines refusal and failure outcomes, receipt validity, future durable requirements, executable evidence, and consumer constraints.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • flyingrobots/keep#54: Defines the durable physical segment-store protocol for authenticated exact-byte reconstruction.

Poem

Exact bytes wait in a proof-bound frame,
Receipts record the scope and name.
Refusals speak when evidence ends,
ReferenceStore verifies and sends.
Durable futures mark the trail,
While false claims find no avail.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely identifies the main change: defining Keep's authenticated reconstruction contract.
Description check ✅ Passed The description covers the required problem, invariant, approach, failures, compatibility, recovery, security, and validation details, but omits the checklist.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/invariants/authenticated-reconstruction/README.md`:
- Line 203: Update the invariant wording in the authenticated reconstruction
documentation to explicitly guarantee that required supporting evidence is not
garbage-collected, deleted, or otherwise invalidated during the read, replacing
the ambiguous “collected” terminology.
- Around line 10-16: Update the contract section around the “Keep either”
statement to distinguish three outcomes: authenticated success, an evidenced
content-related refusal, and operational failure. Align the wording with
ReferenceStore::reconstruct so output or other I/O errors are classified as
operational failures, do not count as precise refusals, and cannot support a
content conclusion.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d886dc72-4668-44aa-9fda-339cb22ceea2

📥 Commits

Reviewing files that changed from the base of the PR and between 57fa4ee and b0469e0.

📒 Files selected for processing (2)
  • README.md
  • docs/invariants/authenticated-reconstruction/README.md
📜 Review details
🔇 Additional comments (2)
README.md (1)

8-10: LGTM!

docs/invariants/authenticated-reconstruction/README.md (1)

1-9: LGTM!

Also applies to: 17-202, 204-240

Comment thread docs/invariants/authenticated-reconstruction/README.md Outdated
Comment thread docs/invariants/authenticated-reconstruction/README.md Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b0469e05a5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +3 to +6
**Status:** Normative for every Keep operation that claims authenticated
reconstruction. The public non-durable `ReferenceStore` implements the
complete-object and exact-range forms. A consolidated durable logical-read
surface is not yet implemented.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add the required reconstruction decision record

This normative contract makes governed decisions about proof scope, receipt durability, recovery, and public API boundaries, but a repo-wide search shows that the new concept directory contains only this README.md and the commit adds no ADR. Add the required colocated rationale.md documenting the decision and rejected alternatives; otherwise the rationale exists only in the commit message and is unavailable to future repository readers.

AGENTS.md reference: AGENTS.md:L150-L156

Useful? React with 👍 / 👎.

Comment on lines +221 to +223
Evidence anchors:

- [`ReferenceStore` architecture](../../architecture/reference-store/README.md)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add a requirement ledger for the normative contract

Because this page declares a governed invariant, docs/Documentation Standards.md §3.2 requires its contract ledger to identify stable requirement IDs, exact laws, oracles, evidence types, status, and concrete tests. A repo-wide search finds no ledger for this new invariant, while this evidence section supplies only unversioned file links, so future changes cannot audit which tests establish each normative reconstruction claim; add a colocated requirements ledger mapping these claims to their evidence.

Useful? React with 👍 / 👎.

Comment on lines +115 to +119
It does not prove that Keep authenticated:

- unrequested chunks;
- the complete logical blob;
- every storage-profile boundary.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge State that range reads verify no profile boundaries

For every exact-range entry point, range_read_execution::verify_selected verifies only each selected ChunkId and never invokes ProfileVerifier; the existing RangeReadReceipt rustdoc likewise says that storage-profile boundaries were not verified. Saying merely that the receipt does not prove “every” boundary can be read as proving the overlapping boundaries, which would let consumers promote the receipt beyond its implemented proof scope. Replace “every” with “any” so the normative contract states the actual verification limit.

AGENTS.md reference: AGENTS.md:L150-L154

Useful? React with 👍 / 👎.

Comment on lines +127 to +130
The generic reconstruction API accepts an ordinary caller-owned `Write` sink.
An ordinary sink is not transactional. It may fail after accepting a prefix,
and an emission-time storage failure may occur after a prefix has been
written.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add coverage for failure after a writer accepts a prefix

This section makes the retained-but-untrusted prefix a normative failure mode, but the reconstruction and range failure tests use FailingWriter, which errors before accepting any byte; the short-write fixture only exercises eventual success. Consequently no executable evidence checks the newly documented case where a writer accepts a prefix and then errors, including the reported bytes_written coordinate and absence of a success receipt. Add a deterministic writer fixture that accepts a nonempty prefix before failing for both whole-object and range operations.

AGENTS.md reference: AGENTS.md:L103-L105

Useful? React with 👍 / 👎.

Comment on lines +211 to +214
The current durable segment, catalog, publication, retention, and recovery
surfaces do not yet form this consolidated high-level `BlobId`-to-writer
contract. Their existence must not be described as an implemented durable
logical reconstruction API.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not describe retention as a current durable surface

A repo-wide search of src finds no retention API or implementation, while the root README explicitly says retention and garbage collection remain planned and ADR-0009 requires documentation to keep describing them that way. Grouping retention among the “current durable ... surfaces” therefore overstates the implemented capabilities and can mislead integrators assessing whether evidence is protected from collection; remove retention from this current-surface list or label it explicitly as planned.

Useful? React with 👍 / 👎.

Comment on lines +28 to +29
authenticated bytes + receipt
or typed refusal

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Include operational failure in the top-level outcome model

When a caller-owned writer fails after accepting a prefix, or when evidence is unreadable, the later failure taxonomy correctly calls this an operational failure from which no content conclusion follows; however, this normative outcome diagram offers only authenticated success or a typed refusal. Consumers following the summary can therefore classify every Err as an evidenced refusal, which is exactly the distinction the later section is intended to prohibit. Add operational failure as an explicit third outcome in the contract and diagram.

AGENTS.md reference: AGENTS.md:L5-L9

Useful? React with 👍 / 👎.

Comment on lines +111 to +113
An exact-range operation has a deliberately narrower proof scope. Its receipt
proves that the requested bytes came from completely authenticated overlapping
chunks under the admitted layout.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Require a committed target-layout binding for range receipts

For a caller-supplied range layout, structural AdmittedLayout validation proves offsets and lengths but not that its target BlobId names the listed chunks; docs/architecture/reference-store/rationale.md explicitly demonstrates this forged same-length-target case. The current read_admitted_layout_range avoids it by resolving the canonical LayoutId to a committed layout, but this normative range rule requires only an “admitted layout,” allowing a future conforming implementation to issue a target-bearing receipt for an unauthenticated target association. Require the layout-to-target binding to come from the admitted store view before returning a range receipt.

AGENTS.md reference: AGENTS.md:L5-L9

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant