Repository navigation
feat(breg): keep files on records and name the Proposal behind a revision - #2797
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c639ad28d2
ℹ️ 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".
Independent review (Claude, read-only, at the author's request)What was reviewed. Commit Verdict. The access control is sound. The download route and the history link both fail closed, and I found no way to read a file or a Proposal link without the grants the docs describe. The one bug that blocked the reviewed commit is fixed by Blocked the reviewed commit, now fixedB1. Availability and target-conditions routes answered 400 for any immediate Action that declares files. Needs a decisionD1. Erasing old history removes a live record's file for good.
D2. An immediate Action can commit a file that is unverified or already rejected, which leaves a dead slot.
D3. The marker left by erasure keeps the file's SHA-256, media type and size indefinitely.
Should fixS1. The erasure outcome and audit entry do not say what was destroyed. The count returned by S2. A refused download is audited as a refused record GET, with no slot. The early returns in S3. BREG-SEC-218 claims lifecycle and record-level disclosure for downloads, and no test pins either. The visibility check in S4. A file-carrying invoke holds the whole request in memory through the transaction. Files travel as base64 inside the JSON body. At the compile-time maxima (8 slots of 16 MiB) one request is about 179 MB, and parsing holds the raw body, the JSON value and the decoded bytes at once. S5. The immediate-Action write path on external object storage has no test, and it stages before guards. S6. "Install on a fresh database" is not enforced. The PR adds a managed table and two indexes but no engine feature gate, unlike the Record timer store precedent. Reading suggests a successor apply would create the table in place before catalog verification, which is an untested upgrade path that contradicts the changelog. Reading also suggests the new binary on an old database fails with the generic catalog-drift message and not a fresh-install message. Either test and document the in-place path, or add the gate and the message. Related: the operator upgrade pages do not carry the requirement (the changelog does), and the changelog bullet about registry revision pins ( S7. Docs that would mislead.
S8. Tests that cannot fail, or that assert presence but not the promised absence.
Nits
Open questions I could not settle by reading
Read and found sound
|
|
Ruling on D2 (from the maintainer): option (a). The immediate-Action write path refuses bytes whose stored verification verdict is already D1 and D3 are still being researched. Please hold both until a ruling is posted here. |
Rulings on D1 and D3 (from the maintainer)These complete the three decisions in the review above. D2 (a) was posted earlier. All three ship in this pull request, each with a failing-first test. D1: history erasure does not remove a live record's fileA slot file is current state of the record. It is write-once, so it never has an earlier version, and the download takes no revision. History erasure removes earlier state. This matches what the retention page already promises ("it does not remove the current record") and how a field value set at revision 1 survives erasure of revision 1. It is also how FHIR
D3: the erased marker keeps no digestAfter a file is erased, the slot's marker keeps the key (record type, record, slot) and when it was erased. That is all write-once needs. It drops the SHA-256 digest, the media type and the size. A hash of a personal document is pseudonymised personal data, not anonymous data: anyone who holds the document can recompute the hash and confirm the record once held it. Records-management practice says the same. A destroyed item leaves a residual with identifiers and timestamps, and other metadata is pruned.
D3b: the same rule for the existing tombstonesProposal attachment tombstones and confirmed external-deletion tombstones keep digests in the same way today. Apply the same rule to them in this pull request, so the product has one answer.
Still open from the reviewThe should-fix items S2 to S8 and the nits stand as written. S1 is covered by D1 point 3. The retention caution in S7 and the erasure test in S8 are rewritten by D1. |
|
D3b has one storage dependency. The Proposal attachment row can drop its digest, media type and size after erasure, leaving only its slot identity and erasure timestamp. The confirmed external-deletion row serves a different purpose. Cleanup still uses its digest as the object key on later runs. An upload that was interrupted locally can finish after the object store first confirmed absence. The retained key lets the next cleanup detect and remove that object. Scrubbing the key on first confirmation would remove that guarantee. Cleanup code · Existing retention test I’ll keep the record and Proposal reference changes in this PR. The external cleanup row needs to stay in place until we can prove that an interrupted write has finished, or give cleanup a different durable object key. |
|
A still-live Proposal can also retain the same file digest after its promoted Record slot is erased. The held Proposal response can include that Proposal's live attachment metadata. The existing Proposal erasure path scrubs the submission's linked responses. This retention boundary matters when the request is to erase all copies of a promoted file. Held Proposal response · Proposal response erasure |
Record history items and single-revision reads gain an optional proposal member (actionId, proposalId, submissionVersion) derived from the stored Proposal result. It appears only when the caller can read that Proposal under the existing Proposal read authorization, and is absent for immediate Actions. The link survives operator erasure. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Record types can declare attachment slots in the Proposal slot shape. An immediate Action create effect can fill a slot with a file sent in the same request, and the reference commits with the record, its history, the idempotency receipt and the outbox. A profile granted the slot through readableAttachments can download it from the record's route inside its row boundary. The response carries the stored digest and media type. Record erasure removes the reference and retires bytes nothing else refers to. Proposal retention counts record references before it deletes content. The Rust client gains download_record_attachment. Record file references live in a new managed table, so the managed schema fingerprint changes. Install the release on a fresh database. Every registry revision moves because the problem code list grew, while per-action contract revisions stay the same. The explain examples were regenerated with the test's own serialization and the ODRL examples are bregctl generate odrl output. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Describe how a record type declares a slot, how an immediate Action writes it, who can download it, and how record retention and erasure treat the file. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
A revision read now returns its record connection to the pool before it checks Proposal links, so a pool of one connection no longer fails the read. All the checks of one read share one deadline. The check reads the applied Proposal without a row lock, so a lifecycle command holding that row no longer delays history. Only a refused read or a failed precondition omits the member. A conflict, a store failure or the deadline fails the read with 503 instead of hiding the link. Proposal result rows gain an index by target record and revision, which the link lookup uses. The managed schema fingerprint changes with it, so install the release on a fresh database. Links attach in a stable order. The generated OpenAPI document declares the proposal member only for a registry with a Proposal Action, and the caller-filtered document only on revision routes where the caller would receive it. New PostgreSQL tests cover the task-grant exclusion, the Proposal row boundary, a byte comparison with an unlinked response, the single revision read, a held row lock, a failing check and the caller-filtered document. Each omission test has a positive control. The security and API reference pages name the residual risks: response timing, no Proposal-read audit for the check, and the link disappearing once a target is tombstoned. The Python client README describes the member. The compiler contract test lists the attachment problem codes the generated OpenAPI document already carries. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
A reviewed decision often rests on a supporting document. Before this, a record slot could only take a file from an immediate Action request, so a file reviewed with a Proposal could not stay on the record it changed. The create or patch effect of a Proposal Action can now name a Proposal attachment slot to promote, as attachments.<record slot>.fromAttachment. bregctl check refuses a promotion from an undeclared Proposal slot, into a slot the target record type does not declare, from a Proposal slot that accepts a content type or size the record slot does not, into a record slot classified less restricted than the Proposal slot, from a tombstone effect, and a second promotion into one slot of one record. Promotions are part of the Action definition revision. The request-file bindings of an immediate Action were missing from its definition revision, so renaming the request part a slot takes its file from left the revision unchanged. They are now part of it. An Action without promotions or request files keeps its revision byte for byte. Apply adds a record reference to the content hash the frozen Proposal file already holds, so no bytes are copied. It rechecks the file against the record slot and the frozen submission inside the apply transaction. A filled slot answers 409 attachment.slot-write-once, and a file whose verification is pending or was rejected answers 412 precondition.failed. Either refusal rolls back every effect of the apply. An empty optional Proposal slot leaves the record slot empty. Proposal erasure keeps the bytes a record refers to and removes the rest. The authoring schemas are regenerated. The apply OpenAPI 409 description names the write-once refusal only for a profile that may apply a promoting Action. New invariants BREG-SEC-221 to BREG-SEC-223 cover the check bounds and verification, the write-once rollback, and erasure. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
The Rust client could already download a record's file, but Node.js and Python callers could not, so an application in either language had to reconstruct the request and its response checks itself. Node.js gains downloadRecordAttachment and Python gains download_record_attachment. Both call the canonical Rust client, so the bytes are returned only when they match the service's Repr-Digest, and the bounded body and redacted errors carry over. The capability inventory, the type declarations and the stack facade copies are updated. Tests also check that the Proposal link on a record revision reaches callers in both languages. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Authors need to know how a Proposal file reaches a record, what bregctl check refuses, and what apply answers when it cannot promote. Operators need to know that erasing a Proposal keeps a promoted file on the record. The Proposal configuration page gains a section with an example and the refusals. The record type, retention, security and API reference pages and the changelog describe promotion. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Three committed values went stale earlier on this branch. The four record attachment Problems joined the generated Problem schema, which moves every pinned fixture's artifact revision and the registry revision in the evidence-source export example. The index of Proposal results by target revision and the record attachment live-reference index moved the portable managed schema fingerprint. The changelog already announces both changes. SQL digests and Action fingerprints stay fixed. The example is rewritten with the `bregctl generate evidence-source` command its test documents. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
An immediate Action that declares record attachments read its body with a plain bounded read, so a file far over its slot answered 400 with no code. The handler now reads frames itself and tells a body that is too long apart from a broken one. On an invocation that takes files, too long answers 413 attachment.too-large. Availability and target conditions take no files, so they keep the snapshot bound with no file slack. The generated OpenAPI document now lists attachment.too-large (413), attachment.content-type (415), attachment.digest-mismatch (422) and attachment.slot-write-once (409) on an invocation that takes files. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
The security page said a promoted file never loses protection. The classification label never drops, but bregctl check reads it once, and who downloads the file is decided by the record grants' readableAttachments. An erased slot's marker is not value-free. It keeps the digest, media type, size and the filling revision, and drops who filled the slot and when. The security page now also says that an immediate Action's file commits before verification, so a rejected file leaves a slot that cannot be filled again, and that field disclosure conditions and field encryption do not cover file slots. The retention page warns that erasing history through the current revision removes a live record's file for good. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
The client READMEs said the record download reads only files an applied Proposal promoted. It also reads files an immediate Action wrote. A slot holds up to 16 MiB while the clients read 8 MiB by default, so each README names the option that raises the bound. The clients cannot send request files yet, so an immediate Action that declares attachments is not invocable from them, and the READMEs, the capability page and the changelog now say so. The Node.js and Python binding tests now pin a concealed download's Problem and a file larger than the response bound. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
A store failure after a record file download's attempt returned without the Refused terminal that GET writes, so the audit showed only an unfinished request. The failure now goes through the read service's refused-read path. The download's operation identity also names the slot, as <get operation>:attachment:<slot>. Slot ids are configuration, not values, so the audit and the subject access log can tell two slots apart. The record download test now asserts the attempt and Returned terminal, the Refused terminal of a concealed 404 and of a store failure, and one subject access log row per released file. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
The Proposal's own author, acting as an agent without a task grant, holds a profile that reads the record history and owns the Proposal. Only the standing-agent ceiling keeps the link from it. The test pins that ceiling on record history, beside the task-grant case, with a traceability row. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
BREG-SEC-221's cited test got its 412 from the manifest check, so removing the promotion's in-transaction recheck broke no test. The new test pauses the apply inside its effect write with a trigger and an advisory lock, rejects the file while it waits, and expects 412 with no record reference and no new revision. With the recheck disabled, the test fails. The matrix now names what the tests pin: the recheck runs under the content-hash lock and requires a verdict that still permits the content. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Apply locked each promoted file's content hash in effect order, while the immediate path sorts its files by hash. Two applies that share files in opposite effect orders could each hold the hash the other waits for. Promotions now run in hash order. The test holds the lower hash, lets an apply whose first effect promotes the higher hash wait on it, and checks that the higher hash is still free. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
write_action_attachments returned at once on an empty file list, even for an Action that declares files. Only a request carries files, and bregctl check keeps them off timer, Evidence and handler Actions, but a compiled registry that binds a file to such an Action committed the record without its file. A file count that differs from the declared count now answers Unavailable and rolls the write back. The test binds a file to a create-only timer Action in the compiled registry and checks that the timer commits no record, revision, outbox row, receipt, application or result. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
The schema fingerprint comment listed the record attachment index but not the registry_record_attachments table that holds record file references. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
authorize_proposal_document read every install_target error as a refusal. install_target turns a database error into a connection error and keeps rejected contexts as configuration errors, so a store failure was taken for a refusal. A record history link check then left the Proposal link out instead of answering 503 as the docs promise. A rejected context still refuses, and any other error now answers Unavailable. install_target keeps no SQLSTATE, so the mapping cannot use map_database_error. No test seam can make the context statement fail between the checks around it, so a unit test pins the mapping. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
The docs style check flags a sentence over 25 words in the Rust README. The three bindings keep the same wording. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
A Proposal's result row names the revision its application wrote, and its foreign key made history erasure through that revision roll back. The erasure now deletes those result rows in the same transaction, so a file the Proposal promoted is erased with the revision. The foreign key stays as it is. A stored application receipt may link a subset of its frozen targets, possibly none, so the Proposal still reads and names no erased revision. The apply itself still links every target. An applied Proposal's read checks its frozen targets as well as its result rows, so a record whose link was erased still bounds who reads the Proposal. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
The retention, configuration and security pages and the changelog say that history erasure removes a Proposal's link to an erased revision, that the Proposal keeps its state and application, and that a promoted file's bytes stay until the Proposal's detail is erased. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…receipt Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
217ba98 to
62b2bf2
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 62b2bf29fa
ℹ️ 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".
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Summary
attachmentsmember in its JSON body and refuses files whose verification has already rejected them.eraseFiles, even if earlier erasure already removed the record’s retained revisions. The result and audit entry count erased and kept file references and removed Proposal links.Upgrade and operation
Install this version on a fresh database. The managed schema fingerprint changes. Update registry revision pins, including for projects with no attachment slots.
Declare record slots under
attachmentsand give readers the applicable slots throughreadableAttachments. Downloads enforce the same lifecycle, disclosure and row checks as the record GET. The operation audit identifies attachment reads and refusals. An undeclared slot gets the general attachment operation.A current Proposal read omits links to erased revisions. While the original receipt is retained, the same authorized caller can replay the apply with the original idempotency key. A live Proposal keeps its own attachment and related held responses after erasure of a promoted Record slot. Erase the Proposal submission under the applicable retention policy when both references must be removed. Bytes remain while a live reference needs them. Erase-and-rebaseline keeps the record’s files.
Evidence
At
217ba9891b, the portability suite passed all 12 tests on both PostgreSQL 17.11 and 18.4. Both produced the same managed schema fingerprint after the attachment metadata constraints changed. The full production-shaped Docs check passed locally after the retention page’s first-use wording fix.At
facd434db1, 27 PostgreSQL attachment tests passed through the existing router fixture. This includes preflight, known rejected files, role and lifecycle visibility, default and named file erasure, a later erasure without retained revisions, erasure counts, stripped metadata and audit identities.Five native retention tests and six CLI history erasure checks passed. The retained object key recheck is covered by the native retention suite. A focused ordinary history erasure case and the route parser check also passed.
Focused BReg and bregctl Clippy, formatting, product validation, identifier reference checks, source neutrality, documentation data tests and evidence anchors passed.
Earlier on this branch, the library suite passed 921 tests. The Proposal, Proposal security, Proposal storage, history erasure and migration suites passed 59, 22, 13, 22 and 61 tests. The contract and client contract gates passed.
The current review fixes were exercised on fresh disposable PostgreSQL. An in-place upgrade, direct immediate-Action external storage rollback/replay, and the remaining client streaming assertions remain unverified. Full workspace CI runs separately.
Record slots are write-once. Proposal Apply rechecks the file and its verification inside the write transaction. History checks the Proposal grant, ownership and row boundaries before exposing a link. See the security matrix BREG-SEC-217 through BREG-SEC-223.
Every commit carries a DCO signoff.
Closes #2794, closes #2795