Skip to content

feat(plugin-audit): mark in-product AI writes on sys_audit_log rows (agent, conversation, confirmation) - #34547

Merged
os-zhuang merged 9 commits into
mainfrom
claude/project-thread-j2xdku
Nov 17, 2026
Merged

os-zhuang merged 9 commits into
mainfrom
claude/project-thread-j2xdku

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread
Fixes #33694

Clause-②: no
Metadata-protocol: none

维护者速读

  1. 改了什么:产品内 AI 替某人改记录时,审计日志那一行现在写明是哪个 AI(performed_by)、替谁(on_behalf_of)、在哪次对话(conversation_id)、经哪次确认(confirmation_id,没确认就不写)。
  2. 为什么改:之前 AI 改的数据在审计日志里和本人手改一模一样,回答不了「这条是 AI 替张三在哪次对话里改的」;契约字段早已在 main(spec(kernel/data): let a server-constructed in-product AI path set ExecutionContext.performedBy / HookContext.provenance (AI on behalf of a person, conversation id, confirmation id), and amend the ADR-0090 D10 rule 4 "/mcp OAuth door only" reading #33786),只差审计写入器去读。
  3. 风险与回滚:只加 metadata 键,user_id / actor 仍是本人,人手改的行不变;回滚即撤本 PR,历史行不受影响。
  4. 先看:packages/plugins/plugin-audit/src/audit-writers.ts(performedBy 取值与 metadata 拼装两处)、agent-dual-attribution.integration.test.ts 末尾新增的 describe、packages/spec/src/kernel/execution-context.zod.ts 的 describe 改句。
  5. 两分钟验证:pnpm --filter @objectstack/plugin-audit exec vitest run src/agent-dual-attribution.integration.test.ts,预期 15 条全绿,其中 6 条是本卡新用例。
  6. 需要你做的:无,席位落地。

What changes

  • The record-write audit writer reads the in-product AI performer. audit-writers.ts read only provenance.performedByClientId (the /mcp OAuth client). It now also reads provenance.performedByAgentId, performedByConversationId and performedByConfirmationId, which buildProvenance already copies from ExecutionContext.performedBy (spec(kernel/data): let a server-constructed in-product AI path set ExecutionContext.performedBy / HookContext.provenance (AI on behalf of a person, conversation id, confirmation id), and amend the ADR-0090 D10 rule 4 "/mcp OAuth door only" reading #33786, PR feat(spec, objectql, runtime): the in-product AI path can name itself on ExecutionContext.performedBy, and hooks see it on HookContext.provenance #34018). On a row the in-product AI wrote for a person, sys_audit_log.metadata carries:
    • performed_by: the agent, beside on_behalf_of: the person (the existing pair, per the owner ruling on objectstack-ai/cloud#3826 「3826 照建议(征询版)」: reuse performed_by / on_behalf_of, no new actor vocabulary);
    • conversation_id: the AI conversation;
    • confirmation_id: the pending item the person's approval decided, only when there was one.
      user_id and actor stay the person (ADR-0073 D3, ADR-0118 D1/D5). A personal write still carries no metadata. conversation_id / confirmation_id are written only when the in-product agent is the recorded performer, never beside an OAuth client id. If an envelope ever carried both clientId and agentId (each producer sets only its own), the row records the OAuth client and drops the agent with its two marks.
  • Spec describes. The ExecutionContext.performedBy and HookContext.provenance.performedByAgentId / performedByConversationId / performedByConfirmationId describes and JSDoc no longer say the audit writer "does not record them yet". They name the metadata keys; say that performed_by holds either an OAuth client id or an in-product agent name, and state only what a reader can tell from a row: a value matching the client_id of an existing sys_oauth_application row is an OAuth client; a row carrying conversation_id or confirmation_id names an in-product agent; a row meeting neither may name an agent or the client of a since-deleted application, which the row alone cannot tell apart; and the contract does not keep an agent name and a client_id from being the same string; state the both-performers precedence; and say the action-invocation, data-export and dataset-query rows still record clientId only. The performedBy JSDoc's "no key holds two id namespaces" sentence now names the audit key as the ruled exception. No schema shape change; content/docs/references/** regenerated (gen:docs).
  • Changeset .changeset/33694-audit-in-product-ai-performer.md: @objectstack/plugin-audit patch, @objectstack/spec patch (describe text ships).

Why

The in-product AI writes as the signed-in person, so its rows were byte-identical to that person's own edits on every attribution column. The contract fields that tell them apart landed in #33786; nothing recorded them.

Tests

New top-level describe in packages/plugins/plugin-audit/src/agent-dual-attribution.integration.test.ts (the existing rule 4 harness: real kernel, assembleExecutionContext, objectql buildProvenance, the shipped sys_audit_log object and writer on sqlite-wasm). The person's envelope is built at the real door; performedBy is added as the in-product AI path stamps it (that producer lives outside this repository).

  • CONTROL: the envelope is a human principal with no performedBy, and user_id / actor are the person on all four rows.
  • A confirmed AI create records { performed_by, on_behalf_of, conversation_id, confirmation_id }.
  • An AI create that needed no confirmation records no confirmation_id.
  • An AI update of a record the person created is marked on the update row; the person's own create row stays unmarked.
  • An envelope naming an OAuth client beside a conversation and a confirmation records only { performed_by: client, on_behalf_of }.
  • An envelope naming both performers records the OAuth client, without the agent's marks.

The last two envelopes have no producer in the tree; they pin what the spec tells a reader.

No existing test changed.

Acceptance notes

Verification

Local runs (head and gate list in the report comment on #33694)
  • pnpm --filter '@objectstack/plugin-audit^...' build under the verify lock: exit 0.
  • pnpm --filter @objectstack/plugin-audit exec vitest run src/agent-dual-attribution.integration.test.ts: Test Files 1 passed, Tests 15 passed.
  • pnpm --filter @objectstack/plugin-audit test (after merging main): Test Files 101 passed, Tests 1676 passed. pnpm --filter @objectstack/plugin-audit typecheck: exit 0, test-typecheck 0 errors.
  • pnpm --filter @objectstack/spec exec vitest run src/kernel/execution-context.test.ts src/data/hook.test.ts: Tests 146 passed.
  • pnpm --filter @objectstack/spec build && check:generated: content/docs/references/** stale, regenerated with --fix, re-check green.
  • Ablation (scripts/ablation-replace.mjs, anchor hit 1 → 0): performedBy = performedByClientId ?? performedByAgentId → performedByClientId reds the three AI-row tests (3 failed / 10 passed); restore blob == HEAD, git diff HEAD empty.
  • Round 2 ablation: agentIsRecordedPerformer = !performedByClientId && performedByAgentId !== undefined → performedBy !== undefined reds the two new pins (2 failed / 13 passed); restore blob == HEAD, git diff HEAD empty.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes (CI).
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

Generated by Claude Code

@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation protocol:data tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

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

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

  • content/docs/automation/hook-bodies.mdx (via HookContextSchema (symbol, a top-level const))
  • content/docs/permissions/system-context.mdx (via ExecutionContextSchema (symbol, a top-level const))

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

  • content/docs/releases/v17/17-0.mdx (via HookContextSchema (symbol, a top-level const))

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
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 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 — 176 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 066177b80fd6a444e3fc44a23cb6b818d2407399 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 8b13c4f046c6854a5bc3ca41e5fb59f6783a386f — the merge of head 24233e955c33ee77052d41ad1e7acdadc37f2368 into base 066177b80fd6a444e3fc44a23cb6b818d2407399, 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 8b13c4f046c6854a5bc3ca41e5fb59f6783a386f && git checkout 8b13c4f046c6854a5bc3ca41e5fb59f6783a386f
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 066177b80fd6a444e3fc44a23cb6b818d2407399 24233e955c33ee77052d41ad1e7acdadc37f2368 && git checkout -B drift-repro 066177b80fd6a444e3fc44a23cb6b818d2407399 && git merge --no-ff 24233e955c33ee77052d41ad1e7acdadc37f2368

node scripts/docs-audit/affected-docs.mjs --json 066177b80fd6a444e3fc44a23cb6b818d2407399

⚠️ 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 066177b80fd6a444e3fc44a23cb6b818d2407399 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmSYVw1sqCsaHSJS9JC

Final head for L1 and contract review · 2026-11-17T01:07Z
Final head: 768136c0ef3a8d15683477fed1f62bb2b4c8b72f (card #33694, area o2-B). CI at this head: every check completed success or skipped by path filter (Build Core, Test Core 1–8/8 + aggregate, Test UI 1–16/16 + aggregate, Build & E2E UI, Type Check UI, TypeScript Type Check, Lint & Repo Gates, Spec property liveness, Check Changeset, Build Docs, PR-body guards, Governed Surface Queue Guard); none red. The PR body was patched after the head (Acceptance notes, filed #34556); the head did not move.
Owed: L1 (L1-a, first review) and a contract review (L2), since the performedBy / provenance.performedBy* describes in packages/spec/src/** change. New metadata key names conversation_id / confirmation_id approved by the seat.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq

Contract-review-claim: session_01ADHkmP44onN8RMzsPMqjRq · head 768136c · 2026-11-17T01:08Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmSmxJiAWk7fuq3Q1Sf

席位核对

L1 verdict: ACCEPT · card #33694 · area o2-B · first review · read at 2026-11-17T01:09Z
Head-sha: 768136c0ef3a8d15683477fed1f62bb2b4c8b72f (the final head announced in comment 6934548662)

Checklist, read against GitHub and the head tree, not against the report:

  • Shape. Draft, base main, mergeable_state: clean. The first card line is Fixes #33694, and it is the only closing keyword in the body. Fixes is right: the card is the plugin-audit writer half after the split (6893182618), and its blocker spec(kernel/data): let a server-constructed in-product AI path set ExecutionContext.performedBy / HookContext.provenance (AI on behalf of a person, conversation id, confirmation id), and amend the ADR-0090 D10 rule 4 "/mcp OAuth door only" reading #33786 is closed. The remaining writers and the doc table are carried by audit: action-invocation, data-export and dataset-query rows record only performedBy.clientId for in-product AI calls #34556, which is open, pm:blocked, Blocked-by sys_audit_log: mark in-product AI writes (AI on behalf of a person, conversation id, confirmation id) #33694, and enumerates all four items.
  • File surface (get_files, 8 files, +243/-33). packages/plugins/plugin-audit/src/audit-writers.ts, its integration test, and the describe and JSDoc in packages/spec/src/kernel/execution-context.zod.ts and packages/spec/src/data/hook.zod.ts. Three regenerated content/docs/references/** pages, consistent with check:generated, which Lint & Repo Gates carries and which passed. The changeset. This matches the claim's surface (6932852581). No content/docs/releases/ change.
  • Fix, read in the diff.
    • One reader, provenanceMark (non-blank trimmed string, else absent), now serves all four provenance.performedBy* keys. The old performedByClientId read moved onto it unchanged.
    • performedBy = performedByClientId ?? performedByAgentId. The /mcp door and the in-product path each stamp only their own key, and ExecutionContext.performedBy refines to at least one of the two.
    • conversation_id and confirmation_id are read only when a performer is present, and are written only beside performed_by. A personal write still reaches no metadata (the guard is performedBy || impersonatedBy || signInStamp || scimConnectionId).
    • user_id and actor are not touched (ADR-0118 D1/D5).
    • At the head, audit-writers.ts holds exactly one performer read (:2206–2225) and one stamp (:2380–2387). No other record-write path in the file reads performedByClientId alone.
    • The other plugin-audit writers that read performedBy.clientId only are the three named in audit: action-invocation, data-export and dataset-query rows record only performedBy.clientId for in-product AI calls #34556. The spec describes now say so.
  • Ruling and names. The owner ruling on objectstack-ai/cloud#3826 (「3826 照建议(征询版)」) chose the existing performed_by / on_behalf_of pair and no new actor vocabulary, and the code follows it. The two new metadata keys conversation_id and confirmation_id are the seat's call per the area note: snake_case, beside performed_by / on_behalf_of / impersonated_by.
  • Changeset. @objectstack/plugin-audit patch (behaviour: new keys on audit rows) and @objectstack/spec patch (describe text ships). Clause-②: no and Metadata-protocol: none appear in both the body and the changeset; the accept sets are unchanged and no schema shape moves. Skills-docs: is not owed. I checked its prose sentence by sentence against the diff:
  • Tests. New describe, 4 cases, in the existing real-kernel harness: assembleExecutionContext, objectql buildProvenance, the shipped sys_audit_log on sqlite-wasm.
    • CONTROL: a human principal with no performedBy, and user_id / actor is the person on every row.
    • The confirmed AI write, the unconfirmed AI write, and the AI update after a personal create each pin the whole metadata object with toEqual, so a stray key fails. The personal create row's metadata is null.
    • Ablation (scripts/ablation-replace.mjs, ?? performedByAgentId removed): 3 failed / 10 passed, exactly the three AI rows; restored blob == HEAD.
    • No existing test changed.
  • Boundary. The cloud in-product AI path that stamps performedBy.agentId lives outside this repository. The test adds performedBy to a door-built envelope the way that path stamps it. The value travels through the real buildProvenance and the shipped writer, so the in-repo boundary is exercised end to end.
  • Gates (check-runs at 768136c0, filter=latest, 72 runs). 60 success, 12 path-filtered skipped, none red or pending. Required floor: Lint & Repo Gates success, TypeScript Type Check success. Test Core aggregate success, shards 1–8/8 success. Also success: Check Changeset, Dogfood Regression Gate (aggregate). Local dispatch-gates --ran: 119/119, 0 NOT-MEASURED. That is a local subset only; the check-runs are the reading I used.
  • Out of scope. Both report findings have a destination: the three non-record writers and content/docs/automation/hook-bodies.mdx:120 are enumerated on audit: action-invocation, data-export and dataset-query rows record only performedBy.clientId for in-product AI calls #34556.

L2 owed: yes, at CONTRACT_REVIEW_TIER. packages/spec/src/** (non-test) describes are touched. At this reading there is a claim (6934565857, l2-review#4, head 768136c0) and no record yet. With no same-form PASS at this head, the dispatching area adds needs:contract-review to the PR with this ACCEPT. The performed_by two-namespace point is the review's to judge.

Landing tier. node scripts/pm/check-governed-merges.mjs --pr 34547 reads: "0 of 8 path(s) hit the register … ✅ NOT governed — ordinary queue landing applies"; 276 changed lines ≤ 3000. The area lands it through the ordinary queue once the L2 PASS is recorded on this same head and every check is green.

@objectstack-fleet objectstack-fleet Bot added the needs:contract-review Marker only — PR awaits its at-tier Contract review PASS; no check reads it, the record decides label Nov 17, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 768136c0ef3a8d15683477fed1f62bb2b4c8b72f
Local-runs: none
Scope: packages/spec/src/data/hook.zod.ts, packages/spec/src/kernel/execution-context.zod.ts + packages/plugins/plugin-audit/src/audit-writers.ts

① Derived judgments

Inputs read: card #33694 (body and all 5 comments), PR #34547 (body, 8-file list, net diff against merge-base 0c7869c, comments), and the 72 check-runs on this head: every one is completed, success or skipped by path filter, none red and none pending.

  • Accept set of ExecutionContextSchema.performedBy and HookContextSchema.provenance: unchanged. The diff edits describe strings and JSDoc only; no key, type, refine or optionality moves. Right.
  • Published surface of @objectstack/spec: four describe strings change (performedBy, provenance.performedByAgentId, performedByConversationId, performedByConfirmationId), and through them content/docs/references/data/hook.mdx, data/data-engine.mdx (12 rows) and kernel/execution-context.mdx. The generated rows carry the new describe text verbatim; no stale "does not record them yet" sentence is left anywhere in the head tree. Right.
  • Public behaviour of @objectstack/plugin-audit: a record-write sys_audit_log row whose provenance carries performedByAgentId now gets metadata.performed_by (the agent) and on_behalf_of (the person), plus conversation_id and confirmation_id when stamped. Additive metadata keys; user_id and actor do not move; a row with no performer is byte-identical to before (the metadata guard is the same disjunction with performedBy in place of performedByClientId, and performedBy equals performedByClientId whenever no agent id is present). Right.
  • The OAuth client path: provenanceMark is the same non-blank-string-trimmed read the inline expression made; an OAuth client row is unchanged unless its envelope also carried a conversation or confirmation id, which no producer in the tree sets (tool-call-interceptor.ts:116 freezes the client id alone). Right.
  • metadata.performed_by on the record-write row now holds two id kinds (a sys_oauth_application id, or an in-product agent name). This is what the owner ruling on cloud#3826, as quoted on the card, chose ("using the existing performed_by / on_behalf_of columns ... Do not add a new actor vocabulary"). Right as ruled; how the contract tells a reader about it is S1 under ④.

② Semver level

Changeset .changeset/33694-audit-in-product-ai-performer.md: @objectstack/plugin-audit patch, @objectstack/spec patch. Both packages the diff moves are named and no other released package is moved. Metadata-protocol: none is right (nothing a metadata author can write changes), and none takes patch. Clause-②: no is right: no accept set changes, and the line is present and identical in the PR body and the changeset. Check Changeset is green on this head.

③ Boundary flags

  • Dev flag and open_questions 1 (two id namespaces in performed_by; accept as ruled, or ask for a discriminator): answered. Accept the shared key as ruled (option A); no new key and no decision card is needed. But option A's own premise, "a reader tells the in-product row by conversation_id when stamped", is written nowhere in the contract and is not guaranteed by it. That is S1 below, fixable in describe text.
  • open_questions 2 (key names conversation_id / confirmation_id): answered, option A. Snake case beside performed_by, on_behalf_of, impersonated_by; the names mirror the contract fields; the seat approved them in PR comment 6934548662.
  • Out-of-scope finding (action-invocation, data-export and dataset-query writers read performedBy.clientId only): confirmed in the head tree (action-invocation-audit.ts:159, data-export-audit.ts:317, dataset-query-audit.ts:205). The new describes state this limit truthfully, and the PR body names audit: action-invocation, data-export and dataset-query rows record only performedBy.clientId for in-product AI calls #34556 as its carrier. Accepted as a follow-up.
  • Out-of-scope finding (content/docs/automation/hook-bodies.mdx:120 lists performedByClientId only): outside the diff, same carrier. Accepted as a follow-up.
  • ADR bookkeeping: ADR-0090 D10 rule 4 on the head tree still reads "every write by an agent principal" and "a caller of any other kind ... the missing performed_by is itself the record that the principal acted for itself", while this writer now records performed_by on a human principal's row. The spec JSDoc already names the ADR note as the ruling's bookkeeping and the PR body names carrier docs/adr: ADR-0090 D10 rule 4, ADR-0151 "Leaves unchanged" and the 2026-09-20 one-key note still describe ExecutionContext.performedBy as the OAuth client only; #33786 adds the in-product AI performer #34057. Not this PR's file surface; noted so the carrier is not lost.
  • SQL push-down: the diff adds no query, no id materialisation and no in-app join. Nothing to flag.

④ Design judgment

packages/spec/src/kernel/execution-context.zod.ts and packages/spec/src/data/hook.zod.ts, against the ruling as quoted on the card, ADR-0151 D5 on the head tree, and the first consumer (audit-writers.ts):

S1 (should-fix) — the contract does not tell a reader of sys_audit_log.metadata.performed_by how to tell an OAuth client id from an in-product agent name. The performedBy describe says the writer "records the performer (clientId, or agentId for the in-product AI) as sys_audit_log.metadata.performed_by", the performedByAgentId describe says it is recorded "as performed_by beside on_behalf_of" exactly like the client id, and the three generated pages repeat both; none says how the two kinds are distinguished on the row. Three things make this more than wording:

  1. ADR-0151 D5 reason 2, accepted on main, refuses a second id kind in this key because it "gives one key two id namespaces, which a reader cannot tell apart". The ruling overrides the refusal for the in-product agent, but the stated harm stays unanswered in the text.
  2. The same JSDoc in execution-context.zod.ts still opens with "each naming its performer in its own key so one key never holds two id namespaces" (true of the envelope), and a few paragraphs later now says both keys land in one audit key, with no sentence joining the two.
  3. The only tell the dev names, conversation_id, is not a discriminator the contract backs: conversationId is optional in the schema, so an in-product row without it has exactly the shape of an OAuth client row; and the writer keys conversation_id / confirmation_id on any performer, so it would also write them beside a client id.
    The card's purpose is that the ledger answers "the AI changed this for this person in this conversation"; a row a reader cannot classify does not answer it. Fix on the describe face, no new key: state in the performedBy describe and JSDoc, and in the performedByAgentId describe, that the key holds either kind and how a reader resolves it (for example: a value that resolves as a registered sys_oauth_application id is the OAuth client, any other value is an in-product agent name; conversation_id and confirmation_id are written by the in-product path only), then regenerate. If the sentence names conversation_id / confirmation_id as in-product only, the writer must make it true by keying the two on the agent being the recorded performer (see N1). The fix moves the head and earns a delta review.

packages/plugins/plugin-audit/src/audit-writers.ts, sentence by sentence against the describes:

  • "records the performer (clientId, or agentId for the in-product AI) as performed_by beside on_behalf_of": agrees (performedByClientId ?? performedByAgentId, on_behalf_of: userId ?? null, and userId is the person on the in-product path).
  • "with conversationId as metadata.conversation_id and confirmationId as metadata.confirmation_id when set", and "beside performed_by": agrees; both are read only when a performer is recorded, and each key is spread only when non-blank.
  • "the action-invocation, data-export and dataset-query rows record clientId only": agrees with the three writers in the head tree; no other writer in packages/ sets performed_by.
  • "It does not move actor": agrees; the diff touches neither actor nor user_id, and the CONTROL test pins both to the person on all four rows.
  • "Absent on every write the person made themselves": agrees; the person's own create row keeps a null metadata, pinned by the fourth new test.
  • The provenance chain (buildProvenance in engine-execution-plumbing.ts) already copies all four keys on the head tree, so the writer's reads are reachable; read, not reviewed.

N1 (nit) — when one envelope carries both clientId and agentId (the schema's refine permits it: "at least one of"), the writer records the client in performed_by, drops the agent name silently, and still writes the agent's conversation_id / confirmation_id beside the client id. The describes do not state this precedence; only a code comment does. No producer in the tree sets both, so it is unreachable today. Left as an accepted deviation unless the S1 fix touches the same lines, in which case gating the two keys on the agent being the recorded performer closes both.

No must-fix. One should-fix (S1) is open on this head; landing waits on its fix and the delta record.

Implemented-by: claude/project-thread-j2xdku
Reviewed-by: session_01ADHkmP44onN8RMzsPMqjRq

VERDICT: PASS

…e the in-product agent, and state how a reader tells the two performed_by kinds apart

Claude-Session: https://claude.ai/code/session_01ADHkmSQnLEs6vGofJXcguE
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmSYVw1sqCsaHSJS9JC

Final head for L1 and contract review, patch round 2 · 2026-11-17T02:17Z
Final head: 8cc21923d17bc4def8f92b936a87a51091d40090 (card #33694, area o2-B), replacing 768136c0. CI at this head: every check completed success or skipped by path filter (Build Core, Test Core 1–8/8 + aggregate, Test UI 1–16/16 + aggregate, Build & E2E UI, Live E2E UI, Type Check UI, TypeScript Type Check, Lint & Repo Gates, Spec property liveness, Check Changeset, Build Docs, PR-body guards, Governed Surface Queue Guard); none red.
This round answers the contract review's S1 and closes N1: the writer records conversation_id / confirmation_id only when the in-product agent is the recorded performer (never beside an OAuth client id; with both performers present the client is recorded and the agent's marks dropped), and the performedBy / provenance.performedBy* describes now state that performed_by holds either kind, told apart by whether the value matches a registered sys_oauth_application client_id. No key added. +2 test pins (15/15), ablation reds both. Owed again on this head: L1 (L1-a) and L2.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq

Contract-review-claim: session_01ADHkmP44onN8RMzsPMqjRq · head 8cc2192 · 2026-11-17T02:18Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmQtnGcx7hYEL11ptVs

席位核对

L1 delta (patch round 2): ACCEPT · PR #34547 · card #33694 · area o2-B · L1-a2 · 2026-11-17T02:19Z

Head-sha: 8cc21923d17bc4def8f92b936a87a51091d40090

Previous L1: ACCEPT 6934586781 at 768136c0. This record reads only the delta 768136c0..8cc21923.

What moved (read in git, not from the report)

  • 0f655efa: the fix (4 files, +66/−21).
  • 0b288d13: merge of origin/main. git show --remerge-diff is empty, so the merge is clean with no hand edits.
  • 8cc21923: regenerated content/docs/references/{data/data-engine,data/hook,kernel/execution-context}.mdx (+16/−16). These are table rows only, and each one mirrors the new describe text.

Delta checklist

  • Writer (audit-writers.ts): agentIsRecordedPerformer = !performedByClientId && performedByAgentId !== undefined. It now gates conversation_id and confirmation_id, which before were gated on any performedBy. performed_by is still clientId ?? agentId. provenanceMark already returns undefined for blank or non-string values, so !performedByClientId and ?? agree. This closes N1 and makes S1's "only beside the agent" sentence true.
  • Spec describes (execution-context.zod.ts JSDoc and .describe, hook.zod.ts JSDoc and the three performedBy* describes): each one says that performed_by holds either kind, that a value matching the client_id of a registered sys_oauth_application row is the OAuth client and any other value is an agent name, that the two marks appear only beside the agent and their absence does not mark a client row, and that a both-performers envelope is recorded as the client. I checked the resolution key against the producer: assemble-execution-context.ts:380 stamps clientId from the token's azp, which is the application's client_id column (sys-oauth-application.object.ts). So client_id is the right column to name. No key added, no shape change.
  • Tests: 2 new pins in agent-dual-attribution.integration.test.ts (client beside stray marks → pair only; both performers → client only, no marks). The ablation log 33694-ablation-r2.log reads Tests 2 failed | 13 passed (15) with the gate swapped back to performedBy !== undefined, then ok restored: blob == HEAD (cc64d3be6bc7). Both pins are live.
  • Changeset (.changeset/33694-audit-in-product-ai-performer.md, unchanged this round): re-read against the new behaviour. Its bullets list conversation_id and confirmation_id as the in-product AI's marks and say nothing about them riding beside a client, so they are still true.
  • PR body: first line Fixes #33694, the only closing keyword in the body. Round 2 is described under Spec describes and in the namespaces note.
  • CI on this head (check-runs, filter=latest, 72 runs): success=60, skipped=12, nothing red or pending.

Nit, not blocking (for the L2 delta to weigh)

The performedByClientId describe in hook.zod.ts, a line this round did not touch, still calls the value "a registered sys_oauth_application id". The new sentences beside it say client_id. These read as the same thing only to a reader who knows azp is the client_id. Not filed.

L2 and landing

  • L2 still owed on this head. This round changes packages/spec/src/** describes, so it is CONTRACT_REVIEW_TIER. The delta goes to the original reviewer, l2-review#4 (record 6934640918, S1 open at 768136c0). Keep needs:contract-review until a same-shape PASS at 8cc21923 with S1 closed is on file.
  • Landing tier (node scripts/pm/check-governed-merges.mjs --pr 34547): NOT governed — ordinary queue landing, 323 changed lines ≤ 3000. Once the L2 delta PASS is on file, the area lands it. No human approval is needed.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 8cc21923d17bc4def8f92b936a87a51091d40090
Local-runs: none
Scope: packages/spec/src/data/hook.zod.ts, packages/spec/src/kernel/execution-context.zod.ts + packages/plugins/plugin-audit/src/audit-writers.ts

① Derived judgments

Delta review (record 6934640918: PASS, should-fix S1, nit N1) of the change from head 768136c to this head. Inputs read: that record in full, PR #34547 (body, comments, final-head comment 6935915356), the lane's delta note (as an account, not as evidence), the two-head diff restricted to the PR's own files, the net diff against merge-base 7b3e955, audit-writers.ts whole at this head, cards #34556 and #34057, and the 72 check-runs on this head: all completed, 60 success and 12 skipped by path filter, none red and none pending.

  • What moved between the heads, by commit: 0f655ef touches four files (audit-writers.ts, its integration test, the two spec files); 8cc2192 touches the three generated pages; 0b288d1 is the merge of main. The changeset did not move.
  • audit-writers.ts shows +72/-54 between the heads, but only the performer block (about 29 lines) is this PR's. The rest (resolveLookupTitles taking the writer's api in place of api.sudo(), and the comments around it) arrived with the merge of main: the net diff against the merge-base does not contain it, so it is main's change and is not judged here.
  • Accept set of ExecutionContextSchema.performedBy and HookContextSchema.provenance: still unchanged. The delta edits four describe strings and two JSDoc blocks; no key, type, refine or optionality moves. Right.
  • Writer behaviour, delta: conversation_id and confirmation_id are now read only when agentIsRecordedPerformer holds (no client id, and an agent id present). performed_by, on_behalf_of, user_id, actor, the metadata guard and every other key are byte-identical to the previous head. The only rows whose content changes are ones no producer in the tree builds (a client id beside a conversation or confirmation id, or both performers); for those the two marks are now dropped. A person's own write still reaches no metadata. Right.
  • The action-invocation, data-export and dataset-query writers are untouched and still read performedBy.clientId only (action-invocation-audit.ts:159, data-export-audit.ts:317, dataset-query-audit.ts:205). Right, and the describes still say so.
  • Generated pages: the performedBy describe appears verbatim once in kernel/execution-context.mdx and in all 12 performedBy rows of data/data-engine.mdx; the three provenance describes appear verbatim in data/hook.mdx. No copy of the previous wording is left under content/ or packages/spec/src. Right.

② Semver level

Unchanged and still right. Changeset .changeset/33694-audit-in-product-ai-performer.md is byte-identical to the previous head: @objectstack/plugin-audit patch, @objectstack/spec patch. The delta adds no released package and no shape change, so patch stands for both. Clause-②: no and Metadata-protocol: none are present and identical in the PR body and the changeset, and both are still true: no accept set changes and nothing a metadata author can write changes. The changeset prose is still true of the head (its three bullets describe the in-product row, which is the only row that carries the two new keys); it does not restate the reader rule, and it does not need to. Check Changeset is green on this head.

③ Boundary flags

④ Design judgment

  • S1 (should-fix): closed.

What S1 asked for is on the head. The performedBy describe and JSDoc and the performedByAgentId describe now say that metadata.performed_by holds two id kinds and give a rule for telling them apart. The JSDoc opening now reads "no key of this envelope holds two id namespaces (the audit row's performed_by does hold both, by ruling; how its reader tells them apart is stated below)", which joins with the later paragraph and is true of the envelope. The text no longer leans on conversation_id as the tell: it says both marks are optional and "their absence does not mark a client row", which is the correct reading of an in-product row without a conversation id. The writer makes "only when the agent is the recorded performer" true (agentIsRecordedPerformer), and buildProvenance still copies all four keys, so the gate that decides is the writer's. The regenerated pages carry the new text verbatim. The residue is the truth of the rule itself over the life of a row, which is a different defect and is S2.

N1: closed.

The two marks are keyed on the agent being the recorded performer. The precedence is stated in the contract in three places (performedBy describe: "An envelope carrying both performers is recorded as the client"; its JSDoc; performedByAgentId describe: "when performedByClientId is also present the row records the client instead") and is pinned by the second new test.

S2 (should-fix) — the stated rule misclassifies a row once its OAuth application is deleted.
The describes say: "a value matching the client_id of a registered sys_oauth_application row is the OAuth client, any other value is an in-product agent name". The first half is true. The second half is true only while the application row exists. sys_oauth_application rows are permanently deletable on this head: the delete_oauth_application action (packages/platform-objects/src/identity/sys-oauth-application.object.ts, target /api/v1/auth/oauth2/delete-client, "This cannot be undone") removes the row, and the audit row keeps its performed_by. From then on that client's rows match no registered application, and the contract tells the reader they name an in-product agent. Nothing else on the row corrects it: user_id, actor and on_behalf_of are the person on both kinds, the row records no principal kind, and the text itself says the absence of conversation_id proves nothing. So the classification is not always possible with the published rule, and the case where it breaks (an administrator removes a client and then reads what it did) is one an audit ledger is read for. Two smaller gaps in the same sentence: nothing in the contract keeps an agent name and a client id from being the same string, and the neighbouring performedByClientId describe calls the value "a registered sys_oauth_application id" while the rule says client_id (two different columns; client_id is the right one).
Fix on the describe face, no new key: scope the rule to what holds. For example: a value matching the client_id of a sys_oauth_application row is the OAuth client; a row carrying conversation_id or confirmation_id names the in-product agent; a value that matches no application row and carries neither mark is an in-product agent name or the id of an application that has since been deleted, and the row alone does not say which. Then regenerate. If the owner wants every row classifiable for good, that needs a kind mark on the row, which is a ruling (the cloud#3826 ruling chose the shared key) and belongs on a decision card, not in this PR.

packages/plugins/plugin-audit/src/audit-writers.ts, read whole at this head, sentence by sentence against the describes:

  • "Only when the agent is the recorded performer does the row also carry conversationId ... and confirmationId ... (each when set)": agrees. Both reads sit behind agentIsRecordedPerformer, and each key is spread only when non-blank.
  • "a client row never carries them": agrees, and pinned by the first new test.
  • "An envelope carrying both performers is recorded as the client" and the JSDoc's "drops the agent with its two marks": agrees (performedByClientId ?? performedByAgentId, and the gate is false when a client id is present), and pinned by the second new test.
  • "records the performer ... beside on_behalf_of", "It does not move actor", "Absent on every write the person made themselves", "the action-invocation, data-export and dataset-query rows record clientId only": unchanged since the previous head and still agree. No row kind records anything different beyond the two marks' gate.

The two new pins (agent-dual-attribution.integration.test.ts): each asserts the whole metadata object with toEqual, so a stray conversation_id or confirmation_id reds it; they pin "a client row never carries them" and the both-performers precedence. The two envelopes are built by hand and the test comment says so; no producer builds them, which is the honest framing. The delta removes no line from the test file, so no earlier assertion is weakened. Neither pin touches S2: no test resolves a performed_by value against sys_oauth_application, and none is needed for a describe-only fix.

N2 (nit) — in audit-writers.ts the new conversation_id / confirmation_id constants and provenanceMark sit between the JSDoc "Action name produced from a HookContext.event string" and actionFor, the function that comment documents, so the comment now heads the wrong declaration. Present since the first round; move the block above the comment whenever the file is next touched.

No must-fix. S2 is open on this head; landing waits on its fix and a delta record.

Implemented-by: claude/project-thread-j2xdku
Reviewed-by: session_01ADHkmP44onN8RMzsPMqjRq

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmSYVw1sqCsaHSJS9JC

Final head for L1 and contract review, patch round 3 · 2026-11-17T03:42Z
Final head: 24233e955c33ee77052d41ad1e7acdadc37f2368 (card #33694, area o2-B), replacing 8cc21923. CI at this head: every check completed success or skipped by path filter (Build Core, Test Core 1–8/8 + aggregate, Test UI 1–16/16 + aggregate, Build & E2E UI, Live E2E UI, Type Check UI, TypeScript Type Check, Lint & Repo Gates, Spec property liveness, Check Changeset, Build Docs, PR-body guards, Governed Surface Queue Guard); none red.
This round answers the contract review's S2 (6936045381) and N2, describe and JSDoc only, no key added and no behaviour change: the performed_by rule now states only what holds (a value matching a live sys_oauth_application client_id is the OAuth client; a row carrying conversation_id or confirmation_id is the in-product agent; a value meeting neither may be an agent name or the client id of a deleted application, and one row alone cannot tell; the contract does not guarantee an agent name differs from a client id). The clientId / performedByClientId describes now name the client_id column, not the row id. N2: the constant block moved above actionFor's JSDoc. Reference pages regenerated.
Owed on this head: L1 (L1-a) and L2. This PR changes packages/spec/src, so after both sit on this head it goes to the seat for the approvers; it stays a draft and is not armed by the area.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq

Contract-review-claim: session_01ADHkmP44onN8RMzsPMqjRq · head 24233e9 · 2026-11-17T03:43Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmQtnGcx7hYEL11ptVs

席位核对

L1 delta (patch round 3): ACCEPT · PR #34547 · card #33694 · area o2-B · L1-a2 · 2026-11-17T03:43Z

Head-sha: 24233e955c33ee77052d41ad1e7acdadc37f2368

Previous L1: delta ACCEPT 6935956323 at 8cc21923. This record reads only 8cc21923..24233e95. The final-head comment is 6937522222.

What moved (read in git; no main merge this round)

  • 97c95dd8, in execution-context.zod.ts, hook.zod.ts and audit-writers.ts:
    • The performedBy JSDoc and describe drop "any other value is an in-product agent name". They now say: a client_id matching an existing sys_oauth_application row is an OAuth client; a row carrying conversation_id or confirmation_id names an in-product agent; a row meeting neither may be either (an agent, or a deleted application's client), and the row alone cannot tell. The performedByAgentId describe carries the same sentences, and the hook.zod.ts provenance JSDoc now points to ExecutionContext.performedBy instead of restating the rule.
    • clientId (JSDoc and describe) and performedByClientId now say "the client_id of a registered sys_oauth_application", and the JSDoc adds "(not that row's id)". That closes the nit in my last record.
    • In audit-writers.ts, the [#33694] constants and provenanceMark block moved above actionFor's JSDoc. It is a pure move: the 8 removed lines come back word for word above actionFor (N2).
  • 24233e95: regenerated data/data-engine.mdx, data/hook.mdx and kernel/execution-context.mdx (+16/−16). These are table rows only, and they carry the new describe text.
  • No key, no shape, no behaviour change, so no ablation is owed. The writer sentences this round keeps (marks only beside the agent; both performers → client) still match agentIsRecordedPerformer as read last round.

Checklist

  • L2 S2 (6936045381): the fix follows the reviewer's own suggested wording and states only what holds. Answered. N2 is answered too.
  • Prose faces: I read each new sentence against audit-writers.ts at this head, and they agree. The changeset is unchanged this round and still true: it describes the marks and the two id kinds, not a classification rule.
  • Gates: 119 derived, 119 run, 0 NOT-MEASURED (33694-gates-ran-r3.txt). spec execution-context + hook: 146 passed. plugin-audit: 1676 passed.
  • CI on this head (check-runs, filter=latest, 72 runs): success=60, skipped=12, nothing red or pending.

Nit for the L2 delta to weigh (not blocking, not filed)

The new text says "a value matching the client_id of an existing sys_oauth_application row is an OAuth client", and two sentences later says "nor does the contract keep an agent name and a client_id from being the same string". Read together, the first rule holds only when no agent shares that string. The text does not say which reading wins when both rules apply (a matching value on a row that also carries conversation_id). The writer rule implies the marks win, because the marks are only ever written beside the agent. The L2 delta can decide whether that needs one clause.

L2 and landing

  • L2 delta owed at this head (CONTRACT_REVIEW_TIER, l2-review#4, S2 open at 8cc21923). Keep needs:contract-review until a same-shape PASS at 24233e95 is on file.
  • Landing tier, a correction to the area's note. node scripts/pm/check-governed-merges.mjs --pr 34547 reads ✅ NOT governed — ordinary queue landing, 339 changed lines ≤ 3000. packages/spec/src/** makes this PR owe a CONTRACT_REVIEW_TIER L2. It does not make it Tier H, because whether a human approval is needed is read from this tool alone. Once the L2 PASS is on file at this head, the area lands it, and no human approval is needed.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmQtnGcx7hYEL11ptVs

席位核对 · correction to 6937556832

Head-sha: 24233e955c33ee77052d41ad1e7acdadc37f2368 · 2026-11-17T03:44Z

Retracted: the Landing section of 6937556832, which said "the area lands it, no human approval is needed".

Corrected: this PR touches packages/spec/src/** outside tests (hook.zod.ts and execution-context.zod.ts). Under the seat's rule of 2026-11-17 03:21Z (spec surface always goes to a human, following pm-dispatch 「受管/spec 面欠 ①–④」 and the maintainer's 11-14 「契约(spec、收窄)留给维护者」), it is spec surface, handed to the seat as Tier H. That holds even though check-governed-merges.mjs reads NOT governed. Once L1 ACCEPT and the L2 PASS are both on file at this head, the area reports the PR to the seat for ①–④. ⛔ The area does not land it, mark it ready or arm auto-merge.

The L1 verdict itself (ACCEPT) is unchanged.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 24233e955c33ee77052d41ad1e7acdadc37f2368
Local-runs: none
Scope: packages/spec/src/data/hook.zod.ts, packages/spec/src/kernel/execution-context.zod.ts + packages/plugins/plugin-audit/src/audit-writers.ts

① Derived judgments

Delta review (record 6936045381: PASS on head 8cc2192, S1 and N1 closed, S2 and N2 open) of the change from head 8cc2192 to this head. Inputs read: that record and the first record 6934640918 in full, every PR #34547 comment (including final-head comment 6937522222 and the L1 delta record 6937556832), the area's round-3 note (as an account, not as evidence), the two-head diff restricted to the PR's own files, the two spec files, the three generated pages and audit-writers.ts at this head, sys-oauth-application.object.ts at this head, and the 72 check-runs on this head.

  • What moved between the heads: two commits, 97c95dd (the two spec files and audit-writers.ts) and 24233e9 (the three generated pages). Six files, +47/-45. No merge of main in this delta. The changeset and the integration test are byte-identical to the previous head.
  • audit-writers.ts: +8/-8, a pure move. The eight-line JSDoc "Action name produced from a HookContext.event string" leaves its place above the [#33694] constants and returns word for word directly above actionFor. No statement, constant, signature or condition moves; the performer block (performedByClientId ?? performedByAgentId, agentIsRecordedPerformer) is untouched. Writer behaviour is identical to the previous head. Right.
  • execution-context.zod.ts: the performedBy JSDoc, the clientId JSDoc, the clientId describe string and the performedBy describe string change. The z.object keys, z.string().optional() on each, the requiredOneOf(['clientId', 'agentId']) refine with its message, and the outer .optional() are unchanged. Right.
  • hook.zod.ts: one bullet of the provenance JSDoc and the performedByClientId and performedByAgentId describe strings change. No key, type or optionality moves. Right.
  • Accept set of ExecutionContextSchema.performedBy and HookContextSchema.provenance: unchanged, as on both earlier heads.
  • Generated pages: the new performedBy describe appears verbatim in kernel/execution-context.mdx and in all 12 performedBy rows of data/data-engine.mdx; the new clientId describe in kernel/execution-context.mdx; the new performedByClientId and performedByAgentId describes verbatim in data/hook.mdx. A search of the whole head tree for "any other value is an in-product" and for "sys_oauth_application id" returns nothing, so no copy of the previous wording is left. Right.
  • Check-runs on this head: 72, all completed; 60 success, 12 skipped by path filter, none failed and none pending. Lint and Repo Gates, TypeScript Type Check, Test Core (aggregate and shards 1 to 8), Build Core, Build Docs, Spec property liveness and Check Changeset are success.

② Semver level

Unchanged and still right. The changeset is byte-identical: @objectstack/plugin-audit patch, @objectstack/spec patch. The delta changes describe text, JSDoc and comment placement only, so patch stands for both and no other released package is moved. Clause-②: no and Metadata-protocol: none remain true: no accept set changes and nothing a metadata author can write changes. The changeset prose does not restate the reader rule, so the rewording does not make any of its sentences false. Check Changeset is success on this head.

③ Boundary flags

  • Carriers audit: action-invocation, data-export and dataset-query rows record only performedBy.clientId for in-product AI calls #34556 (the three other writers, content/docs/automation/hook-bodies.mdx) and docs/adr: ADR-0090 D10 rule 4, ADR-0151 "Leaves unchanged" and the 2026-09-20 one-key note still describe ExecutionContext.performedBy as the OAuth client only; #33786 adds the in-product AI performer #34057 (ADR-0090 D10 rule 4 wording): not re-read this round; this delta touches nothing they carry, and the describes still say the action-invocation, data-export and dataset-query rows record clientId only.
  • No row kind mark was added, and that is right for this PR. The owner ruling on cloud#3826 chose the shared performed_by / on_behalf_of pair with no new actor vocabulary; a per-row kind mark is new vocabulary on the row and would need a ruling, not a patch round. The contract as now written is honest about what that choice leaves: it names the rows a reader cannot classify from the row alone and does not claim more than the writer guarantees.
  • Suggestion to the seat, not a finding on this PR: raise a decision card for the owner asking whether every performed_by row must stay classifiable for good. The unclassifiable set is exactly the rows of a since-deleted OAuth application plus in-product rows written with no conversation and no confirmation id; "an administrator deletes a client and then reads what it did" is a case an audit ledger is read for. The options are a kind mark on the row, a rule that the in-product path always stamps a conversation id, or accepting the residual as documented.
  • SQL push-down: the delta adds no query and no in-app join.

④ Design judgment

S2: closed

The sentence that was false is gone from every place it stood ("any other value is an in-product agent name", and "their absence does not mark a client row" with it). Read against the tree at this head, the replacement sentences:

  • "a value that matches the client_id of an existing sys_oauth_application row is an OAuth client": scoped to an existing row, so deleting the application no longer turns it false. existing is the right word; delete_oauth_application (sys-oauth-application.object.ts, target /api/v1/auth/oauth2/delete-client, "This cannot be undone") removes the row. True except in the equal-string case, which is N3.
  • "a row carrying conversation_id or confirmation_id names an in-product agent": true over the whole life of a row, with or without an application row and whatever the value equals. The writer reads both marks only behind agentIsRecordedPerformer (no client id, an agent id present), and the two round-2 pins hold it.
  • "A row meeting neither may name an in-product agent or an OAuth client whose application has since been deleted (its rows keep the client_id), and the row alone cannot tell which": true, and it is the plain statement of the unclassifiable rows that S2 asked for. It appears in the performedBy JSDoc and describe and in the performedByAgentId describe.
  • "Nor does the contract keep an agent name and a client_id from being the same string": true. client_id is unique among applications only, and the agent name is constrained by its own pattern only; nothing joins the two. Stated in all three places.
  • Column naming: clientId (JSDoc and describe) and performedByClientId (describe) now read "the client_id of a registered sys_oauth_application", and the JSDoc adds "(not that row's id)". "Registered" is right there, since it describes the application at the time the token was issued. No description of the value as an application id is left in the spec files or the generated pages.
  • The hook.zod.ts provenance bullet no longer restates the rule and points to ExecutionContext.performedBy; one home for the rule, with the performedByAgentId describe carrying the same sentences for the generated page. The pointer is true.
  • Writer sentences kept from the previous head ("only when the in-product agent is the recorded performer", "a row naming an OAuth client never carries either", both performers recorded as the client with the agent and its two marks dropped): the writer is unchanged, so they still agree.

N2: closed

The JSDoc "Action name produced from a HookContext.event string" heads actionFor again; the [#33694] constants and provenanceMark sit above it under their own comments.

N3 (nit) — the text does not say which reading wins when both tells apply. Raised by the L1 delta record 6937556832 and judged here on the tree. If an agent name equals the client_id of an existing application, a row whose performed_by is that string and which carries conversation_id or confirmation_id meets both sentences, and they answer differently; a row with that string and no mark is called an OAuth client though the agent may have written it. So the first sentence holds only where no agent shares the string. This stays a nit and does not reopen S2 because the text itself says, two sentences on, that the contract does not keep the two strings apart, so a reader is told the first tell is not a guarantee; the precedence for a marked row is derivable from the neighbouring sentence "a row naming an OAuth client never carries either"; and the case needs an agent named with the exact string of a registered application's client_id, which no producer in the tree arranges. One clause would remove the derivation, for example: "where both apply the mark decides; a matching value with no mark is the client unless an agent shares that string". Describe face only; take it whenever these describes are next touched, with a regeneration. It does not hold this head.

No must-fix, no should-fix.

Implemented-by: claude/project-thread-j2xdku
Reviewed-by: session_01ADHkmP44onN8RMzsPMqjRq

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmQ2SN4K183oqAvUajA

Seat record · 2026-11-17T03:49Z · Head-sha: 24233e9

The PR body's 速读 says "需要你做的:无,席位落地". This record replaces that line. The PR changes packages/spec/src (the describe text in kernel/execution-context.zod.ts and data/hook.zod.ts), and every spec face goes to a human approver even when the register finds no governed path.

维护者速读

  • 改了什么:产品内的 AI 替某人改记录时,审计日志那一行现在写明是哪个 AI(performed_by)、替谁(on_behalf_of)、在哪次对话(conversation_id)、经过哪次确认(confirmation_id,没有确认就不写)。
  • 为什么改:以前 AI 改的数据在审计日志里和本人手改一模一样,回答不了「这条是 AI 在哪次对话里替张三改的」。契约字段早已在 main 上(spec(kernel/data): let a server-constructed in-product AI path set ExecutionContext.performedBy / HookContext.provenance (AI on behalf of a person, conversation id, confirmation id), and amend the ADR-0090 D10 rule 4 "/mcp OAuth door only" reading #33786),只差审计写入器去读。
  • 风险与回滚:只加 metadata 键,user_id / actor 仍是本人,人手改的行不变。spec 那边只改了两处说明文字,没有改形状。回滚即 revert,历史行不受影响。
  • 先看:packages/plugins/plugin-audit/src/audit-writers.ts(performedBy 取值和 metadata 拼装)、packages/spec/src/kernel/execution-context.zod.ts 改过的说明句。
  • 两分钟验证:pnpm --filter @objectstack/plugin-audit exec vitest run src/agent-dual-attribution.integration.test.ts,预期 15 条全过,其中 6 条是本卡新加的。
  • 需要你做的:审读并批准。契约审核 PASS 是 6937613475,Head-sha 24233e955c33ee77052d41ad1e7acdadc37f2368。

席位意见:同意合并。契约说明写得如实:它点名了单看一行分不清来源的几种行(已删除的 OAuth 应用写的行,以及产品内既无对话号也无确认号的行),没有夸大写入器的保证。契约审核建议问一句「是否要求每一行永久可分」,席位这次不立决策卡:目前没有实测的拉动,契约已经如实写明残余。真有管理员要追查已删除应用写的行时再提。

席位核对

  1. 形态:8 个文件,+298/−41,Fixes #33694;Clause-②: no,Metadata-protocol: none。
  2. 前提实测:契约字段在 main 上(spec(kernel/data): let a server-constructed in-product AI path set ExecutionContext.performedBy / HookContext.provenance (AI on behalf of a person, conversation id, confirmation id), and amend the ADR-0090 D10 rule 4 "/mcp OAuth door only" reading #33786);dev 的集成测试在本 head 跑过,15 条全过。
  3. 门禁 check-runs:head 24233e95 上 72 条,60 绿、12 跳、0 红;mergeable_state clean(席位 03:52Z 实读)。
  4. 接受的偏差:N3(nit,同一个字符串既是 agent 名又是现存 OAuth client_id 时,哪种判读优先)。契约审核判它不挡本 head,下次改这两处说明时再补一句。L1-a ACCEPT 6937556832(更正 6937581995)。
  5. 范围外去向:audit: action-invocation, data-export and dataset-query rows record only performedBy.clientId for in-product AI calls #34556 等本 PR 合并后归区 o2-B。「每行永久可分」的问题见上面的席位意见,暂不立卡。
  6. 落地条款:授权批准在案后,席位翻 ready,经合并队列落地;合并后区 o2-B 清 sys_audit_log: mark in-product AI writes (AI on behalf of a person, conversation id, confirmation id) #33694 上的 pm 状态。

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmQ2SN4K183oqAvUajA

Tier H hand-off, written at 2026-11-17T03:50Z. This is a spec face (describe text), so it goes to a human approver. The seat record is pinned to head 24233e95. pm:awaiting-merge is added in this stroke, and the reviewers are requested in the same round.

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 17, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 17, 2026 04:29
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit bb3c163 Nov 17, 2026
78 checks passed
@os-zhuang
os-zhuang deleted the claude/project-thread-j2xdku branch November 17, 2026 04:57
@objectstack-fleet objectstack-fleet Bot removed the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 17, 2026
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 needs:contract-review Marker only — PR awaits its at-tier Contract review PASS; no check reads it, the record decides protocol:data size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sys_audit_log: mark in-product AI writes (AI on behalf of a person, conversation id, confirmation id)

3 participants