Repository navigation
feat(cli): os migrate audit-side-copies runs the at-rest side-copy rewrite on the live audit tables and the archive - #33607
Conversation
…d the rewrite's amendment name before the code The archive integration suite drives the command over the hot tables and an archive datasource (dry run, --object, apply, re-run, refusal); the family rosters gain the new member; the live redaction suite pins the name a sealed row's amendment records. Docs and the changeset say how to run it. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cz2MxDkQYCC4U8indM
…write, hot and archive The command drives plugin-audit's migrateSideCopies and migrateArchivedSideCopies with audit-key-material's shape (read-only dry run by default, --apply/--yes/--force/--json, the redaction seal, the archive classification and exit codes) plus a repeatable --object over the two copy tables; any other name is refused OBJECT_NOT_FOUND before the boot. The rewrite's redaction amendments now name it 'os migrate audit-side-copies', as the twins name theirs. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cz2MxDkQYCC4U8indM
📓 Docs Drift CheckThis PR changes 2 package(s): 11 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
What this run could not see
Coarse fallback — 45 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 8821ca81af391c7f57cb07055caef997cba14f5e && git checkout 8821ca81af391c7f57cb07055caef997cba14f5e
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin c32bb6ccbb293a4bda77010ce7ad416fcfeb1138 34582583df4b86a5250a4adefee4d4f7a3ae3521 && git checkout -B drift-repro c32bb6ccbb293a4bda77010ce7ad416fcfeb1138 && git merge --no-ff 34582583df4b86a5250a4adefee4d4f7a3ae3521
node scripts/docs-audit/affected-docs.mjs --json c32bb6ccbb293a4bda77010ce7ad416fcfeb1138
|
|
Contract-review-claim: session_016WV4d1PGptBW3QRQNmy5e6 · head 3458258 · 2026-11-15T02:39Z review#3. |
Contract reviewServed-tier: Read: the PR's two commits on top of ① Derived judgmentsThe driver is the twin, plus
Audit data stays safe.
The
The pins measure the claims, with one gap, N1. Cases 0–5 drive the real Archiver and the source CLI. They compare both stores row for row, check which keys survive in a rewritten copy ( The docs match the behaviour. In ② Semver level
③ Boundary flagsNone. The diff stays in Nits (none blocks).
Implemented-by: VERDICT: PASS |
|
domain:server#5 · os-elon-musk · session_016WV4cz2MxDkQYCC4U8indM ACCEPT: head 3458258
Landing: ready for review, then auto-merge (the area rule for PRs that passed review, 2026-11-15T03:10Z). |
Requested by Elon · project thread
Fixes #33155
Clause-②: yes (widening)
Metadata-protocol: none
Maintainer quick read
os migrate audit-side-copies, runs plugin-audit's at-rest side-copy rewrite (an approval request'spayload_jsonremoved from old audit and activity copies) on the live tables and on the archive. The rewrite's amendments now record that command as their name.--apply --yes. Nothing runs it automatically. Rollback is reverting this PR; rows it already rewrote stay rewritten, as for its three twins.packages/cli/src/commands/migrate/audit-side-copies.ts(the--objectrefusal before the boot, and the two runner calls withobjectsandseal);packages/plugins/plugin-audit/src/side-copy-migration.ts(the one-line name change);packages/cli/src/commands/migrate/audit-side-copies.archive.integration.test.ts.pnpm --filter @objectstack/cli exec vitest run --project integration src/commands/migrate/audit-side-copies.archive.integration.test.tsshows 9 tests passing: dry run,--object, apply, re-run, archive, refusal.What changes
os migrate audit-side-copies(new,packages/cli). It runsmigrateSideCopieson the livesys_audit_logandsys_activityrows, thenmigrateArchivedSideCopieson the archive datasourcesys_audit_logarchives to. It is a twin ofos migrate audit-key-material, line for line: the read-only dry-run boot, the absent-table read view, the redaction seal (ADR-0154 D7), the archive classification (examineArchiveTargets) and the exit codes. Its flags are the same (--database-url,--apply,--yes,--force,--json), plus one more:--object, repeatable, takessys_audit_logorsys_activity. It narrows the hot run and the archive run to the tables it names; without it, both tables are walked. A name that is not a copy table is refused with the family's envelope,OBJECT_NOT_FOUNDand exit 1, before the boot, so a typo never narrows a run to nothing.scanned), rewritten or to rewrite (rewritten) and sealed-and-refused (refused), for the hot store and for each archive. The--jsondocument is{ database, apply, objects, report, archive, duration }. No line prints a value.packages/plugins/plugin-audit/src/side-copy-migration.ts). A redaction amendment now recordsrewritten_by: 'os migrate audit-side-copies'instead ofside-copy-migration.content/docs/deployment/cli.mdxgets a table row, a#### os migrate audit-side-copiessection, and the command added to the read-only-boot and sealed-rows paragraphs.content/docs/upgrading.mdxgets an "Upgrading from 18.4.0 or earlier" line. The sibling migrations are documented in these two places; the plugin-audit README documents none of them.audit-redaction-seal.contract.test.ts,migrate-confirmation-exit.pin.test.ts,json-stdout-purity.e2e.test.ts,schema-migrate.one-shot-family.integration.test.ts, anddata-commands.absent-database.integration.test.ts(with a seeded livesys_activitycopy, so the hot activity path is driven too).The name, and why
Round 3 of the #33117 contract review said: "The rewrite records its amendments as
side-copy-migration; the two precedents record the command name (os migrate audit-key-material,os migrate audit-mail-bodies). Settle the name when the door lands."audit-side-copies. The three siblings are namedaudit-plus what they rewrite:audit-metadata-bodies,audit-mail-bodies,audit-key-material. This rewrite removes the columns of the listside-copy-columns.tsholds (SIDE_COPY_COLUMNS), asaudit-key-materialremoves the listkey-material-copy.tsholds.audit-approval-payloadswould name the only entry today, but the list is keyed by object and built to take more, so the name follows the list.os migrate audit-side-copies. All three precedents record the full command (os migrate audit-...) asrewritten_by, so an operator readingsys_audit_amendmentfinds the command to re-run. The old name never shipped in a release: feat(approvals,mcp): an approver's agent lists the approvals waiting on them over MCP #33117's changeset is still pending. A row amended on a pre-release build keeps the old name, which the changeset says.os migrate audit-* --applyhold a database session lock. This command matches that pattern and takes the same--applypath as its twins, so P4b3 covers it with no special case. This PR builds no lock.Tests
Every new pin was run red before the code existed. The command file was held out of the tree, and plugin-audit still recorded the old name.
0c23193ab(tests only):audit-side-copies.archive.integration.test.ts: 7 failed, all withError: command migrate:audit-side-copies not found. Test 7 ("no run prints a sentinel") passed, as it must when nothing runs.audit-redaction-seal.contract.test.ts: failed withENOENT ... audit-side-copies.ts.audit-seal-redaction-live.integration.test.ts: 1 failed, 16 passed. Expected"os migrate audit-side-copies", received"side-copy-migration".34582583d:audit-side-copies.archive.integration.test.ts, 9 cases:sys_audit_log1 scanned / 1 to rewrite and archive 2 / 2. Both stores are byte-identical afterwards.--object sys_activity --applyreads onlysys_activity, has no archive entry, and leaves both stores unchanged.--applyleaves 0 carrying copies in either store and reports what it wrote. Every other key, column and the unlisted object's row is unmoved.--object sys_approval_requestis refused withOBJECT_NOT_FOUND, exit 1.data-commands.absent-database.integration.test.ts: the new door answers empty work on a missing database, and on the booted control it rewrites 1sys_audit_logand 1 livesys_activitycopy.schema-migrate.one-shot-family.integration.test.ts: the dry run writes nothing and--applybehaves as its family does.redactedunderrewritten_by: 'os migrate audit-side-copies'.No separate ablation was run. The red run above is the before-and-after for each pin: the behaviour is new, and the same files go from red to green with only the implementation added.
Acceptance notes
sys_activitydeclares no archive target, so--object sys_activityreportsarchive: []. Case 2 pins that.none/not-connected/unknown) is pinned inaudit-key-material.archive.integration.test.tsandaudit-mail-bodies.archive.integration.test.ts. It is not repeated here, because this command calls the sameexamineArchiveTargets.docs/adr/0154-...mdlists the three earlier rewrites by command. It is not edited here: the ADR is a decision record, not a roster.Verification
All readings are at head
34582583d(worktree cut fromorigin/main4bba8b8f0).Local runs
pnpm --filter '@objectstack/cli^...' buildunder the verify lock:VERDICT command-exit 0.pnpm --filter @objectstack/plugin-audit typecheck:VERDICT command-exit 0.pnpm --filter @objectstack/plugin-audit exec vitest run: Test Files 93 passed (93), Tests 1502 passed (1502),VERDICT command-exit 0.pnpm --filter @objectstack/cli typecheck(tsc pluscheck:test-typecheck):VERDICT command-exit 0.pnpm --filter @objectstack/cli exec vitest run --project integrationon the three touched integration files: Test Files 3 passed (3), Tests 240 passed (240),VERDICT command-exit 0.pnpm --filter @objectstack/cli exec vitest run --project unit: Test Files 418 passed and 2 failed (420); Tests 5944 passed, 29 skipped.test/published-subpath-console.pin.test.tsandtest/published-subpath-hook-body.pin.test.ts. Both refused with "packages/cli is not built (./dist/index.js is absent)", a missing-prerequisite refusal, not a finding. The closure build does not buildpackages/cliitself. The touchedmigrate-confirmation-exit.pin.test.tsandaudit-redaction-seal.contract.test.tsare in the 418 that passed.test/json-stdout-purity.e2e.test.ts: NOT MEASURED. Reason: the verify lock queue-timed out (exit 99) behind another worktree's holder. CI runs it.eslint --no-inline-configon the 9 changed.tsfiles: exit 0.node scripts/check-test-source-alias.mjs: exit 0.node scripts/check-nul-bytes.mjs: exit 0.node scripts/pm/dispatch-gates.mjs --commands: 103 families derived. All 103 were run, and--ranreconciles 103/103.check:i18n,check:i18n-coverage,check:i18n-walk-parity,check:type-check-debt: "the workspace CLI is not built".check:dual-build-cjs-loads: a package with nodist/.spec check:skill-examples: client-react not built.check-plugin-teardown-shape --self-test: the shallow clone cannot reach its pinned fixture.Human Minimum
packages/specholds no runtime logic. (packages/specnot touched.)main, one pull request.packages/specnot touched.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_016WV4cz2MxDkQYCC4U8indM