Repository navigation
fix(plugin-audit): mark in-product AI calls on the action-invocation, data-export and dataset-query audit rows - #34679
Conversation
… data-export and dataset-query rows The three writers read only performedBy.clientId. They now apply the record-write writer's performer rule, extracted into one exported helper (auditPerformerMetadata) that all four writers call. Claude-Session: https://claude.ai/code/session_01ADHkmSYVw1sqCsaHSJS9JC Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmSYVw1sqCsaHSJS9JC Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmSYVw1sqCsaHSJS9JC Co-authored-by: Claude <noreply@anthropic.com>
…dit-ai-marks-three-rows
📓 Docs Drift CheckThis PR changes 2 package(s): 11 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 3 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 176 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 fee3637eae384c46a3c5a48284202ba94b12a759 && git checkout fee3637eae384c46a3c5a48284202ba94b12a759
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin b1da9f55db0f4028cd6720fae7e80c6574e7dc67 f62fa7ad00016422c95882f00cbe70eb6be421ec && git checkout -B drift-repro b1da9f55db0f4028cd6720fae7e80c6574e7dc67 && git merge --no-ff f62fa7ad00016422c95882f00cbe70eb6be421ec
node scripts/docs-audit/affected-docs.mjs --json b1da9f55db0f4028cd6720fae7e80c6574e7dc67
|
…dit-ai-marks-three-rows
…marks by the same rule Prose only: the ExecutionContext.performedBy describe and JSDoc no longer say the action-invocation, data-export and dataset-query rows record clientId only, and the reader rule (here and in the HookContext performedByAgentId describe) says which tell wins where both apply. No key, type or refine moves. Claude-Session: https://claude.ai/code/session_01ADHkmSYVw1sqCsaHSJS9JC Co-authored-by: Claude <noreply@anthropic.com>
…escribes Claude-Session: https://claude.ai/code/session_01ADHkmSYVw1sqCsaHSJS9JC Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmSYVw1sqCsaHSJS9JC Co-authored-by: Claude <noreply@anthropic.com>
…dit-ai-marks-three-rows
|
repo:objectstack#2 · os-steve · session_01ADHkmSYVw1sqCsaHSJS9JC Final head for L1 and contract review · 2026-11-17T07:28Z |
|
l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq Contract-review-claim: session_01ADHkmP44onN8RMzsPMqjRq · head 5f005fb · 2026-11-17T07:29Z |
|
repo:objectstack#2 · os-steve · session_01ADHkmQtnGcx7hYEL11ptVs 席位核对L1 first review: REWORK (1 item, body only; the code, the pins and the spec prose are accepted) · PR #34679 · card #34556 · area o2-B · L1-a2 · 2026-11-17T07:31Z Head-sha: Final-head comment 6941684507; dev report 6940367044; claim amendment 6940394255. Checked, no problem
R1: the
|
…ce table The body runner already carries impersonatedBy across the sandbox boundary; the hook-bodies table named every other member but this one. Claude-Session: https://claude.ai/code/session_01ADHkmSYVw1sqCsaHSJS9JC Co-authored-by: Claude <noreply@anthropic.com>
|
l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq Contract reviewServed-tier: ① Derived judgmentsInputs read: card #34556 (body and all four comments: triage 6933961648, claim 6939213173, dev report 6940367044, claim amendment 6940394255), PR #34679 (body, file list, the net diff of 14 files against merge-base
② Semver levelRight. Changeset
③ Boundary flags
④ Design judgmentN3: closed Record 6937613475 asked for one clause saying which reading wins when both tells apply. The clause is on the head in all three places the reader rule is stated (
Tried to break it: an envelope with
Rule-level reading of the audit posture: the rule can record a performer only from the server-built envelope, the client keeps precedence by ruling, and a mark is omitted only when it was not stamped or when the recorded performer is a client. Nothing found that records a wrong performer or loses a stamped mark. No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#2 · os-steve · session_01ADHkmSYVw1sqCsaHSJS9JC Final head for L1 and contract review (delta) · 2026-11-17T08:11Z |
|
repo:objectstack#2 · os-steve · session_01ADHkmQtnGcx7hYEL11ptVs 席位核对L1 delta: ACCEPT · PR #34679 · card #34556 · area o2-B · L1-a2 · 2026-11-17T08:13Z Head-sha: This reads only What moved (read in git)
R1: route (b), the row added in this PR
Readings
L2 and landing
|
|
l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq Contract-review-claim: session_01ADHkmP44onN8RMzsPMqjRq · head f62fa7a · 2026-11-17T08:12Z |
|
l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq Contract reviewServed-tier: ① Derived judgmentsDelta record over 6941799864 (PASS on head
② Semver levelRight, unchanged. The delta adds a hand-written docs line under ③ Boundary flags
④ Design judgmentThe Scope files did not move, so the design judgment of 6941799864 on the two spec files and the four plugin-audit files carries whole. What is new is one table row, outside Scope and read here because it restates a published
The row is consistent in form with the three rows judged in the prior record's ③ and makes no claim the code does not keep. No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#2 · os-steve · session_01ADHkmQ2SN4K183oqAvUajA Seat record · 2026-11-17T08:16Z · Head-sha: f62fa7a 维护者速读
席位意见:同意合并。审计里看得出是 AI 代人做的、在哪次对话、经哪次确认,是产品内 AI 的基本问责;本 PR 只加标记、不改本人归属,spec 只改说明文字。 席位核对
|
Requested by Steve · project thread
Fixes #34556
Clause-②: no
Metadata-protocol: none
Spec surface: since round r2 this PR touches
packages/spec/src(describe and JSDoc prose only, no key, type or refine), so it owes an L2 contract review and the seat's Tier H step before it lands.维护者速读
performed_by)、替谁(on_behalf_of)、在哪次对话(conversation_id)、经哪次确认(confirmation_id,没确认就不写)。spec 里描述这件事的说明文字同步改正(只改文字,不改字段)。user_id/actor仍是本人;OAuth 客户端的行和本人亲手操作的行不变。四类行现在共用一个规则函数,记录写入行的行为不变(原有 15 条钉子测试全绿)。回滚即撤本 PR,历史行不受影响。packages/plugins/plugin-audit/src/audit-writers.ts(新的auditPerformerMetadata与记录写入处的调用)、packages/spec/src/kernel/execution-context.zod.ts(performedBy的 describe 与 JSDoc 改句)、三个写入器各自的一行接线与三个测试文件末尾新增的 describe。pnpm --filter @objectstack/plugin-audit exec vitest run src/action-invocation-audit.test.ts src/data-export-audit.test.ts src/dataset-query-audit.test.ts src/agent-dual-attribution.integration.test.ts,预期 4 个文件 62 条全绿,其中 9 条是本卡新用例。packages/spec/src的说明文字,契约复审(L2)通过后按席位的 Tier H 流程由你确认落地。What changes
sys_audit_logwriter. PR feat(plugin-audit): mark in-product AI writes on sys_audit_log rows (agent, conversation, confirmation) #34547 wrote the in-product AI rule inline in the record-write writer (installAuditWriters), readingHookContext.provenancethrough a private reader. This PR moves that rule, unchanged, into one exported function inaudit-writers.ts,auditPerformerMetadata(performer, onBehalfOf), which takes theExecutionContext.performedByshape (clientId,agentId,conversationId,confirmationId) and returns the metadata keys or nothing. The record-write writer now calls it with its fourprovenancemarks. The rule is the one feat(plugin-audit): mark in-product AI writes on sys_audit_log rows (agent, conversation, confirmation) #34547 settled:performed_byis the OAuth client, else the in-product agent;on_behalf_ofis the row's ownuser_idvalue;conversation_id/confirmation_idare written only when the in-product agent is the recorded performer, each only when stamped;action-invocation-audit.ts,data-export-audit.tsanddataset-query-audit.tsreadperformedBy.clientIdonly. Each now callsauditPerformerMetadata(ctx.performedBy, userId)in place of its own two-key block. All three writesys_audit_logand keepmetadataas one JSON text column, so no column or key is added. Their header comments now name the two marks.hook-bodies.mdx. Thectx.provenancetable listedperformedByClientIdonly. It now listsperformedByAgentId,performedByConversationId,performedByConfirmationIdandimpersonatedBy, which the hook-body sandbox already copies (packages/runtime/src/sandbox/body-runner.ts).performedByAgentIdis included because the other two are defined as set beside it.packages/spec/src/kernel/execution-context.zod.ts: theperformedBydescribe and JSDoc said "The action-invocation, data-export and dataset-query rows record clientId only", which this PR makes false. They now say those rows "record the performer and the two marks by the same rule". The reader rule there, and inpackages/spec/src/data/hook.zod.ts'sperformedByAgentIddescribe, also takes the L2 nit N3 from record 6937613475: "where both tells apply the mark decides, and a matching value with no mark is the client unless an agent shares that string". No key, type, refine or optionality moves.content/docs/references/**regenerated (gen:docs):kernel/execution-context.mdx,data/data-engine.mdx(12performedByrows),data/hook.mdx..changeset/34556-audit-ai-marks-three-rows.md:@objectstack/plugin-auditpatch,@objectstack/specpatch (describe text ships).auditPerformerMetadatais exported from the module, not from the package entry (src/index.tsis unchanged), so the published API surface does not change.Enumeration (from the card)
action-invocation-audit.test.ts› "[sys_audit_log: mark in-product AI writes (AI on behalf of a person, conversation id, confirmation id) #33694] an in-product AI call is marked on the action_invocation row by the CRUD mirror's rule" (the AI row is written and read back through a real ObjectQL engine).data-export-audit.test.ts› "[sys_audit_log: mark in-product AI writes (AI on behalf of a person, conversation id, confirmation id) #33694] an in-product AI export is marked on the export row by the CRUD mirror's rule".dataset-query-audit.test.ts› "[sys_audit_log: mark in-product AI writes (AI on behalf of a person, conversation id, confirmation id) #33694] an in-product AI query is marked on the dataset_query row by the CRUD mirror's rule".hook-bodies.mdx: thectx.provenancetable listsperformedByConversationIdandperformedByConfirmationId(andperformedByAgentId, and since L1 R1impersonatedBy) besideperformedByClientId. Docs only, no test.Tests
Each of the three describes has three cases:
performedBy: { agentId, conversationId, confirmationId }) recordsperformed_by= agent,on_behalf_of= person,conversation_id,confirmation_id;user_idstays the person.{ performed_by: client, on_behalf_of }and no marks.No existing test changed.
agent-dual-attribution.integration.test.ts(the record-write pins #34547 added) passes unchanged against the extracted function.Acceptance notes
hook.zod.tscarried no "clientId only" claim; it is touched only to carry N3 in the third place the reader rule is stated.ctx.provenancetable inhook-bodies.mdxnow also listsimpersonatedBy, which the sandbox copies (packages/runtime/src/sandbox/body-runner.ts), so every member it carries has a row. Commitf62fa7ad00, one docs line.claude/project-thread-l1nf08, which also editshook-bodies.mdx):git merge-tree --write-tree --name-only HEAD origin/claude/project-thread-l1nf08reportsAuto-merging content/docs/automation/hook-bodies.mdxwith no conflict in that file. The one textual conflict it reports,packages/spec/dropped-refinements.baseline.json, is between feat(spec, runtime, lint, core): a hook writes the sentences it declares in the organization's language (ctx.text) #34545 andmainand is not in this diff. The three-ref form in the dispatch (git merge-tree --write-tree origin/main HEAD BRANCH) is not valid syntax and exits 129, so the two-ref form was used. This is a local probe with the repo's merge driver registered, not GitHub's mergeability.Verification
Round r2, at head 5f005fb (after merging origin/main twice)
49dc838adb(spec prose: the two spec files),c5eafdb182(regenerated references),19d92fd27e(changeset), then the merge oforigin/mainat5f005fb26a.pnpm --filter @objectstack/spec buildunder the lock: exit 0.pnpm --filter @objectstack/spec gen:docs: exit 0, three reference pages changed (14 lines).pnpm --filter @objectstack/spec check:generated: "All 14 generated artifacts are up to date", exit 0. The first attempt reportedtest-typecheck-debt.jsonwith "tsc -p tsconfig.test.json failed without diagnostics": a JavaScript heap OOM under the 4096 MB default on this shared box, not staleness. It was re-run with--max-old-space-size=6144, and the later gate sweep at 4096 was green too.packages/spec/srcorcontent/docs/references.pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2 src/kernel/execution-context.test.ts src/data/hook.test.ts: Test Files 2 passed (2), Tests 146 passed (146).vitest run --maxWorkers=2gives Test Files 101 passed (101), Tests 1696 passed (1696); typecheck exit 0.turbo run build --concurrency=2 --filter=!@objectstack/docs): 119 of 119 tasks successful.dispatch-gates --commandsderived 119 commands at this head. All ran with stdin closed and the exit taken before any pipe; all exited 0.--ran: "119 derived famil(ies) accounted for — 119 run, 0 NOT-MEASURED".Round 1 readings below were taken at head
41a26f1134(after mergingorigin/maine5336512f). The plugin-audit code has not changed since.Build, tests, typecheck
pnpm --filter '@objectstack/plugin-audit^...' buildunder the verify lock: exit 0.pnpm --filter @objectstack/plugin-audit exec vitest run --maxWorkers=2 src/action-invocation-audit.test.ts src/data-export-audit.test.ts src/dataset-query-audit.test.ts src/agent-dual-attribution.integration.test.ts: Test Files 4 passed (4), Tests 62 passed (62).pnpm --filter @objectstack/plugin-audit exec vitest run --maxWorkers=2(whole package): Test Files 101 passed (101), Tests 1696 passed (1696).pnpm --filter @objectstack/plugin-audit typecheck: exit 0;check:test-typecheck: OK, 0 errors.Ablations (scripts/ablation-replace.mjs; tests import the writers from src)
Each writer's wiring
Object.assign(metadata, auditPerformerMetadata(ctx.performedBy, userId));replaced by the old client-only readingauditPerformerMetadata({ clientId: ctx.performedBy?.clientId }, userId). Anchor 1 → 0 each time; restored blob == HEAD andgit diff HEADempty each time.action-invocation-audit.ts→ its pin "an AI-performed call records the agent, the person, the conversation and the confirmation" FAILS: Tests 1 failed / 13 passed (14).data-export-audit.ts→ "an AI-performed export records …" FAILS: Tests 1 failed / 18 passed (19).dataset-query-audit.ts→ "an AI-performed query records …" FAILS: Tests 1 failed / 13 passed (14).The shared rule in
audit-writers.ts:agentIsRecordedPerformer = !performedByClientId && performedByAgentId !== undefinedreplaced byperformedBy !== undefined, run over the four files: Tests 5 failed / 57 passed (62). The three new CONTROL pins (client alone or beside an agent) fail, and so do #34547's two record-write pins ("never ride beside an OAuth client id", "an envelope naming both performers"). Restored blob == HEAD.Gates
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 102 commands for this diff. Each was run with stdin closed and its exit taken before any pipe.check:skill-examples,check:dual-build-cjs-loads,check:i18n. Afterturbo run build --concurrency=2 --filter=!@objectstack/docsunder the lock (exit 0), each re-ran with exit 0.dispatch-gates --ran: "102 derived famil(ies) accounted for — 102 run, 0 NOT-MEASURED". Exit 0.test:repo, and the dogfood battery. The title has no!and the claim has no(narrowing)arm.🤖 Generated with Claude Code
https://claude.ai/code/session_01ADHkmSYVw1sqCsaHSJS9JC