Skip to content

fix(plugin-audit,cli): activity is written only when an organization is derivable, never as a NULL row; the ceremony deletes the existing NULL rows no anchor attributes (ADR-0131 D9, C8 stage 8b-0c) - #24429

Merged
objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/issue-24343-8b0c-activity-never-null
Oct 19, 2026

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Part of #24343
Part of #15212
Clause-②: no

C8 stage 8b-0c. It executes ruling record 6257510973 item 3 (Q3 A) on #24377: activity is written only when an organization is derivable, and never as a NULL row. #24343 stays open: stages 8b-0d and 8b-0f remain.

What changes

@objectstack/plugin-audit: the activity mirror (audit-writers.ts, the CRUD mirror's derivation).

  • The mirror keeps its derivation, in this order: the record's organization, then the session's, then the tenancy service's Default Organization under single.
  • When none of them is derivable, the mirror now writes no sys_activity row. 8b-0b's ?? null arm is gone.
  • The ledger row (sys_audit_log) is still written, with its D7 tenant_id attribution.
  • An activity table with no organization_id column takes the row unstamped, as before.

@objectstack/cli: the ownership ceremony.

  • sys_activity's inventory row keeps fate 3 (attribution, with the subject anchor). It now also declares a platform-only underivableDeparture (underivable-activity).
  • On every posture but single:
    • The plan counts the NULL rows no anchor attributes as that departure, instead of reporting them as unattributable.
    • The plan warns before the first write that --apply deletes them.
    • The apply's mirror-deletion step deletes them after attribution. It reads them from a fresh plan, and blocks with nothing deleted if that plan still derives an owner for a NULL row or still reports one.
    • The post-check reports the count as the table's deleted.
  • Under single, the Default Organization takes those rows, as before, and nothing is deleted.
  • A checkpointed re-run deletes any such row that has appeared since.

Why a new inventory key and not a mirror-deletion departure. A declared departure is classified before the anchors (walkNullRows), and its where runs over every NULL row. Used here, it would delete the rows the subject anchor can attribute, and under single every row the Default Organization takes. The new key is classified after the anchors and the Default Organization. It is platform-only: the spec's supplement row is unchanged (OrganizationOwnershipSupplementEntrySchema), so a host still cannot declare a deletion. organization-ownership-inventory.test.ts lists the key with the other platform-only keys.

Tests that model single. 19 plugin-audit suites boot the audit writer without AuthPlugin, with org-less records and sessions. Under this change they would model a wall and write no activity. They now boot the single composition they test: src/__tests__/single-posture-tenancy.ts, which is the tenancy service reduced to defaultOrgId(), or getDefaultOrganizationId for the direct installs. Their assertions are unchanged.

Measurements (on origin/main 71fa166e)

  • Producers of sys_activity rows. git grep over packages/** (non-test) finds one insert: audit-writers.ts persistAuditTrailRow, sys.object('sys_activity').create. installActivityStampHook stamps inserts and creates none. An app's own server-side action can still insert into the table directly (sys-activity.object.ts names hotcrm sites); that path goes through the engine, which is 8b's surface, not this stage's.
  • Clause-②: no. No published schema changes. The rows that disappear are the walled NULL rows. A walled reader never received them: Layer 0's organization_id = active organization predicate excludes NULL, and a row is readable only if its parent record is (activity-read-visibility.ts). No docs page, skill or spec description promises an activity row for an org-less record (grep over content/docs, skills, packages/spec/src: 0 hits).
  • Size. 471 insertions and 21 deletions in 28 files, under the 3,000-line threshold.

Verification (head 36af4c05)

  • pnpm --filter @objectstack/plugin-audit test: 56 files, 898 tests passed. Before the suites booted single, the same run had 160 failures in 19 files, all caused by the missing activity rows.
  • pnpm --filter @objectstack/plugin-audit typecheck and pnpm --filter @objectstack/cli typecheck: exit 0.
  • pnpm --filter @objectstack/cli exec vitest run --project unit: 309 files passed. 2 files failed only on the precondition "packages/cli is not built". After pnpm --filter @objectstack/cli build they passed (2 files, 29 tests).
  • Ceremony integration tier (--project integration), the 15 organization-ownership* / apply-organization-ownership-gate suites under commands/migrate/ and utils/: 13 files passed, 1 skipped; 68 tests passed, 1 skipped.
  • New organization-ownership-apply.underivable-activity.test.ts (sqlite fixture):
    • walled (isolated): the plan reports the departure (2 rows) and the warning. The apply attributes 1 row, deletes 2 and leaves remaining 0. The delete runs after the attribution UPDATE. A second run writes nothing to the table.
    • single: 3 rows attributed (2 to the Default Organization), 0 deleted, no warning.
  • packages/qa/dogfood/test/identity-admin-fields-org-peer.dogfood.test.ts (showcase boot, single; the activity reads about sys_user rows as an organization member): 12/12 passed.
  • Ablations, each through scripts/ablation-replace.mjs with the restore proven (blob equals HEAD, git diff HEAD empty):
    • mirror mirrorsActivity && activityOrganizationKnown ? → mirrorsActivity ?: 1 red (writes no activity row under a wall…).
    • plan: the underivable-departure branch in walkNullRows disabled (false && prepended): 3 walled cases red.
    • plan posture !== 'single' arm removed: the single case red.
  • Gates. 72 derived families plus the 53-family artifact roster, each exit code captured before any pipe. dispatch-gates --ran with coded exits: 72 accounted for, 70 run, 2 NOT MEASURED (exit 3).
    • NOT MEASURED, exit 3: check:dual-build-cjs-loads and check:published-readme-exports (no full build); check-plugin-teardown-shape --self-test (shallow clone).
    • NOT MEASURED, no pull request context (exit 2, or 1 for the queue guard): check-closing-target-claim, check-partof-closing-keyword, check-single-claim-paths, check-governed-queue-guard.
    • Every other family exited 0. CI runs all of them.

Acceptance notes

  • derivableActivityOrganization() still catches a throwing tenancy.defaultOrgId() and reads it as "none". Under single such a throw now drops the activity row; before, it wrote a NULL row. The ledger row is still written. A throwing tenancy service under single is not measured to occur.
  • Nothing here touches identity mail (8b-0d), sys_secret or the settings audit (8b-0e), the self-registration grant (8b-0f), or the engine exemption (8b).

🤖 Generated with Claude Code

https://claude.ai/code/session_018oXkooW8d1rtxYGFYwnAiT


Generated by Claude Code

…is derivable, never as a NULL row; the ceremony deletes the existing NULL rows no anchor attributes (ADR-0131 D9, C8 stage 8b-0c)

Ruling record 6257510973 item 3 (Q3 A).

- plugin-audit: the activity mirror takes its organization from the record,
  the session, then the Default Organization under single. When none is
  derivable it writes no sys_activity row; the sys_audit_log row is still
  written. Suites that boot the writer without AuthPlugin now boot the
  single composition they model (src/__tests__/single-posture-tenancy.ts).
- cli: sys_activity's inventory row declares an underivableDeparture. On any
  posture but single, the plan counts the NULL rows no anchor attributes as
  departing (and warns), and the apply's mirror-deletion step deletes them
  after attribution, read from a fresh plan. Under single the Default
  Organization takes them and nothing is deleted.

Claude-Session: https://claude.ai/code/session_018oXkooW8d1rtxYGFYwnAiT
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling labels Oct 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/cli, @objectstack/plugin-audit, touching 17 documentable anchor(s).

12 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/automation/webhooks.mdx (via object_name (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in anchors))
  • content/docs/deployment/cli.mdx (via object_name (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in anchors), record_id (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in anchors), sys_activity (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in object))
  • content/docs/kernel/contracts/storage-service.mdx (via record_id (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in anchors))
  • content/docs/kernel/runtime-services/audit-service.mdx (via object_name (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in anchors), record_id (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in anchors), sys_activity (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in object))
  • content/docs/permissions/record-view-auditing.mdx (via object_name (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in anchors), record_id (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in anchors))
  • content/docs/permissions/system-context.mdx (via sys_activity (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in object))
  • content/docs/plugins/packages.mdx (via sys_activity (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in object))
  • content/docs/protocol/kernel/http-protocol.mdx (via object_name (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in anchors), record_id (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in anchors))
  • content/docs/protocol/kernel/i18n-standard.mdx (via object_name (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in anchors))
  • content/docs/protocol/kernel/realtime-protocol.mdx (via record_id (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in anchors))
  • content/docs/ui/pages.mdx (via record_id (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in anchors))
  • content/docs/ui/setup-app.mdx (via sys_activity (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in object))

⛔ 5 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v14.mdx (via sys_activity (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in object))
  • content/docs/releases/v16.mdx (via record_id (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in anchors), sys_activity (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in object))
  • content/docs/releases/v17/17-5.mdx (via record_id (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in anchors))
  • content/docs/releases/v17/17-6.mdx (via object_name (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in anchors), record_id (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in anchors), sys_activity (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in object))
  • content/docs/releases/v17/17-7.mdx (via sys_activity (literal, a string literal in ORGANIZATION_OWNERSHIP_INVENTORY; a string literal in object))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 5 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 54 of 206 client-bound route-ledger rows — the other 152 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 152: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 55 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 97 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 34 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json e22defb13c171900e2c1c54d1d15c24ed85fe91b → packageMentionDocs.

Which tree this was computed on

This run read content/docs from bd31980ac0466c38ebbd97b626171ece364c23e7 — the merge of head 36af4c053bb716f68ae5687811d0240e3c85b2b5 into base e22defb13c171900e2c1c54d1d15c24ed85fe91b, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin bd31980ac0466c38ebbd97b626171ece364c23e7 && git checkout bd31980ac0466c38ebbd97b626171ece364c23e7
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin e22defb13c171900e2c1c54d1d15c24ed85fe91b 36af4c053bb716f68ae5687811d0240e3c85b2b5 && git checkout -B drift-repro e22defb13c171900e2c1c54d1d15c24ed85fe91b && git merge --no-ff 36af4c053bb716f68ae5687811d0240e3c85b2b5

node scripts/docs-audit/affected-docs.mjs --json e22defb13c171900e2c1c54d1d15c24ed85fe91b

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs e22defb13c171900e2c1c54d1d15c24ed85fe91b → pass the list as
args.docs, on the commit named under Which tree this was computed on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants