Repository navigation
feat(plugin-audit): seal the audit log by default and expire sealed rows by whole checkpoints (ADR-0154 D8, D10) - #37605
objectstack-fleet[bot] wants to merge 8 commits into
Conversation
…154 D8) Claude-Session: https://claude.ai/code/session_01L6bhgUd6hon2o34LQSLbZt Co-authored-by: Claude <noreply@anthropic.com>
…ned expiry amendments (WIP) ADR-0154 D8/D10 P4c: sys_audit_log seals by default; the sealer writes an expiry amendment before the lifecycle service deletes a covered prefix. Claude-Session: https://claude.ai/code/session_01L6bhgUd6hon2o34LQSLbZt Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L6bhgUd6hon2o34LQSLbZt Co-authored-by: Claude <noreply@anthropic.com>
…sealed expiry (WIP) Claude-Session: https://claude.ai/code/session_01L6bhgUd6hon2o34LQSLbZt Co-authored-by: Claude <noreply@anthropic.com>
…l default (WIP) Claude-Session: https://claude.ai/code/session_01L6bhgUd6hon2o34LQSLbZt Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 4 package(s): 15 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 6 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 183 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 504032f30a7a8fae333833480ed56043fc2792e8 && git checkout 504032f30a7a8fae333833480ed56043fc2792e8
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 54d6726c09019bd1d9da29b7aee3fb9e907dbb0a 4deab949980d45dd8a860ca86b187b4c38379691 && git checkout -B drift-repro 54d6726c09019bd1d9da29b7aee3fb9e907dbb0a && git merge --no-ff 4deab949980d45dd8a860ca86b187b4c38379691
node scripts/docs-audit/affected-docs.mjs --json 54d6726c09019bd1d9da29b7aee3fb9e907dbb0a
|
…expiry window Claude-Session: https://claude.ai/code/session_01L6bhgUd6hon2o34LQSLbZt Co-authored-by: Claude <noreply@anthropic.com>
…pins; type the sealed-expiry test's veto sys_audit_log now declares lifecycle.seal, so an `os migrate audit-* --apply` run on SQLite needs --sealer-stopped (ADR-0154 D3 amended, B). The four archive/preview integration files pass it; the changeset names the operator change. The lifecycle sealed-expiry test's partial-veto double returns string ids. Claude-Session: https://claude.ai/code/session_01L6bhgUd6hon2o34LQSLbZt Co-authored-by: Claude <noreply@anthropic.com>
…ule load The edited test file is now judged by the test-source alias gate's source reach: each dist-resolved dependency its served boot reaches through a dynamic import gets a module-top side-effect import. Claude-Session: https://claude.ai/code/session_01L6bhgUd6hon2o34LQSLbZt Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA Contract reviewServed-tier: Inputs: card #31908 (body and all 62 comments), PR #37605 (body, 28 files, net diff against merge base ① Derived judgments
② Semver levelThe changeset moves M2 (must-fix) — the declaration carries no narrowing, and this diff narrows. This card's own precedent is changeset
S2 (should-fix) — ③ Boundary flags
④ Design judgment
S1 (should-fix) —
M1 (must-fix) — S3 (should-fix) — the resumed range is read with no
Nits:
Implemented-by: VERDICT: FAIL |
Requested by Sales · project thread
Fixes #31908
Clause-②: yes (widening) (LifecycleService gains a public prefix-expiry seam for sealed objects)
Metadata-protocol: none (the seal key landed in P1b; this changes a platform object's declaration only)
维护者速读
Tier: not Tier H. About 1,500 changed lines (under 3,000), and no governed path:
packages/spec/src/data/object.zod.tschanges one.describe()sentence only, and theskills/**wording fix is split into this claim's second PR (amendment 7193137455), which is Tier H on its own.What changes
ADR-0154 D8 + D10, slice P4c, the last slice of #31908.
sys_audit_logis sealed by default. Its lifecycle now declaresseal: { valueFields: ['old_value', 'new_value', 'metadata'] }(packages/plugins/plugin-audit/src/objects/sys-audit-log.object.ts). The chain column is the defaulttenant_id(a lookup, one text value on every store).packages/objectql/src/lifecycle/lifecycle-service.ts). New publicregisterSealedExpiry(expiry)(one slot; a later registration replaces it; the disposer clears only its own) and the typesLifecycleSealedExpiry,LifecycleSealedExpiryRequest,LifecycleSealedExpiryRun. For an object withlifecycle.seal:retention.maxAge/ttl.expireAfterlegs and the archive'skeepprune never delete by a row cutoff; each asks the seam toplan({ object, policy, policyValue, cutoff });rowIdsare deleted by id (hot and archive for an archiving object; through the engine, reap guards asked, for the rest), andrun.complete()is called only when every one is gone;seal-expiry-pending, and onewarnsays so;audit-seal/expiry.ts,AuditSealer.expire, registration inaudit-plugin.ts):expiryamendment (the S1 key-id loop, then the sink, best-effort), then answer the run;complete()deletes the checkpoints, then their seeds;audit.sealerlock and the DB seal-pass lock, so two replicas never sign two amendments over one range; a fully drained plan is memoised for the day;last_sequence,last_removed_digest), and the object floor to the newestcovered_to.windowcheckpoint names is sealed, so a lagging chain's rows readlateand unsealed.packages/verify/src/harness.ts, ruling 6884540128 item 4): anAuditPluginthatbootStackmounts (extra, stackplugins, orrequires: ['audit']provider) adoptsharnessCryptoProvider(), the instance settings and the engine get; an instance with its own provider keeps it.lifecycle.sealdescribe sentence (and the regeneratedcontent/docs/references/data/object.mdx),content/docs/data-modeling/objects.mdx(the sentence at :277, plus one line thatsys_audit_logdeclares the block).Tests
packages/objectql/src/lifecycle/lifecycle-service.sealed-expiry.test.ts(new, 9): pending skip and the once-only warning;archive.keepplan on both stores and complete-after-delete;retention.maxAgeper-id engine deletes;ttl.expireAfter; a partial guard veto leaves its run uncompleted; a failing plan deletes nothing; slot replacement and disposer; a malformed registration; an unsealed object keeps the row-cutoff path.packages/plugins/plugin-audit/src/audit-seal/audit-seal-expiry-live.integration.test.ts(new, 8): the real-kernel end-to-end over SQLite with anarchivedatasource.sys_audit_logsealed by its own declaration; the plugin's sealer seals; an interrupted expiry (amendment stored, rows still there) readsexpired; the kernel's own LifecycleService sweep archives, resumes, deletes exactly the expired rows from both stores and then their checkpoints and seeds; a second same-day sweep signs nothing; verify then reads no gap and the untouched windowsunmodifiedin hot and in archive; a fully expired chain's next checkpoint links tolast_removed_digest;modified,missingandredactedare still told apart. A second boot: a sound chain expires whole, a chain stops at a checkpoint no trusted key signed, a chain with a gap is kept, each said once.audit-seal-sealer.test.ts(+1): the S4 sole-chain window readslateunsealed andokfalse.audit-plugin.test.ts(+3): the expiry is registered with a crypto provider, unregistered on destroy, not registered without one, and boot survives a lifecycle service without the seam.packages/cli/src/commands/audit/verify.integration.test.tsandverify.ownership-queue.integration.test.tsnow expectsys_audit_logbeside the fixture ledger inobjectsand in the unreachable-archive message, and case 4 reads that a project with no seal of its own still checks the platform's sealed audit log (exit 0); the fouros migrate audit-*archive and preview integration files (audit-mail-bodies.archive,audit-key-material.archive,audit-side-copies.archive,preview-read-only) pass--sealer-stoppedon their SQLite--applyruns (andpreview-read-only, now judged by the test-source alias gate's source reach, pays its twelve dynamic imports at module top); and in plugin-audit,audit-seal-chain-field-34164.test.tspassesarchive: () => 'none'(its boot connects no archive datasource, asos audit verifyestablishes), andaudit-seal-host-seam-resolve-34280.integration.test.tsforgets what the loop's own first pass reported before each pin counts its own passes.Ablations (each restored, blob == HEAD)
|| start <= this.newestSealedWindow()→|| false: the new sole-chain pin goes red (expected [] to deeply equal [ Array(1) ]), 1 failed | 57 passed.if (lc.seal) return this.reapSealed(…)disabled: 5 of the 9 new lifecycle pins go red.if (lc.seal) {disabled: the two archive pins go red.Acceptance notes
AuditPluginhas no crypto provider now keepssys_audit_logrows pastarchive.keepinstead of pruning them, and says so once per process atwarn.os migrate audit-* --applyon SQLite or Turso now needs--sealer-stoppedwhenever it rewritessys_audit_log: the 18.6.0 rule for a sealed object (ADR-0154 D3 amended, B, seat ruling 6885005594) now meets every deployment. Postgres and MySQL take the lock as before; dry runs are unchanged. Named in the changeset.os audit verifyon a deployment with noarchivedatasource anywhere already reads the hot store alone ('none'); a library caller ofverifyAuditLedgerthat composes no archive must now passarchiveforsys_audit_log, as the adjusted test does.os audit verifyintegration pins and the four CLIos migrate audit-*integration files above (expectations and the flag only),packages/verify/vitest.config.ts(one anchored alias the source-alias gate asks for),scripts/engine-double-contract.pinned.jsonand the plugin-audit tenant-audit census page (both regenerated by their own--write). Named here for the seat.os servecomposition is unchanged (it already hands its host provider toAuditPlugin, P4b).skills/objectstack-data/rules/lifecycle.md"not built yet" wording follows in this claim's second PR (Tier H, amendment 7193137455).Verification
Two-minute check:
cd packages/plugins/plugin-audit && pnpm exec vitest run src/audit-seal/audit-seal-expiry-live.integration.test.ts— expectTests 8 passed (8).Read first (risk order):
packages/plugins/plugin-audit/src/audit-seal/expiry.ts(chainRun: resume, gap, admission, budget),packages/objectql/src/lifecycle/lifecycle-service.ts(sweepSealed/deleteSealedRows: complete only after every row is gone),packages/plugins/plugin-audit/src/audit-seal/sealer.ts(expire: locks around planning; the head fallback).Local runs at 51ba1c1 (each under os-verify-lock, exit captured before any pipe)
pnpm turbo run buildover the plugin-audit, verify and cli closures: exit 0.src/commands/audit/,serve-audit-registration.contract,app-audit-plugin-host-crypto,schema-migrate.one-shot-family.integration: 4 red before the pin updates (all the seal default), then the two adjusted files 15 passed (15).src/data+metadata-form-zod-reconciliation: 6963 passed | 1 todo; service-settings 1521 passed; lintvalidate-security-posture224 passed; runtime's twosys_audit_loglifecycle integration files 14 passed | 2 skipped.pnpm --filter @objectstack/{objectql,plugin-audit,verify}tsc --noEmit: exit 0.eslint --no-inline-configon the 15 changed sources: exit 0.gen:schema && gen:docsregeneratedcontent/docs/references/data/object.mdx.dispatch-gates --commands: 128 derived. 127 exit 0 at the end, after four fixes (check:engine-double-contractandcheck:objectql-double-limiton the new lifecycle double,check:test-source-aliason verify's new import,check-tenant-audit-censuson the new amendment insert, each--writeregenerated or fixed at source). One NOT MEASURED:check-plugin-teardown-shape --self-testexits 3, PREREQUISITE NOT MET (needs an unshallow clone; its scan exits 0). Three that first exited 3 while a build ran beside them (check:skill-examples,check:dual-build-cjs-loads,check:i18n) exit 0 on re-run.typecheck(test files included) exit 0; cliaudit-mail-bodies.archive,audit-side-copies.archive,audit-key-material.archive,preview-read-onlyandaudit-redaction-seal.contract: Test Files 5 passed (5), Tests 57 passed | 1 skipped, exit 0 (14 red before--sealer-stopped, all the seal default).check:test-source-aliasexit 0;preview-read-only8 passed | 1 skipped.overlap-checkat 4deab94: merges cleanly with origin/main 0f6a1e5, 0 PR heads.Generated by Claude Code
🤖 Generated with Claude Code
https://claude.ai/code/session_01L6bhgUd6hon2o34LQSLbZt