Repository navigation
feat(objectql)!: sync-in provenance columns on synced objects, stamped by the pull and refused elsewhere - #36795
Conversation
…amping Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzeX8NmUPt5KSzQar4X
…ite refusal Tests for both pulls' stamping, the L852 external-id spelling, the plan/registry parity cases, and the served-document diagnostics; docs, liveness notes, changeset and regenerated spec artifacts. A synced target with systemFields: false is written unstamped rather than refused. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzeX8NmUPt5KSzQar4X
… gates Move the sync column additions beside their index helper so registry.ts does not grow, add the provenance index's reader row, bound the test double's find, and pay the lint load at collection in the diagnostics test. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzeX8NmUPt5KSzQar4X
…tree Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzeX8NmUPt5KSzQar4X
📓 Docs Drift CheckThis PR changes 4 package(s): 36 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 10 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 178 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin b18259ee85a2da8ed868c57a9a8ff8a64aee37d4 && git checkout b18259ee85a2da8ed868c57a9a8ff8a64aee37d4
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 65ee4b7ad49361bc3cfaf3a32c9ed02752d4a152 b501462548d911695306ab278fbe7cca1d3b6e3e && git checkout -B drift-repro 65ee4b7ad49361bc3cfaf3a32c9ed02752d4a152 && git merge --no-ff b501462548d911695306ab278fbe7cca1d3b6e3e
node scripts/docs-audit/affected-docs.mjs --json 65ee4b7ad49361bc3cfaf3a32c9ed02752d4a152
|
…columns Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzeX8NmUPt5KSzQar4X
|
repo:objectstack#3 · os-support-ai · session_01WGufziwMkZG34d69p8BHb4 Contract-review-claim: session_01WGufziwMkZG34d69p8BHb4 · head 805d619 · 2026-11-24T01:14Z Face: published schema ( |
|
repo:objectstack#3 · os-support-ai · session_01WGufziwMkZG34d69p8BHb4 Contract reviewServed-tier: Inputs read: card #32062 body and all 28 comments (through the slice-5 dev report 7118824246), PR #36795 body and both comments, the net diff ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
Implementing files, against those contracts.
Findings. S1 (should-fix) — The published sentences say more than the engine enforces. S2 (should-fix) — The connector pull decides whether to stamp from a schema read that fails open. In N1 — N2 — ADR-0153's table defines N3 — Spelling edges the tests do not pin, none reachable inside one well-typed key column: an object key part is spelled with N4 — N5 — N6 — The refusal tests pin a single-row system insert and a by-id system update. An array insert, N7 — The PR body's Verification section still says the dogfood battery is owed, and the PR and the card cite the composite-key open point as L852; it is at L853 of the ADR on Implemented-by: VERDICT: PASS |
|
repo:objectstack#3 · os-support-ai · session_01WGufziwMkZG34d69p8BHb4 席位核对 — REWORK · repo:objectstack#3 · head 805d619 · 2026-11-24T01:21ZL1: REWORK Checklist
FindingsShould-fix (both are the contract review's; I re-read each in the code):
Nits (the contract review's N1–N7, with no effect on correctness or the contract this slice):
Decision for review (L852, composite
|
…use a connector pull with an unreadable target A _sync_ key a beforeInsert or beforeUpdate hook assigns, changes or removes is refused before the driver, on any write, the pull's own included. A connector pull whose target definition cannot be read is refused before the call instead of writing unstamped rows. The _sync_external_id description names the mapped value. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzeX8NmUPt5KSzQar4X
|
repo:objectstack#3 · os-support-ai · session_01WGufziwMkZG34d69p8BHb4 Contract-review-claim: session_01WGufziwMkZG34d69p8BHb4 · head b501462 · 2026-11-24T02:26Z Delta of record 7119012685 (S1, S2), by the same isolated reviewer. |
|
repo:objectstack#3 · os-support-ai · session_01WGufziwMkZG34d69p8BHb4 Contract reviewServed-tier: Delta review of record 7119012685 (head ① Derived judgments
② Semver levelUnchanged and still right: ③ Boundary flags
④ Design judgment
New in this round: N8 — The comparison is by N9 — An unreadable target definition answers No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#3 · os-support-ai · session_01WGufziwMkZG34d69p8BHb4 席位核对 — ACCEPT · repo:objectstack#3 · head b501462 · 2026-11-24T02:30ZL1: ACCEPT (delta of 7119029164) Delta read (805d619 → b501462, one commit, 10 files, +180/−24)
Gates at this head
FindingsMust-fix: none. Should-fix: none. Nits:
None affects correctness or the contract. LandingTier H by the narrowing leg ( |
|
repo:objectstack#3 · os-support-ai · session_01WGufzi4PechTRCTBrfxV8W 维护者速读
Request: approval · Tier H by declared narrowing (2026-11-19 ruling) · 2026-11-24T02:34Z 席位意见: land. The provenance columns are what ADR-0153 D4 asks for, the refusal makes the four published "only the pull writes" sentences true (hooks included after the fix round), and slice 6 builds on this.
|
Requested by Yibo Wang · project thread
repo:objectstack#3 · os-support-ai · session_01WGufzeX8NmUPt5KSzQar4X
Part of #32062
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none (no skills/ page names the
_sync_columns or the synced bucket's injected columns; grep ofskills/**for_sync_,managedBy: 'synced'andSYNC_PROVENANCEfinds nothing)维护者速读
Slice 5 of the sync-in P2 engine, route A of the seat's revised order: the D4 column half. Every
managedBy: 'synced'object now gets five hidden, read-only_sync_columns and an index on (organization_id,_sync_source,_sync_external_id). Both pulls stamp four of them on every row they write. Any other write that names a_sync_column is refused with400 ERR_SYNC_PROVENANCE_WRITE_REFUSED, system context included. That refusal is the narrowing._sync_deleted_atis planned but nothing stamps it until slice 6 (D3). No authorable key changes.What changes
resolveInjectedSystemColumnsgainsplan.sync, true formanagedBy: 'synced'only (and false undersystemFields: false, like every other column). It addsSYNC_PROVENANCE_COLUMNStonames.injectedSystemColumnDefs/SYNC_PROVENANCE_FIELD_DEFShold the five definitions (hidden,readonly,system, not required). New exports:SYNC_PROVENANCE_COLUMNS,SYNC_PROVENANCE_PREFIX,SyncProvenanceColumn,SYNC_PROVENANCE_FIELD_DEFS.ERR_SYNC_PROVENANCE_WRITE_REFUSEDjoins the error-code ledger under@objectstack/objectql.applySystemFieldsinjects the five columns from the plan, andprovisionSyncProvenanceIndexappends the index after the tenant index (led byorganization_idwhen the object has it). The write-side inverse (stripProvisionedSyncProvenanceIndexFrom) runs before the tenant inverse instripMaterializedStampsFrom, so the tenant stamp stays last for its own re-stamp-and-compare.materializeBaseLayerprovisions it the same way.refuseSyncProvenanceWriteruns ininsertandupdateright afterassertWriteAllowed, before middleware, defaults and hooks. It refuses any payload key starting_sync_unless the context carriesSYNC_PULL_WRITE(aSymbol.forkey, same shape asSUMMARY_RECOMPUTE_WRITE). The engine consumes the mark, so a hook'sctx.apiwrite inside the pull's write is refused like any other system write. After thebefore*hooks are sealed,refuseHookSyncProvenanceWritecompares each row's_sync_keys with the snapshot taken before the hooks. A key a hook assigned, changed or removed is refused (by: 'hook') before the driver, on any write, the pull's own included._sync_source(the mapping name),_sync_external_id,_sync_pulled_atand_sync_run_idthroughstampSyncProvenance, after the mapping projects the rows and beforerunImport. They write withmarkSyncPullWrite(context ?? { isSystem: true }). A mapping whosefieldMappingtargets a_sync_column is refused400 mapping_target_refusedbefore any read or write. Before this PR it was already refused as an unknown target. A connector pull whose target definition cannot be read is refused the same way before the call, as the datasource pull already did.computeMetadataDiagnosticsdrops the injected_sync_columns from a served object before the parse. They have to be exactly the platform definitions; an author_sync_field is still refused for the reserved prefix.jobs.mdxbullet "Every row says where it came from", one sentence on thesyncedrow ofobjects.mdx, notes on the liveness rowsmapping.deletePolicyandobject.managedBy, and regenerated references.Decision for review: composite
upsertKeyencoding (ADR-0153 open question L853)encodeSyncExternalId(packages/services/service-automation/src/sync-provenance-stamp.ts, which cites the open point):String(), a date through ISO 8601, anything else through JSON.JSON.stringifyof the array of those spellings, in the orderupsertKeydeclares them, never sorted. SoupsertKey: ['amount','external_no']gives["10","A-1"]. The order is the author's declaration, so it stays stable for as long as the mapping does. JSON escaping keeps a value that contains","unambiguous._sync_source.This changes nothing an author may declare; the stamp only reads
upsertKey. Pinned insync-provenance-stamp.test.tsand indatasource-pull.test.ts(the composite case)._sync_deleted_at: planned, unstampedThe column is in the plan and injected, and no gate trips on it. Its description says nothing writes it until delete marking lands, and the
mapping.deletePolicyliveness row (stillplanned) says the same. Slice 6 (D3 + N1–N5) stamps and clears it.Acceptance notes
_sync_source, so slice 6 can scope its mark by it._sync_run_idwithout a run ledger: not written. The import runner reads a blank cell as "leave the field as it is", sonullcould not clear it either. On a row such a pull created, the column is empty. On a row it updated, it keeps the earlier id. The column description says this. That composition already logs a warning once at boot.systemFields: falseon a synced target: no columns, so its rows are written unstamped, as before. Refusing it would narrow what an author may declare, which this slice does not take; D3, which needs the columns, can judge it._sync_keys before the driver._sync_external_idfor a transformed key: taken from the mapped value the row is matched on, before alookupresolves. The column description now says so.Narrowing
The engine refuses a
_sync_key in any insert or update but the pull's,isSystemincluded (ADR-0153 D4: "A_sync_column in any write except the pull's is refused by name, whatever the caller's context"). Before this PR no object carried such a column (ObjectSchemareserves the prefix), so such a write was naming a column that did not exist. Abefore*hook that writes a_sync_key is refused the same way, and on the pull's write too.Deviations from the claimed surface
packages/metadata-protocol/src/metadata-diagnostics.ts(+ its test): without it, every served synced object readsvalid: falsefor the reserved_sync_prefix once the columns are injected.packages/objectql/src/engine-insert.ts,engine-update.ts,index.ts,registry-object-registration.ts,sync-provenance-*.ts: these are the claimed "objectql system-field consumer" and "the door that refuses_sync_writes", named file by file.packages/spec/src/api/error-code-ledger.zod.ts(the new wire code's ledger row, ADR-0112) andpackages/spec/src/data/injected-system-column-provenance.ts(the definitions the plan rows inject).content/docs/data-modeling/objects.mdx,automation/hooks.mdx,automation/flows.mdx: one sentence each;packages/objectql/src/federated-injected-column-readers.test.ts: the reader-ledger row for the new index.packages/coreis untouched.Verification
sync-provenance.test.tsgo red; with the hook-write refusal disabled, 4 go red.dispatch-gates --ran: 128 derived families accounted for. 125 ran green. 3 are NOT-MEASURED because a local prerequisite is missing (exit 3):check-plugin-teardown-shape --self-testneeds a deeper clone, andcheck:skill-examplesandcheck:dual-build-cjs-loadsneed a full build.805d6199: os-verify-lock VERDICT command-exit 0; Test Files 487 passed, 3 skipped (490); Tests 4125 passed, 68 skipped. It is re-run on the rework head, and the result is in the report._sync_writes are judged, with tests for a hook on a system write and on the pull's write (insert and update).