pluribus-context 0.3.33 → 0.3.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +7 -6
  3. package/docs/ai-pr-review-receipts.md +153 -0
  4. package/docs/canonical-output-receipts.md +107 -0
  5. package/docs/community-review-packet.md +11 -11
  6. package/docs/context-budget-receipts.md +22 -0
  7. package/docs/context-input-evidence.md +15 -0
  8. package/docs/dynamic-workflow-run-receipts.md +158 -0
  9. package/docs/install-plan-receipts.md +77 -0
  10. package/docs/mcp-tool-visibility-receipts.md +67 -0
  11. package/docs/review-primitive-gate.md +107 -0
  12. package/docs/skill-policy-receipts.md +87 -0
  13. package/docs/subagent-role-receipts.md +95 -0
  14. package/docs/temporal-context-receipts.md +123 -0
  15. package/examples/agent-skills/context-receipts/SKILL.md +21 -0
  16. package/examples/agent-skills/skill-policy-receipts/README.md +22 -0
  17. package/examples/agent-skills/skill-policy-receipts/SKILL.md +77 -0
  18. package/examples/ai-pr-review-receipts/.github/pull_request_template.md +31 -0
  19. package/examples/ai-pr-review-receipts/README.md +5 -0
  20. package/examples/canonical-output-receipts/canonical-output-receipt.json +55 -0
  21. package/examples/claude-code-review-hook/README.md +74 -0
  22. package/examples/claude-code-review-hook/check-review-receipt-hook.mjs +80 -0
  23. package/examples/claude-code-review-hook/sample-task-completed-event.json +6 -0
  24. package/examples/context-input-evidence/code-search-retrieval-otel-trace.json +879 -0
  25. package/examples/context-input-evidence/code-search-retrieval-receipt.ndjson +8 -0
  26. package/examples/context-input-evidence/convert-code-search-retrieval-log.mjs +280 -0
  27. package/examples/context-input-evidence/sample-code-search-retrieval-log.jsonl +5 -0
  28. package/examples/dynamic-workflow-run-receipts/README.md +18 -0
  29. package/examples/dynamic-workflow-run-receipts/workflow-run-receipt.json +112 -0
  30. package/examples/install-plan-receipts/README.md +34 -0
  31. package/examples/install-plan-receipts/agent-install-plan-receipt.json +56 -0
  32. package/examples/review-primitive-gate/README.md +19 -0
  33. package/examples/review-primitive-gate/check-review-receipt.mjs +100 -0
  34. package/examples/review-primitive-gate/fail-review-receipt.json +42 -0
  35. package/examples/review-primitive-gate/pass-review-receipt.json +54 -0
  36. package/examples/subagent-role-receipts/README.md +15 -0
  37. package/examples/subagent-role-receipts/agents.toml +36 -0
  38. package/examples/temporal-context-receipts/CURRENT_STATE.md +13 -0
  39. package/examples/temporal-context-receipts/specs/2025-checkout-rewrite.md +10 -0
  40. package/examples/temporal-context-receipts/specs/2026-checkout-risk-notes.md +10 -0
  41. package/examples/temporal-context-receipts/temporal-authority-receipt.json +27 -0
  42. package/package.json +1 -1
  43. package/src/utils/version.js +1 -1
@@ -0,0 +1,8 @@
1
+ {"trace_id":"02c8df97e575ea76a89acf4fe9194925","span_id":"9568b542931d5d73","name":"code.index.snapshot.used","time":"2026-05-26T14:00:01.000Z","attributes":{"session.id":"session-code-search-demo-001","gen_ai.conversation.id":"conv-code-search-demo-001","agent.name":"claude-code","code_search.index.snapshot_id_hash":"sha256:6a0d5bd7e10e","code_search.codebase.path_hash":"sha256:747ff961f5c565013d2b43aa6393ee4f328ed3d6a82f28fc4ca06b417c47ebfb","code_search.git.commit_hash":"sha256:87fe0690312cb4a86c9f9256ff9e1863118a67b44f286e3510c7816d430caae0","code_search.indexed_file_count_bucket":"over_1k","code_search.indexed_chunk_count_bucket":"over_1k","code_search.embedding.provider_hash":"sha256:15c5b8267d43","code_search.embedding.model_hash":"sha256:dbb48b3aa923","code_search.snapshot.status":"fresh","privacy.raw_codebase_path_recorded":false,"privacy.raw_embedding_config_recorded":false}}
2
+ {"trace_id":"02c8df97e575ea76a89acf4fe9194925","span_id":"9568b542931d5d73","name":"code.search.performed","time":"2026-05-26T14:00:03.000Z","attributes":{"session.id":"session-code-search-demo-001","gen_ai.conversation.id":"conv-code-search-demo-001","code_search.query_hash":"sha256:436d2a7ed0737815a485101149ac0b2f0257573dc4a7d65cc3f5d1495bdb001a","code_search.query_category":"auth_session_debug","code_search.filter_hash":"sha256:823b6b5cedb4858291cc68b8eeaccd69cd4a8e4f54cbe62c6ca99bc590847335","code_search.top_k":8,"code_search.candidate_count_bucket":"over_1k","code_search.index.snapshot_id_hash":"sha256:6a0d5bd7e10e","privacy.raw_query_recorded":false,"privacy.raw_filter_recorded":false,"audit_gap":"proves search request identity and candidate scale, not semantic relevance"}}
3
+ {"trace_id":"02c8df97e575ea76a89acf4fe9194925","span_id":"9568b542931d5d73","name":"code.search.result.returned","time":"2026-05-26T14:00:04.000Z","attributes":{"session.id":"session-code-search-demo-001","gen_ai.conversation.id":"conv-code-search-demo-001","code_search.index.snapshot_id_hash":"sha256:6a0d5bd7e10e","code_search.result.rank":1,"code_search.result.score_bucket":"very_high","code_search.result.chunk_id_hash":"sha256:9b5a0917012a","code_search.result.chunk_text_hash":"sha256:89f80a544ab501d52eb4f3cb9ff1aefe496570db864b06011895db06009142ce","code_search.result.path_hash":"sha256:d730007d6c0f93605282b288e74d7f544c7f6f341a3f3c4a38a82903df69766d","code_search.result.path_extension":"ts","code_search.result.line_range_bucket":"under_100_lines","code_search.result.stale":false,"code_search.result.duplicate_of_hash":"","code_search.result.loaded_into_agent_context":true,"code_search.result.suppressed_before_agent_context":false,"code_search.result.suppression_reason":"","privacy.raw_code_chunk_recorded":false,"privacy.raw_path_recorded":false}}
4
+ {"trace_id":"02c8df97e575ea76a89acf4fe9194925","span_id":"9568b542931d5d73","name":"code.search.result.returned","time":"2026-05-26T14:00:04.000Z","attributes":{"session.id":"session-code-search-demo-001","gen_ai.conversation.id":"conv-code-search-demo-001","code_search.index.snapshot_id_hash":"sha256:6a0d5bd7e10e","code_search.result.rank":2,"code_search.result.score_bucket":"high","code_search.result.chunk_id_hash":"sha256:813c55aef28e","code_search.result.chunk_text_hash":"sha256:d73fdad68b67584cd00466261369d2c8bf41c7518ef39699c3962f6819a840b3","code_search.result.path_hash":"sha256:74915fb212979bb303ee810c9190a0d316ab17f1946975e3d1af57ed3001f058","code_search.result.path_extension":"ts","code_search.result.line_range_bucket":"under_100_lines","code_search.result.stale":false,"code_search.result.duplicate_of_hash":"","code_search.result.loaded_into_agent_context":true,"code_search.result.suppressed_before_agent_context":false,"code_search.result.suppression_reason":"","privacy.raw_code_chunk_recorded":false,"privacy.raw_path_recorded":false}}
5
+ {"trace_id":"02c8df97e575ea76a89acf4fe9194925","span_id":"9568b542931d5d73","name":"code.search.result.returned","time":"2026-05-26T14:00:04.000Z","attributes":{"session.id":"session-code-search-demo-001","gen_ai.conversation.id":"conv-code-search-demo-001","code_search.index.snapshot_id_hash":"sha256:6a0d5bd7e10e","code_search.result.rank":3,"code_search.result.score_bucket":"high","code_search.result.chunk_id_hash":"sha256:0570aa4bf0e9","code_search.result.chunk_text_hash":"sha256:39b430127a752702d78ec3180e183f90732310d13e15bcc1adf44cfba2861152","code_search.result.path_hash":"sha256:504efd04322190f19e8d6268b79713d4f7ce890fe9279e76f69d8f18a1e20eb3","code_search.result.path_extension":"ts","code_search.result.line_range_bucket":"under_100_lines","code_search.result.stale":false,"code_search.result.duplicate_of_hash":"","code_search.result.loaded_into_agent_context":true,"code_search.result.suppressed_before_agent_context":false,"code_search.result.suppression_reason":"","privacy.raw_code_chunk_recorded":false,"privacy.raw_path_recorded":false}}
6
+ {"trace_id":"02c8df97e575ea76a89acf4fe9194925","span_id":"9568b542931d5d73","name":"code.search.result.returned","time":"2026-05-26T14:00:04.000Z","attributes":{"session.id":"session-code-search-demo-001","gen_ai.conversation.id":"conv-code-search-demo-001","code_search.index.snapshot_id_hash":"sha256:6a0d5bd7e10e","code_search.result.rank":4,"code_search.result.score_bucket":"high","code_search.result.chunk_id_hash":"sha256:8f6ad990276d","code_search.result.chunk_text_hash":"sha256:fa92fc454797f886864101bdc4032b930d3243320829e4cab48b4f130f95c6b3","code_search.result.path_hash":"sha256:201aa087ff7e0ae80320fea83e0ab68442f48898f199564286804131f9cb9725","code_search.result.path_extension":"ts","code_search.result.line_range_bucket":"under_100_lines","code_search.result.stale":false,"code_search.result.duplicate_of_hash":"sha256:9b5a0917012a","code_search.result.loaded_into_agent_context":false,"code_search.result.suppressed_before_agent_context":true,"code_search.result.suppression_reason":"duplicate","privacy.raw_code_chunk_recorded":false,"privacy.raw_path_recorded":false}}
7
+ {"trace_id":"02c8df97e575ea76a89acf4fe9194925","span_id":"9568b542931d5d73","name":"code.search.result.returned","time":"2026-05-26T14:00:04.000Z","attributes":{"session.id":"session-code-search-demo-001","gen_ai.conversation.id":"conv-code-search-demo-001","code_search.index.snapshot_id_hash":"sha256:6a0d5bd7e10e","code_search.result.rank":5,"code_search.result.score_bucket":"medium","code_search.result.chunk_id_hash":"sha256:cfc00599f288","code_search.result.chunk_text_hash":"sha256:ce03d90b6be534b863cda68baa527cd8067d2cc2b17909d224badc35aaea09a0","code_search.result.path_hash":"sha256:fec2453a62f266008a8ec7ca36bdaf87ff3da8a6e16a1af58f3e67a06eee3db1","code_search.result.path_extension":"md","code_search.result.line_range_bucket":"under_100_lines","code_search.result.stale":true,"code_search.result.duplicate_of_hash":"","code_search.result.loaded_into_agent_context":false,"code_search.result.suppressed_before_agent_context":true,"code_search.result.suppression_reason":"stale_snapshot_chunk","privacy.raw_code_chunk_recorded":false,"privacy.raw_path_recorded":false}}
8
+ {"trace_id":"02c8df97e575ea76a89acf4fe9194925","span_id":"9568b542931d5d73","name":"context.input.loaded","time":"2026-05-26T14:00:06.000Z","attributes":{"session.id":"session-code-search-demo-001","gen_ai.conversation.id":"conv-code-search-demo-001","context.input.kind":"retrieved_code_chunks","context.input.source":"code_search","context.input.client_transform":"top_k_then_dedupe_then_stale_filter","context.input.loaded_chunk_count":3,"context.input.suppressed_chunk_count":2,"context.input.loaded_chunk_ids_hash":"sha256:65ecc531bcad826933c08dc1be4429a6c02f68f446517f6c16f06c9ba5492a72","context.input.suppressed_chunk_ids_hash":"sha256:f4baf0b7d5a2c8a337242746cc1bb6a0473761b4319c10b46c7332356d695c4e","context.input.prompt_token_bucket":"under_5k","context.input.raw_prompt_hash":"sha256:5d992588057a1ae2b6cb5675315c4804a23f1eb2724527d5036be185e3ce161d","privacy.raw_prompt_recorded":false,"privacy.raw_code_chunks_recorded":false,"privacy.raw_paths_recorded":false,"audit_gap":"proves returned-vs-loaded boundary, not answer correctness or retrieval optimality"}}
@@ -0,0 +1,280 @@
1
+ #!/usr/bin/env node
2
+ import { createHash } from 'node:crypto';
3
+ import { readFileSync, writeFileSync } from 'node:fs';
4
+ import { dirname, extname, join, resolve } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+
7
+ const here = dirname(fileURLToPath(import.meta.url));
8
+ const inputPath = process.argv[2] ? resolve(process.argv[2]) : join(here, 'sample-code-search-retrieval-log.jsonl');
9
+ const receiptPath = process.argv[3] ? resolve(process.argv[3]) : join(here, 'code-search-retrieval-receipt.ndjson');
10
+ const tracePath = process.argv[4] ? resolve(process.argv[4]) : join(here, 'code-search-retrieval-otel-trace.json');
11
+
12
+ function sha256(value) {
13
+ return `sha256:${createHash('sha256').update(value ?? '').digest('hex')}`;
14
+ }
15
+
16
+ function hashRef(value) {
17
+ return sha256(value ?? '').slice(0, 19);
18
+ }
19
+
20
+ function readJsonl(path) {
21
+ return readFileSync(path, 'utf8')
22
+ .trim()
23
+ .split('\n')
24
+ .filter(Boolean)
25
+ .map((line, index) => {
26
+ try {
27
+ return JSON.parse(line);
28
+ } catch (error) {
29
+ throw new Error(`Invalid JSONL at ${path}:${index + 1}: ${error.message}`);
30
+ }
31
+ });
32
+ }
33
+
34
+ function unixNano(isoTimestamp) {
35
+ return `${BigInt(Date.parse(isoTimestamp)) * 1_000_000n}`;
36
+ }
37
+
38
+ function otelValue(value) {
39
+ if (typeof value === 'boolean') return { boolValue: value };
40
+ if (typeof value === 'number' && Number.isInteger(value)) return { intValue: String(value) };
41
+ if (typeof value === 'number') return { doubleValue: value };
42
+ if (value == null) return { stringValue: '' };
43
+ return { stringValue: String(value) };
44
+ }
45
+
46
+ function attributesToOtel(attributes) {
47
+ return Object.entries(attributes).map(([key, value]) => ({ key, value: otelValue(value) }));
48
+ }
49
+
50
+ function countBucket(value) {
51
+ if (value === 0) return 'zero';
52
+ if (value <= 5) return 'under_5';
53
+ if (value <= 25) return 'under_25';
54
+ if (value <= 100) return 'under_100';
55
+ if (value <= 1_000) return 'under_1k';
56
+ return 'over_1k';
57
+ }
58
+
59
+ function tokenBucket(value) {
60
+ if (value < 1_000) return 'under_1k';
61
+ if (value < 5_000) return 'under_5k';
62
+ if (value < 10_000) return 'under_10k';
63
+ return 'over_10k';
64
+ }
65
+
66
+ function scoreBucket(score) {
67
+ if (score >= 0.9) return 'very_high';
68
+ if (score >= 0.8) return 'high';
69
+ if (score >= 0.6) return 'medium';
70
+ return 'low';
71
+ }
72
+
73
+ function lineRangeBucket(result) {
74
+ const lineCount = Math.max(0, Number(result.end_line) - Number(result.start_line) + 1);
75
+ if (lineCount <= 25) return 'under_25_lines';
76
+ if (lineCount <= 100) return 'under_100_lines';
77
+ return 'over_100_lines';
78
+ }
79
+
80
+ const records = readJsonl(inputPath);
81
+ const session = records.find((record) => record.type === 'session.start');
82
+ const snapshot = records.find((record) => record.type === 'code.index.snapshot.used');
83
+ const search = records.find((record) => record.type === 'code.search.performed');
84
+ const returned = records.find((record) => record.type === 'code.search.results.returned');
85
+ const loaded = records.find((record) => record.type === 'context.input.loaded');
86
+
87
+ if (!session || !snapshot || !search || !returned || !loaded) {
88
+ throw new Error(`Expected session.start, code.index.snapshot.used, code.search.performed, code.search.results.returned, and context.input.loaded records in ${inputPath}`);
89
+ }
90
+
91
+ const results = returned.results ?? [];
92
+ const traceSeed = `${session.session_id}:${session.conversation_id}:code-search-retrieval`;
93
+ const traceId = sha256(traceSeed).replace('sha256:', '').slice(0, 32);
94
+ const spanId = sha256(`${traceSeed}:span`).replace('sha256:', '').slice(0, 16);
95
+ const loadedIds = new Set(loaded.loaded_chunk_ids ?? []);
96
+ const suppressedIds = new Set(loaded.suppressed_chunk_ids ?? []);
97
+
98
+ const snapshotEvent = {
99
+ trace_id: traceId,
100
+ span_id: spanId,
101
+ name: 'code.index.snapshot.used',
102
+ time: snapshot.time,
103
+ attributes: {
104
+ 'session.id': session.session_id,
105
+ 'gen_ai.conversation.id': session.conversation_id,
106
+ 'agent.name': session.agent,
107
+ 'code_search.index.snapshot_id_hash': hashRef(snapshot.index_snapshot_id),
108
+ 'code_search.codebase.path_hash': sha256(snapshot.codebase_path),
109
+ 'code_search.git.commit_hash': sha256(snapshot.git_commit),
110
+ 'code_search.indexed_file_count_bucket': countBucket(snapshot.indexed_file_count),
111
+ 'code_search.indexed_chunk_count_bucket': countBucket(snapshot.indexed_chunk_count),
112
+ 'code_search.embedding.provider_hash': hashRef(snapshot.embedding_provider),
113
+ 'code_search.embedding.model_hash': hashRef(snapshot.embedding_model),
114
+ 'code_search.snapshot.status': snapshot.snapshot_status,
115
+ 'privacy.raw_codebase_path_recorded': false,
116
+ 'privacy.raw_embedding_config_recorded': false
117
+ }
118
+ };
119
+
120
+ const searchEvent = {
121
+ trace_id: traceId,
122
+ span_id: spanId,
123
+ name: 'code.search.performed',
124
+ time: search.time,
125
+ attributes: {
126
+ 'session.id': session.session_id,
127
+ 'gen_ai.conversation.id': session.conversation_id,
128
+ 'code_search.query_hash': sha256(search.raw_query),
129
+ 'code_search.query_category': search.query_category,
130
+ 'code_search.filter_hash': sha256(search.filter),
131
+ 'code_search.top_k': search.top_k,
132
+ 'code_search.candidate_count_bucket': countBucket(search.candidate_count),
133
+ 'code_search.index.snapshot_id_hash': hashRef(search.index_snapshot_id),
134
+ 'privacy.raw_query_recorded': false,
135
+ 'privacy.raw_filter_recorded': false,
136
+ 'audit_gap': 'proves search request identity and candidate scale, not semantic relevance'
137
+ }
138
+ };
139
+
140
+ const resultEvents = results.map((result) => ({
141
+ trace_id: traceId,
142
+ span_id: spanId,
143
+ name: 'code.search.result.returned',
144
+ time: returned.time,
145
+ attributes: {
146
+ 'session.id': session.session_id,
147
+ 'gen_ai.conversation.id': session.conversation_id,
148
+ 'code_search.index.snapshot_id_hash': hashRef(returned.index_snapshot_id),
149
+ 'code_search.result.rank': result.rank,
150
+ 'code_search.result.score_bucket': scoreBucket(result.score),
151
+ 'code_search.result.chunk_id_hash': hashRef(result.chunk_id),
152
+ 'code_search.result.chunk_text_hash': sha256(result.raw_chunk_text),
153
+ 'code_search.result.path_hash': sha256(result.path),
154
+ 'code_search.result.path_extension': extname(result.path).slice(1) || 'none',
155
+ 'code_search.result.line_range_bucket': lineRangeBucket(result),
156
+ 'code_search.result.stale': Boolean(result.stale),
157
+ 'code_search.result.duplicate_of_hash': result.duplicate_of ? hashRef(result.duplicate_of) : '',
158
+ 'code_search.result.loaded_into_agent_context': loadedIds.has(result.chunk_id),
159
+ 'code_search.result.suppressed_before_agent_context': suppressedIds.has(result.chunk_id),
160
+ 'code_search.result.suppression_reason': loaded.suppression_reasons?.[result.chunk_id] ?? '',
161
+ 'privacy.raw_code_chunk_recorded': false,
162
+ 'privacy.raw_path_recorded': false
163
+ }
164
+ }));
165
+
166
+ const loadedEvent = {
167
+ trace_id: traceId,
168
+ span_id: spanId,
169
+ name: 'context.input.loaded',
170
+ time: loaded.time,
171
+ attributes: {
172
+ 'session.id': session.session_id,
173
+ 'gen_ai.conversation.id': session.conversation_id,
174
+ 'context.input.kind': 'retrieved_code_chunks',
175
+ 'context.input.source': 'code_search',
176
+ 'context.input.client_transform': loaded.client_transform,
177
+ 'context.input.loaded_chunk_count': loadedIds.size,
178
+ 'context.input.suppressed_chunk_count': suppressedIds.size,
179
+ 'context.input.loaded_chunk_ids_hash': sha256([...loadedIds].sort().join('\n')),
180
+ 'context.input.suppressed_chunk_ids_hash': sha256([...suppressedIds].sort().join('\n')),
181
+ 'context.input.prompt_token_bucket': tokenBucket(loaded.prompt_token_count),
182
+ 'context.input.raw_prompt_hash': sha256(loaded.raw_prompt_fragment),
183
+ 'privacy.raw_prompt_recorded': false,
184
+ 'privacy.raw_code_chunks_recorded': false,
185
+ 'privacy.raw_paths_recorded': false,
186
+ 'audit_gap': 'proves returned-vs-loaded boundary, not answer correctness or retrieval optimality'
187
+ }
188
+ };
189
+
190
+ const events = [snapshotEvent, searchEvent, ...resultEvents, loadedEvent]
191
+ .sort((left, right) => Date.parse(left.time) - Date.parse(right.time) || left.name.localeCompare(right.name));
192
+
193
+ writeFileSync(receiptPath, `${events.map((event) => JSON.stringify(event)).join('\n')}\n`);
194
+
195
+ const trace = {
196
+ resourceSpans: [
197
+ {
198
+ resource: {
199
+ attributes: attributesToOtel({
200
+ 'service.name': 'pluribus-code-search-retrieval-receipt-demo',
201
+ 'service.version': '0.0.0-fixture',
202
+ 'deployment.environment.name': 'local-fixture'
203
+ })
204
+ },
205
+ scopeSpans: [
206
+ {
207
+ scope: {
208
+ name: 'pluribus.context_input_evidence.code_search_retrieval_demo',
209
+ version: '0.0.0-fixture'
210
+ },
211
+ spans: [
212
+ {
213
+ traceId,
214
+ spanId,
215
+ parentSpanId: '',
216
+ name: 'agent.session.code_search_retrieval',
217
+ kind: 1,
218
+ startTimeUnixNano: unixNano(snapshot.time),
219
+ endTimeUnixNano: unixNano(loaded.time),
220
+ attributes: attributesToOtel({
221
+ 'session.id': session.session_id,
222
+ 'gen_ai.conversation.id': session.conversation_id,
223
+ 'agent.name': session.agent,
224
+ 'workspace.name_hash': hashRef(session.workspace),
225
+ 'gen_ai.request.model': session.model,
226
+ 'code_search.query_category': search.query_category
227
+ }),
228
+ events: events.map((event) => ({
229
+ name: event.name,
230
+ timeUnixNano: unixNano(event.time),
231
+ attributes: attributesToOtel(event.attributes)
232
+ }))
233
+ }
234
+ ]
235
+ }
236
+ ]
237
+ }
238
+ ]
239
+ };
240
+
241
+ writeFileSync(tracePath, `${JSON.stringify(trace, null, 2)}\n`);
242
+
243
+ const forbiddenRawStrings = [
244
+ '/Users/alex/src/acme-payments/private-monorepo',
245
+ 'Acme-Co',
246
+ 'sk_live_private_fixture',
247
+ 'finance-vp@acme.example',
248
+ 'sso.internal.acme.example',
249
+ 'tok_private_fixture',
250
+ 'ACME-7391',
251
+ '+1-555-0100',
252
+ 'https://acme.example/private/sso',
253
+ 'src/auth/session-renewal.ts',
254
+ 'src/auth/sso/failover.ts',
255
+ 'src/billing/stripe-session.ts',
256
+ 'docs/runbooks/sso-failover.md'
257
+ ];
258
+
259
+ const receiptText = readFileSync(receiptPath, 'utf8');
260
+ const traceText = readFileSync(tracePath, 'utf8');
261
+ const leaked = forbiddenRawStrings.filter((value) => receiptText.includes(value) || traceText.includes(value));
262
+ if (leaked.length > 0) {
263
+ throw new Error(`Receipt leaked raw private fixture strings: ${leaked.join(', ')}`);
264
+ }
265
+
266
+ console.log(JSON.stringify({
267
+ schema: 'pluribus.codeSearchRetrievalReceipt.demo.v0',
268
+ eventCount: events.length,
269
+ returnedResultCount: results.length,
270
+ loadedChunkCount: loadedIds.size,
271
+ suppressedChunkCount: suppressedIds.size,
272
+ staleReturnedCount: results.filter((result) => result.stale).length,
273
+ duplicateReturnedCount: results.filter((result) => result.duplicate_of).length,
274
+ rawCodeCopiedToReceipt: false,
275
+ rawPathsCopiedToReceipt: false,
276
+ rawQueryCopiedToReceipt: false,
277
+ receiptPath: 'examples/context-input-evidence/code-search-retrieval-receipt.ndjson',
278
+ tracePath: 'examples/context-input-evidence/code-search-retrieval-otel-trace.json',
279
+ lesson: 'Code-search tools should attest returned result identities separately from what the agent actually loaded, without exposing raw code or private paths.'
280
+ }, null, 2));
@@ -0,0 +1,5 @@
1
+ {"type":"session.start","time":"2026-05-26T14:00:00.000Z","session_id":"session-code-search-demo-001","conversation_id":"conv-code-search-demo-001","agent":"claude-code","workspace":"private-monorepo-fixture","model":"claude-opus-4.6"}
2
+ {"type":"code.index.snapshot.used","time":"2026-05-26T14:00:01.000Z","index_snapshot_id":"snapshot-2026-05-26T13-55Z","codebase_path":"/Users/alex/src/acme-payments/private-monorepo","git_commit":"d34db33fd34db33fd34db33fd34db33fd34db33f","embedding_provider":"zilliz-cloud-openai","embedding_model":"text-embedding-3-large","indexed_file_count":1842,"indexed_chunk_count":12678,"snapshot_status":"fresh"}
3
+ {"type":"code.search.performed","time":"2026-05-26T14:00:03.000Z","raw_query":"why does Acme-Co session renewal fail for enterprise SSO customers after region failover? include Stripe payment token path","query_category":"auth_session_debug","top_k":8,"candidate_count":12678,"filter":"language:typescript path:src/auth","index_snapshot_id":"snapshot-2026-05-26T13-55Z"}
4
+ {"type":"code.search.results.returned","time":"2026-05-26T14:00:04.000Z","index_snapshot_id":"snapshot-2026-05-26T13-55Z","results":[{"rank":1,"score":0.912,"path":"src/auth/session-renewal.ts","start_line":42,"end_line":91,"chunk_id":"chunk-auth-renewal-42-91","raw_chunk_text":"const ACME_INTERNAL_SSO_CLIENT_SECRET = 'sk_live_private_fixture'; const customerEmail = 'finance-vp@acme.example'; renewSessionAfterRegionFailover();","stale":false,"duplicate_of":null},{"rank":2,"score":0.887,"path":"src/auth/sso/failover.ts","start_line":14,"end_line":66,"chunk_id":"chunk-sso-failover-14-66","raw_chunk_text":"handle failover for sso tenant acme-co with payment token tok_private_fixture and internal host sso.internal.acme.example","stale":false,"duplicate_of":null},{"rank":3,"score":0.861,"path":"src/billing/stripe-session.ts","start_line":108,"end_line":143,"chunk_id":"chunk-billing-stripe-108-143","raw_chunk_text":"stripe payment renewal path for customer acme-co. contains ticket ACME-7391 and private webhook payload.","stale":false,"duplicate_of":null},{"rank":4,"score":0.858,"path":"src/auth/session-renewal-copy.ts","start_line":42,"end_line":91,"chunk_id":"chunk-auth-renewal-copy-42-91","raw_chunk_text":"duplicate copy of the private Acme-Co session renewal fixture with sk_live_private_fixture","stale":false,"duplicate_of":"chunk-auth-renewal-42-91"},{"rank":5,"score":0.792,"path":"docs/runbooks/sso-failover.md","start_line":5,"end_line":38,"chunk_id":"chunk-runbook-sso-5-38","raw_chunk_text":"runbook says page oncall at +1-555-0100 and include customer URL https://acme.example/private/sso","stale":true,"duplicate_of":null}]}
5
+ {"type":"context.input.loaded","time":"2026-05-26T14:00:06.000Z","index_snapshot_id":"snapshot-2026-05-26T13-55Z","loaded_chunk_ids":["chunk-auth-renewal-42-91","chunk-sso-failover-14-66","chunk-billing-stripe-108-143"],"suppressed_chunk_ids":["chunk-auth-renewal-copy-42-91","chunk-runbook-sso-5-38"],"suppression_reasons":{"chunk-auth-renewal-copy-42-91":"duplicate","chunk-runbook-sso-5-38":"stale_snapshot_chunk"},"prompt_token_count":2860,"raw_prompt_fragment":"User asked about Acme-Co private SSO failover and sk_live_private_fixture; include webhook payload from https://acme.example/private/sso","client_transform":"top_k_then_dedupe_then_stale_filter"}
@@ -0,0 +1,18 @@
1
+ # Dynamic workflow run receipt example
2
+
3
+ This example is a copyable privacy-safe receipt for Claude Code-style dynamic workflows, ultracode runs, local LLM gateway orchestration, or any script that spawns several subagents to audit, migrate, research, or verify a codebase.
4
+
5
+ Use it when the parent session only sees the final report, but reviewers still need to understand:
6
+
7
+ - which phases ran;
8
+ - how many agents were spawned;
9
+ - which role/model/provider each agent actually used;
10
+ - which context was loaded, skipped, or suppressed;
11
+ - which tools/capabilities were granted and used;
12
+ - how token spend was bucketed;
13
+ - where each agent stopped;
14
+ - which gaps remain before mutation or merge.
15
+
16
+ The example intentionally uses coarse labels, buckets, and hashes instead of raw prompts, source code, exact paths, transcripts, tool output, secrets, or customer data.
17
+
18
+ See [`docs/dynamic-workflow-run-receipts.md`](../../docs/dynamic-workflow-run-receipts.md) for the checklist and field rationale.
@@ -0,0 +1,112 @@
1
+ {
2
+ "type": "dynamic.workflow.run_receipt.v1",
3
+ "workflow": {
4
+ "workflow_id": "wf_checkout_auth_audit_2026_05_30",
5
+ "runner": "claude-code-dynamic-workflow",
6
+ "script_source": "generated-then-reviewed-command",
7
+ "script_hash": "sha256:example-only",
8
+ "task_kind": "codebase_auth_audit",
9
+ "plan_approved_before_run": true,
10
+ "resumable": true,
11
+ "max_wall_clock_bucket": "under_15m",
12
+ "kill_switch_available": true,
13
+ "started_at": "2026-05-30T15:20:00Z",
14
+ "completed_at": "2026-05-30T15:31:42Z"
15
+ },
16
+ "permissions": {
17
+ "tool_allowlist_inherited": true,
18
+ "writes_allowed": false,
19
+ "network_allowed": false,
20
+ "external_commands_allowed": ["grep", "test --dry-run"],
21
+ "permission_profile": "review-only"
22
+ },
23
+ "phases": [
24
+ {
25
+ "phase_id": "route-inventory",
26
+ "purpose": "find candidate auth-sensitive routes",
27
+ "agent_count": 3,
28
+ "token_spend_bucket": "under_50k",
29
+ "elapsed_ms_bucket": "under_2m",
30
+ "result": "completed"
31
+ },
32
+ {
33
+ "phase_id": "adversarial-review",
34
+ "purpose": "cross-check candidate misses",
35
+ "agent_count": 2,
36
+ "token_spend_bucket": "under_25k",
37
+ "elapsed_ms_bucket": "under_2m",
38
+ "result": "completed_with_gaps"
39
+ }
40
+ ],
41
+ "agents": [
42
+ {
43
+ "agent_id": "agent-route-auditor-1",
44
+ "phase_id": "route-inventory",
45
+ "role": "route-auth-auditor",
46
+ "model": "claude-sonnet",
47
+ "provider": "anthropic",
48
+ "context_loaded": ["repo-policy", "auth-boundary-rules", "route-index-summary"],
49
+ "context_skipped_or_suppressed": [
50
+ {
51
+ "source": "customer-fixture-dump",
52
+ "reason": "contains raw customer data; summary hash only"
53
+ }
54
+ ],
55
+ "tools_granted": ["read", "grep"],
56
+ "tools_used": ["grep"],
57
+ "feature_areas_checked": ["checkout routes", "admin routes"],
58
+ "token_budget_bucket": "under_25k",
59
+ "token_spend_bucket": "under_10k",
60
+ "max_iterations": 8,
61
+ "iterations_used": 3,
62
+ "heartbeat_seen_at": "2026-05-30T15:25:00Z",
63
+ "partial_progress_reported": true,
64
+ "fuse_triggered": false,
65
+ "stop_reason": "completed_assigned_partition",
66
+ "confidence": "medium",
67
+ "known_gaps": ["did not execute integration tests"],
68
+ "raw_prompt_logged": false,
69
+ "raw_tool_output_logged": false,
70
+ "raw_paths_logged": false
71
+ },
72
+ {
73
+ "agent_id": "agent-reviewer-1",
74
+ "phase_id": "adversarial-review",
75
+ "role": "adversarial-auth-reviewer",
76
+ "model": "local-codex-compatible",
77
+ "provider": "local-llm-gateway",
78
+ "context_loaded": ["candidate-findings-summary", "public-api-contract-summary"],
79
+ "context_skipped_or_suppressed": [],
80
+ "tools_granted": ["read"],
81
+ "tools_used": ["read"],
82
+ "feature_areas_checked": ["route findings cross-check"],
83
+ "token_budget_bucket": "under_10k",
84
+ "token_spend_bucket": "under_10k",
85
+ "max_iterations": 5,
86
+ "iterations_used": 5,
87
+ "heartbeat_seen_at": "2026-05-30T15:30:00Z",
88
+ "partial_progress_reported": true,
89
+ "fuse_triggered": true,
90
+ "stop_reason": "iteration_budget_reached_before_claim_verified",
91
+ "confidence": "low",
92
+ "known_gaps": ["one route requires owner confirmation before merge"],
93
+ "raw_prompt_logged": false,
94
+ "raw_tool_output_logged": false,
95
+ "raw_paths_logged": false
96
+ }
97
+ ],
98
+ "handoff": {
99
+ "final_result_kind": "workflow_review_receipt",
100
+ "claims_rejected_or_deferred": 1,
101
+ "next_safe_action": "ask route owner to confirm checkout callback auth before writing fix",
102
+ "where_it_stopped": "ambiguous auth boundary before mutation"
103
+ },
104
+ "privacy": {
105
+ "raw_prompts_logged": false,
106
+ "raw_source_logged": false,
107
+ "raw_tool_output_logged": false,
108
+ "transcripts_logged": false,
109
+ "secrets_logged": false,
110
+ "customer_data_logged": false
111
+ }
112
+ }
@@ -0,0 +1,34 @@
1
+ # Install-plan receipt example
2
+
3
+ This example is for one-command agent setup tools that configure MCP, Skills, instruction files, hooks, or plugins across multiple AI coding tools.
4
+
5
+ Use it when you want a setup script to prove what it will write before it writes anything.
6
+
7
+ ## Copyable preflight checklist
8
+
9
+ Before applying installer changes, ask the agent or setup script to emit an `agent.install.plan.v1` receipt with:
10
+
11
+ - `agents_detected`
12
+ - `agents_selected`
13
+ - `planned_writes[]` with `kind`, `target`, `operation`, and `backup_planned`
14
+ - `external_commands_planned[]`
15
+ - `network_after_install`
16
+ - `writes_started=false`
17
+ - `next_safe_command`
18
+
19
+ Review the receipt, then run the apply command only if the planned writes match your intent.
20
+
21
+ ## Smoke test
22
+
23
+ The sample receipt is intentionally static JSON so it can be inspected without running an installer:
24
+
25
+ ```bash
26
+ cat examples/install-plan-receipts/agent-install-plan-receipt.json
27
+ node -e "const r=require('./examples/install-plan-receipts/agent-install-plan-receipt.json'); if (r.writes_started !== false) process.exit(1); console.log(r.receipt_type, r.planned_writes.length)"
28
+ ```
29
+
30
+ Expected output:
31
+
32
+ ```text
33
+ agent.install.plan.v1 3
34
+ ```
@@ -0,0 +1,56 @@
1
+ {
2
+ "receipt_type": "agent.install.plan.v1",
3
+ "run_id": "demo-install-2026-05-29T16:00Z",
4
+ "installer": "example-agent-setup",
5
+ "mode_requested": "plan",
6
+ "mode_effective": "plan",
7
+ "agents_detected": [
8
+ "claude-code",
9
+ "cursor",
10
+ "codex",
11
+ "openclaw"
12
+ ],
13
+ "agents_selected": [
14
+ "claude-code",
15
+ "openclaw"
16
+ ],
17
+ "planned_writes": [
18
+ {
19
+ "kind": "mcp_config",
20
+ "target": "claude-code project config",
21
+ "operation": "add_local_mcp_server",
22
+ "backup_planned": true
23
+ },
24
+ {
25
+ "kind": "instruction_file",
26
+ "target": "AGENTS.md",
27
+ "operation": "append_usage_notes",
28
+ "backup_planned": true
29
+ },
30
+ {
31
+ "kind": "hook",
32
+ "target": "pre-tool hook config",
33
+ "operation": "register_receipt_guard",
34
+ "backup_planned": true
35
+ }
36
+ ],
37
+ "external_commands_planned": [
38
+ {
39
+ "phase": "apply",
40
+ "command_class": "package_manager_install"
41
+ }
42
+ ],
43
+ "network_after_install": "local_mcp_server_only",
44
+ "writes_started": false,
45
+ "next_safe_command": "example-agent-setup apply --from-plan install-plan.json",
46
+ "privacy_exclusions": [
47
+ "raw_source",
48
+ "secrets",
49
+ "env_dump",
50
+ "raw_prompt",
51
+ "transcript",
52
+ "raw_tool_output",
53
+ "customer_data",
54
+ "private_absolute_path"
55
+ ]
56
+ }
@@ -0,0 +1,19 @@
1
+ # Review primitive gate example
2
+
3
+ This example validates a privacy-safe agent handoff receipt as a reviewer/CI primitive.
4
+
5
+ Run the passing fixture:
6
+
7
+ ```bash
8
+ node examples/review-primitive-gate/check-review-receipt.mjs \
9
+ examples/review-primitive-gate/pass-review-receipt.json
10
+ ```
11
+
12
+ Run the failing fixture:
13
+
14
+ ```bash
15
+ node examples/review-primitive-gate/check-review-receipt.mjs \
16
+ examples/review-primitive-gate/fail-review-receipt.json
17
+ ```
18
+
19
+ The script exits non-zero if the run is partial/unsafe, if a required check failed or was skipped, or if the agent changed scope/access without approval.
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env node
2
+ import { readFileSync } from 'node:fs'
3
+
4
+ const [file] = process.argv.slice(2)
5
+
6
+ if (!file) {
7
+ console.error('Usage: node check-review-receipt.mjs <receipt.json>')
8
+ process.exit(2)
9
+ }
10
+
11
+ let receipt
12
+ try {
13
+ receipt = JSON.parse(readFileSync(file, 'utf8'))
14
+ } catch (error) {
15
+ console.error(JSON.stringify({ ok: false, file, errors: [`invalid JSON: ${error.message}`] }, null, 2))
16
+ process.exit(2)
17
+ }
18
+
19
+ const errors = []
20
+ const warnings = []
21
+
22
+ if (receipt.type !== 'agent.review_primitive_receipt.v1') {
23
+ errors.push('type must be agent.review_primitive_receipt.v1')
24
+ }
25
+
26
+ for (const key of ['assignment_id', 'run_id']) {
27
+ if (!receipt[key] || typeof receipt[key] !== 'string') {
28
+ errors.push(`${key} is required`)
29
+ }
30
+ }
31
+
32
+ const boundaries = receipt.approved_boundaries || {}
33
+ if (!Array.isArray(boundaries.read) || boundaries.read.length === 0) {
34
+ errors.push('approved_boundaries.read must name at least one coarse read boundary')
35
+ }
36
+ if (!Array.isArray(boundaries.write)) {
37
+ errors.push('approved_boundaries.write must be an array, even for read-only runs')
38
+ }
39
+
40
+ const scopeChanges = receipt.scope_access_changes || []
41
+ if (!Array.isArray(scopeChanges)) {
42
+ errors.push('scope_access_changes must be an array')
43
+ } else {
44
+ for (const [index, change] of scopeChanges.entries()) {
45
+ if (change?.approved !== true) {
46
+ errors.push(`scope_access_changes[${index}] is not explicitly approved`)
47
+ }
48
+ }
49
+ }
50
+
51
+ const checks = receipt.commands_and_checks || []
52
+ if (!Array.isArray(checks) || checks.length === 0) {
53
+ errors.push('commands_and_checks must include at least one required check/test')
54
+ } else {
55
+ for (const [index, check] of checks.entries()) {
56
+ if (!String(check?.kind || '').startsWith('required_')) continue
57
+ if (check.status !== 'passed') {
58
+ errors.push(`commands_and_checks[${index}] required check did not pass: ${check.status || 'missing status'}`)
59
+ }
60
+ if (!check.evidence || check.evidence === 'not-run') {
61
+ errors.push(`commands_and_checks[${index}] required check is missing evidence`)
62
+ }
63
+ }
64
+ }
65
+
66
+ const allowedResumeStates = new Set(['complete', 'partial', 'unsafe-to-resume'])
67
+ if (!allowedResumeStates.has(receipt.resume_state)) {
68
+ errors.push('resume_state must be complete, partial, or unsafe-to-resume')
69
+ }
70
+ if (receipt.resume_state !== 'complete') {
71
+ errors.push(`resume_state is ${receipt.resume_state}; reviewer must inspect before merge/continuation`)
72
+ }
73
+
74
+ const handoff = receipt.handoff || {}
75
+ if (!handoff.next_safe_action || typeof handoff.next_safe_action !== 'string') {
76
+ errors.push('handoff.next_safe_action is required')
77
+ }
78
+ if (!handoff.evidence_path || typeof handoff.evidence_path !== 'string') {
79
+ warnings.push('handoff.evidence_path is recommended for review traceability')
80
+ }
81
+
82
+ const privacy = receipt.privacy || {}
83
+ for (const key of ['raw_prompts_logged', 'raw_tool_output_logged', 'source_code_logged', 'secrets_logged']) {
84
+ if (privacy[key] !== false) {
85
+ errors.push(`privacy.${key} must be false for this gate`)
86
+ }
87
+ }
88
+
89
+ const result = {
90
+ ok: errors.length === 0,
91
+ file,
92
+ assignment_id: receipt.assignment_id,
93
+ run_id: receipt.run_id,
94
+ resume_state: receipt.resume_state,
95
+ errors,
96
+ warnings
97
+ }
98
+
99
+ console.log(JSON.stringify(result, null, 2))
100
+ process.exit(result.ok ? 0 : 1)