Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
docs: corroborate nested releases too, format sheet names from the owner
Danny6f100f271846
diff --git a/docs/design/sheet-blob-scoping.md b/docs/design/sheet-blob-scoping.mdindex e5b7463879..785d0caf15 100644--- a/docs/design/sheet-blob-scoping.md+++ b/docs/design/sheet-blob-scoping.md@@ -219,6 +219,13 @@ Three constraints together close it:single release has not identified anything, and `EXISTS` would accept whichever duplicate happensto predate the revision and carry the hash. This is the composite-PK identification rule in`AGENTS.md` applied to an alternate key that turns out not to be one.++ **A release is resolved in two places, and both need the same test.** Directly, from the+ revision's own `release`; and indirectly, when a corroborating task's `payload.release` names one.+ The indirect path is easy to leave on a bare `EXISTS` — it sits nested inside the task branch and+ reads like a lookup rather than a corroboration — but a duplicate release carrying the hash would+ corroborate a task whose intended release did not, which is the same over-grant by a longer route.+ Exactly-one, age, and hash apply wherever `(project, release_id)` is resolved.- **Temporal.** Require the corroborating row's `created_at` to be no later than the revision's.A revision is written after the task run it records completes, so a genuine reference alwayspredates it, whereas a row that reused the ID after a purge is necessarily newer — the purge, the@@ -518,12 +525,19 @@ WHERE r.payload->>'sheetSha256' IS NOT NULLAND (-- task.payload.source is a oneof: a sheet hash, or a release naming onet.payload->>'sheetSha256' = r.payload->>'sheetSha256'- OR EXISTS (- SELECT 1 FROM release rel2- CROSS JOIN LATERAL jsonb_array_elements(COALESCE(rel2.payload->'files', '[]'::jsonb)) AS f2- WHERE rel2.project = (regexp_match(t.payload->>'release', 'projects/([^/]+)/'))[1]- AND rel2.release_id = (regexp_match(t.payload->>'release', 'releases/([^/]+)'))[1]- AND f2->>'sheetSha256' = r.payload->>'sheetSha256'+ OR (+ -- same exactly-one / age / hash test as the direct release branch+ (SELECT count(*) FROM release rel2+ WHERE rel2.project = (regexp_match(t.payload->>'release', 'projects/([^/]+)/'))[1]+ AND rel2.release_id = (regexp_match(t.payload->>'release', 'releases/([^/]+)'))[1]) = 1+ AND EXISTS (+ SELECT 1 FROM release rel2+ CROSS JOIN LATERAL jsonb_array_elements(COALESCE(rel2.payload->'files', '[]'::jsonb)) AS f2+ WHERE rel2.project = (regexp_match(t.payload->>'release', 'projects/([^/]+)/'))[1]+ AND rel2.release_id = (regexp_match(t.payload->>'release', 'releases/([^/]+)'))[1]+ AND rel2.created_at <= r.created_at+ AND f2->>'sheetSha256' = r.payload->>'sheetSha256'+ ))));diff --git a/docs/design/sheet-history-on-database-transfer.md b/docs/design/sheet-history-on-database-transfer.mdindex ca84f21c41..e515cf2fa6 100644--- a/docs/design/sheet-history-on-database-transfer.md+++ b/docs/design/sheet-history-on-database-transfer.md@@ -93,6 +93,8 @@ Change history follows the database; statement content does not.- When a revision's sheet is not readable by the current project, the statement is withheld and theresponse says so explicitly — naming the owning project where that can be verified — rather thanreturning NotFound for the sheet.+- The sheet *name* is formatted from that same resolved owner, not from the database's current+ project. A name is emitted only when it is true.- No sheet references are carried between projects. A database transfer grants no new read access,and the four reassignment paths above need no changes.@@ -223,8 +225,13 @@ corruption outweighs the modelling improvement.## Implementation- A field on the revision response carrying the withheld-content reason and the owning project,- populated by the resolution order above — provenance first, `sheet_blob_ref` second, unknown last- — and distinguishing a live owning project from a purged one.+ populated by the resolution order above — provenance first, `sheet_blob_ref` second, unknown last.+- `convertToRevision` formats `Revision.sheet` from the resolved owner rather than from+ `database.ProjectID` (`backend/api/v1/revision_service.go:304`), and emits no sheet name when the+ owner does not resolve. Leaving it built from the current project would keep exactly the false+ resource name R7 exists to eliminate — a response asserting that project A owns the statement while+ handing the client `projects/B/sheets/{sha}` to follow, which then 404s. The owner is already+ computed for the withheld-content field, so this costs nothing extra.- A UI affordance for the withheld state that names the owning project rather than rendering anerror, and says the project no longer exists when that is the case.- No *carry* logic in `UpdateDatabase`, `BatchUpdateDatabases`, `updateInstanceLifecycle`, or@@ -254,15 +261,16 @@ Tests:is a regression test rather than a contrived one.- Ambiguity: two projects in the caller's own workspace holding refs for one hash resolves tounknown, not to whichever row comes back first.+- Sheet name: after a transfer, `Revision.sheet` names the resolved owner and resolves to that+ project's readable sheet for a caller who holds rights there; when the owner is unknown, no sheet+ name is emitted rather than one pointing at the current project.## Open items-**Sheet name attribution.** `convertToRevision` formats the sheet name with the database's current-project, which is incorrect after a transfer: it names the destination as owner of a sheet the source-authored. The withheld-content response resolves this through provenance, but the `name` field itself-is still built from `db.project` and stays wrong. Fixing it means formatting the name from the same-provenance chain — which works for revisions carrying `release` or `taskRun` and leaves the rest-without a correct name, so it is a partial fix rather than a clean one.+**Revisions with no resolvable owner have no sheet name.** Where the owner resolves, the name is+correct and unchanged for every database that never moved. Where it does not, the response carries+no sheet name at all — a behavior change for clients that assume the field is always populated, and+the residual cost of refusing to emit a name that is not true.**Workspace-level roles have no escape hatch.** The gate checks the ref table for the named project,so workspace admins and DBAs are refused as well, despite holding `bb.sheets.get` broadly. Whether