pluribus-context 0.3.22 → 0.3.26

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 (93) hide show
  1. package/CHANGELOG.md +25 -3
  2. package/README.md +2 -2
  3. package/docs/community-review-packet.md +2 -1
  4. package/docs/context-budget-receipts.md +150 -0
  5. package/docs/context-input-evidence.md +397 -0
  6. package/docs/context-receipts-for-agent-observability.md +177 -0
  7. package/docs/orchestration-search-receipts.md +102 -0
  8. package/docs/portability-fidelity-report.md +4 -2
  9. package/examples/context-input-evidence/AGENTS.md +12 -0
  10. package/examples/context-input-evidence/agent-overlay-log.jsonl +4 -0
  11. package/examples/context-input-evidence/agent-overlay-otel-trace.json +548 -0
  12. package/examples/context-input-evidence/agent-overlay-receipt.ndjson +3 -0
  13. package/examples/context-input-evidence/agentgateway-progressive-disclosure-otel-trace.json +393 -0
  14. package/examples/context-input-evidence/agentgateway-progressive-disclosure-receipt.ndjson +4 -0
  15. package/examples/context-input-evidence/brain-remediation-otel-trace.json +645 -0
  16. package/examples/context-input-evidence/brain-remediation-receipt.ndjson +7 -0
  17. package/examples/context-input-evidence/claudekit-mcp-manager-otel-trace.json +417 -0
  18. package/examples/context-input-evidence/claudekit-mcp-manager-receipt.ndjson +5 -0
  19. package/examples/context-input-evidence/cli-progressive-disclosure-otel-trace.json +399 -0
  20. package/examples/context-input-evidence/cli-progressive-disclosure-receipt.ndjson +4 -0
  21. package/examples/context-input-evidence/compaction-otel-trace.json +711 -0
  22. package/examples/context-input-evidence/compaction-receipt.ndjson +6 -0
  23. package/examples/context-input-evidence/context-selection-otel-trace.json +627 -0
  24. package/examples/context-input-evidence/context-selection-receipt.ndjson +7 -0
  25. package/examples/context-input-evidence/convert-agent-overlay-log.mjs +156 -0
  26. package/examples/context-input-evidence/convert-agentgateway-progressive-disclosure-log.mjs +251 -0
  27. package/examples/context-input-evidence/convert-brain-remediation-log.mjs +241 -0
  28. package/examples/context-input-evidence/convert-claudekit-mcp-manager-log.mjs +253 -0
  29. package/examples/context-input-evidence/convert-cli-progressive-disclosure-log.mjs +251 -0
  30. package/examples/context-input-evidence/convert-compaction-log.mjs +224 -0
  31. package/examples/context-input-evidence/convert-context-selection-log.mjs +247 -0
  32. package/examples/context-input-evidence/convert-mcp-tool-search-log.mjs +242 -0
  33. package/examples/context-input-evidence/convert-memory-consolidation-log.mjs +240 -0
  34. package/examples/context-input-evidence/convert-memory-governance-delete-log.mjs +223 -0
  35. package/examples/context-input-evidence/convert-memory-log.mjs +226 -0
  36. package/examples/context-input-evidence/convert-memory-provenance-log.mjs +263 -0
  37. package/examples/context-input-evidence/convert-secret-scanning-log.mjs +233 -0
  38. package/examples/context-input-evidence/convert-session-log.mjs +186 -0
  39. package/examples/context-input-evidence/convert-skill-log.mjs +161 -0
  40. package/examples/context-input-evidence/convert-skill-registry-log.mjs +246 -0
  41. package/examples/context-input-evidence/convert-skill-routing-log.mjs +253 -0
  42. package/examples/context-input-evidence/convert-subagent-context-budget-log.mjs +267 -0
  43. package/examples/context-input-evidence/convert-subagent-delegation-log.mjs +264 -0
  44. package/examples/context-input-evidence/export-otel-trace.mjs +128 -0
  45. package/examples/context-input-evidence/generate-receipt.mjs +188 -0
  46. package/examples/context-input-evidence/mcp-tool-search-otel-trace.json +477 -0
  47. package/examples/context-input-evidence/mcp-tool-search-receipt.ndjson +5 -0
  48. package/examples/context-input-evidence/memory-consolidation-otel-trace.json +492 -0
  49. package/examples/context-input-evidence/memory-consolidation-receipt.ndjson +4 -0
  50. package/examples/context-input-evidence/memory-governance-delete-otel-trace.json +614 -0
  51. package/examples/context-input-evidence/memory-governance-delete-receipt.ndjson +5 -0
  52. package/examples/context-input-evidence/memory-otel-trace.json +645 -0
  53. package/examples/context-input-evidence/memory-provenance-otel-trace.json +711 -0
  54. package/examples/context-input-evidence/memory-provenance-receipt.ndjson +5 -0
  55. package/examples/context-input-evidence/memory-receipt.ndjson +4 -0
  56. package/examples/context-input-evidence/otel-trace.json +1119 -0
  57. package/examples/context-input-evidence/receipt.ndjson +6 -0
  58. package/examples/context-input-evidence/sample-agentgateway-progressive-disclosure-log.jsonl +5 -0
  59. package/examples/context-input-evidence/sample-brain-remediation-log.jsonl +9 -0
  60. package/examples/context-input-evidence/sample-claudekit-mcp-manager-log.jsonl +6 -0
  61. package/examples/context-input-evidence/sample-cli-progressive-disclosure-log.jsonl +5 -0
  62. package/examples/context-input-evidence/sample-compaction-log.jsonl +7 -0
  63. package/examples/context-input-evidence/sample-context-selection-log.jsonl +7 -0
  64. package/examples/context-input-evidence/sample-mcp-tool-search-log.jsonl +6 -0
  65. package/examples/context-input-evidence/sample-memory-consolidation-log.jsonl +5 -0
  66. package/examples/context-input-evidence/sample-memory-governance-delete-log.jsonl +6 -0
  67. package/examples/context-input-evidence/sample-memory-provenance-log.jsonl +6 -0
  68. package/examples/context-input-evidence/sample-memory-retrieval-log.jsonl +6 -0
  69. package/examples/context-input-evidence/sample-secret-scanning-log.jsonl +7 -0
  70. package/examples/context-input-evidence/sample-session-log.jsonl +6 -0
  71. package/examples/context-input-evidence/sample-skill-registry-log.jsonl +5 -0
  72. package/examples/context-input-evidence/sample-skill-routing-log.jsonl +7 -0
  73. package/examples/context-input-evidence/sample-subagent-context-budget-log.jsonl +6 -0
  74. package/examples/context-input-evidence/sample-subagent-delegation-log.jsonl +5 -0
  75. package/examples/context-input-evidence/secret-scanning-otel-trace.json +794 -0
  76. package/examples/context-input-evidence/secret-scanning-receipt.ndjson +6 -0
  77. package/examples/context-input-evidence/session-otel-trace.json +411 -0
  78. package/examples/context-input-evidence/session-receipt.ndjson +2 -0
  79. package/examples/context-input-evidence/skill-invocation-log.jsonl +4 -0
  80. package/examples/context-input-evidence/skill-otel-trace.json +548 -0
  81. package/examples/context-input-evidence/skill-receipt.ndjson +3 -0
  82. package/examples/context-input-evidence/skill-registry-otel-trace.json +471 -0
  83. package/examples/context-input-evidence/skill-registry-receipt.ndjson +5 -0
  84. package/examples/context-input-evidence/skill-routing-otel-trace.json +567 -0
  85. package/examples/context-input-evidence/skill-routing-receipt.ndjson +6 -0
  86. package/examples/context-input-evidence/subagent-context-budget-otel-trace.json +507 -0
  87. package/examples/context-input-evidence/subagent-context-budget-receipt.ndjson +5 -0
  88. package/examples/context-input-evidence/subagent-delegation-otel-trace.json +388 -0
  89. package/examples/context-input-evidence/subagent-delegation-receipt.ndjson +4 -0
  90. package/package.json +6 -2
  91. package/schemas/audit-result.schema.json +409 -71
  92. package/src/commands/audit.js +64 -3
  93. package/src/utils/version.js +1 -1
@@ -0,0 +1,253 @@
1
+ #!/usr/bin/env node
2
+ import { createHash } from 'node:crypto';
3
+ import { readFileSync, writeFileSync } from 'node:fs';
4
+ import { dirname, 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-claudekit-mcp-manager-log.jsonl');
9
+ const receiptPath = process.argv[3] ? resolve(process.argv[3]) : join(here, 'claudekit-mcp-manager-receipt.ndjson');
10
+ const tracePath = process.argv[4] ? resolve(process.argv[4]) : join(here, 'claudekit-mcp-manager-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 tokenBucket(value) {
51
+ if (value < 1_000) return 'under_1k';
52
+ if (value < 10_000) return 'under_10k';
53
+ if (value < 50_000) return 'under_50k';
54
+ if (value < 100_000) return 'under_100k';
55
+ return 'over_100k';
56
+ }
57
+
58
+ function countBucket(value) {
59
+ if (value === 0) return 'zero';
60
+ if (value <= 5) return 'under_5';
61
+ if (value <= 25) return 'under_25';
62
+ if (value <= 100) return 'under_100';
63
+ if (value <= 500) return 'under_500';
64
+ return 'over_500';
65
+ }
66
+
67
+ const records = readJsonl(inputPath);
68
+ const session = records.find((record) => record.type === 'session.start');
69
+ const parentContext = records.find((record) => record.type === 'mcp.manager.parent_context.evaluated');
70
+ const subagentBoot = records.find((record) => record.type === 'mcp.manager.subagent.booted');
71
+ const toolSelected = records.find((record) => record.type === 'mcp.manager.tool_selected');
72
+ const toolInvoked = records.find((record) => record.type === 'mcp.manager.tool_invoked');
73
+ const summaryReturned = records.find((record) => record.type === 'mcp.manager.parent_summary.returned');
74
+
75
+ if (!session || !parentContext || !subagentBoot || !toolSelected || !toolInvoked || !summaryReturned) {
76
+ throw new Error(`Expected session.start and all mcp.manager.* records in ${inputPath}`);
77
+ }
78
+
79
+ const traceSeed = `${session.session_id}:${session.conversation_id}:claudekit-mcp-manager`;
80
+ const traceId = sha256(traceSeed).replace('sha256:', '').slice(0, 32);
81
+ const spanId = sha256(`${traceSeed}:span`).replace('sha256:', '').slice(0, 16);
82
+
83
+ const events = [
84
+ {
85
+ trace_id: traceId,
86
+ span_id: spanId,
87
+ name: 'mcp.manager.parent_context.evaluated',
88
+ time: parentContext.time,
89
+ attributes: {
90
+ 'session.id': session.session_id,
91
+ 'gen_ai.conversation.id': session.conversation_id,
92
+ 'agent.name': session.agent,
93
+ 'mcp.manager.pattern': parentContext.pattern,
94
+ 'mcp.manager.parent_visible_skill_hash': hashRef(parentContext.parent_visible_skill),
95
+ 'mcp.manager.parent_visible_token_bucket': tokenBucket(parentContext.parent_visible_token_count),
96
+ 'mcp.manager.hidden_server_count_bucket': countBucket(parentContext.hidden_mcp_server_count),
97
+ 'mcp.manager.hidden_tool_schema_count_bucket': countBucket(parentContext.hidden_mcp_tool_schema_count),
98
+ 'mcp.manager.hidden_full_schema_token_bucket': tokenBucket(parentContext.hidden_full_schema_token_count),
99
+ 'mcp.manager.full_schemas_loaded_in_parent': false,
100
+ 'privacy.raw_parent_prompt_recorded': false,
101
+ 'privacy.raw_hidden_schemas_recorded': false
102
+ }
103
+ },
104
+ {
105
+ trace_id: traceId,
106
+ span_id: spanId,
107
+ name: 'mcp.manager.subagent.booted',
108
+ time: subagentBoot.time,
109
+ attributes: {
110
+ 'session.id': session.session_id,
111
+ 'gen_ai.conversation.id': session.conversation_id,
112
+ 'mcp.manager.subagent_id_hash': hashRef(subagentBoot.subagent_id),
113
+ 'mcp.manager.tools_policy': subagentBoot.tools_policy,
114
+ 'mcp.manager.server_count_bucket': countBucket(subagentBoot.server_count),
115
+ 'mcp.manager.tool_schema_count_bucket': countBucket(subagentBoot.tool_schema_count),
116
+ 'mcp.manager.subagent_startup_token_bucket': tokenBucket(subagentBoot.startup_context_token_count),
117
+ 'mcp.manager.context_window_token_bucket': tokenBucket(subagentBoot.context_window_tokens),
118
+ 'privacy.raw_subagent_tool_catalog_recorded': false
119
+ }
120
+ },
121
+ {
122
+ trace_id: traceId,
123
+ span_id: spanId,
124
+ name: 'mcp.manager.tool_selected',
125
+ time: toolSelected.time,
126
+ attributes: {
127
+ 'session.id': session.session_id,
128
+ 'gen_ai.conversation.id': session.conversation_id,
129
+ 'mcp.manager.selection_strategy': toolSelected.selection_strategy,
130
+ 'mcp.manager.selected_server_hash': hashRef(toolSelected.selected_server),
131
+ 'mcp.manager.selected_tool_hash': hashRef(toolSelected.selected_tool),
132
+ 'mcp.manager.candidate_tool_count_bucket': countBucket(toolSelected.candidate_tool_count),
133
+ 'mcp.manager.expanded_tool_count': toolSelected.expanded_tool_count,
134
+ 'mcp.manager.suppressed_tool_count_bucket': countBucket(toolSelected.suppressed_tool_count),
135
+ 'mcp.manager.selection_reason_hash': sha256(toolSelected.raw_selection_reason),
136
+ 'privacy.raw_selection_reason_recorded': false
137
+ }
138
+ },
139
+ {
140
+ trace_id: traceId,
141
+ span_id: spanId,
142
+ name: 'mcp.manager.tool_invoked',
143
+ time: toolInvoked.time,
144
+ attributes: {
145
+ 'session.id': session.session_id,
146
+ 'gen_ai.conversation.id': session.conversation_id,
147
+ 'mcp.tool.name_hash': hashRef(toolInvoked.tool),
148
+ 'mcp.tool_call.status': toolInvoked.status,
149
+ 'mcp.tool_call.result_count_bucket': countBucket(toolInvoked.result_count),
150
+ 'mcp.tool_call.latency_ms': toolInvoked.latency_ms,
151
+ 'mcp.tool_call.arguments_hash': sha256(toolInvoked.raw_arguments),
152
+ 'mcp.tool_call.result_sample_hash': sha256(toolInvoked.raw_result_sample),
153
+ 'privacy.raw_tool_arguments_recorded': false,
154
+ 'privacy.raw_tool_results_recorded': false
155
+ }
156
+ },
157
+ {
158
+ trace_id: traceId,
159
+ span_id: spanId,
160
+ name: 'mcp.manager.parent_summary.returned',
161
+ time: summaryReturned.time,
162
+ attributes: {
163
+ 'session.id': session.session_id,
164
+ 'gen_ai.conversation.id': session.conversation_id,
165
+ 'mcp.manager.summary.status': summaryReturned.status,
166
+ 'mcp.manager.summary_token_bucket': tokenBucket(summaryReturned.summary_token_count),
167
+ 'mcp.manager.parent_context_after_token_bucket': tokenBucket(summaryReturned.parent_context_token_count_after),
168
+ 'mcp.manager.summary_hash': sha256(summaryReturned.raw_summary),
169
+ 'mcp.manager.audit_gap': summaryReturned.audit_gap,
170
+ 'privacy.raw_summary_recorded': false
171
+ }
172
+ }
173
+ ];
174
+
175
+ writeFileSync(receiptPath, `${events.map((event) => JSON.stringify(event)).join('\n')}\n`);
176
+
177
+ const trace = {
178
+ resourceSpans: [
179
+ {
180
+ resource: {
181
+ attributes: attributesToOtel({
182
+ 'service.name': 'pluribus-claudekit-mcp-manager-receipt-demo',
183
+ 'service.version': '0.0.0-fixture',
184
+ 'deployment.environment.name': 'local-fixture'
185
+ })
186
+ },
187
+ scopeSpans: [
188
+ {
189
+ scope: {
190
+ name: 'pluribus.context_input_evidence.claudekit_mcp_manager_demo',
191
+ version: '0.0.0-fixture'
192
+ },
193
+ spans: [
194
+ {
195
+ traceId,
196
+ spanId,
197
+ parentSpanId: '',
198
+ name: 'agent.session.mcp.manager.subagent_boundary',
199
+ kind: 1,
200
+ startTimeUnixNano: unixNano(parentContext.time),
201
+ endTimeUnixNano: unixNano(summaryReturned.time),
202
+ attributes: attributesToOtel({
203
+ 'session.id': session.session_id,
204
+ 'gen_ai.conversation.id': session.conversation_id,
205
+ 'agent.name': session.agent,
206
+ 'workspace.name': session.workspace,
207
+ 'gen_ai.request.model': session.model,
208
+ 'mcp.manager.pattern': parentContext.pattern,
209
+ 'mcp.manager.receipt.scope': 'parent_vs_manager_subagent_context_budget'
210
+ }),
211
+ events: events.map((event) => ({
212
+ name: event.name,
213
+ timeUnixNano: unixNano(event.time),
214
+ attributes: attributesToOtel(event.attributes)
215
+ }))
216
+ }
217
+ ]
218
+ }
219
+ ]
220
+ }
221
+ ]
222
+ };
223
+
224
+ writeFileSync(tracePath, `${JSON.stringify(trace, null, 2)}\n`);
225
+
226
+ const forbiddenRawStrings = [
227
+ 'Acme-Co',
228
+ 'sk_live_parent_fixture',
229
+ 'sk_live_manager_fixture',
230
+ 'finance@acme.example',
231
+ 'private-enterprise-mcp',
232
+ 'support.ticket.search',
233
+ 'TICKET-private-002',
234
+ 'Stripe prod incident',
235
+ 'billing account 4242'
236
+ ];
237
+
238
+ const publicOutputs = `${readFileSync(receiptPath, 'utf8')}\n${readFileSync(tracePath, 'utf8')}`;
239
+ const leaked = forbiddenRawStrings.filter((value) => publicOutputs.includes(value));
240
+ if (leaked.length > 0) {
241
+ throw new Error(`Receipt/trace leaked raw fixture strings: ${leaked.join(', ')}`);
242
+ }
243
+
244
+ console.log(JSON.stringify({
245
+ input: inputPath,
246
+ receipt: receiptPath,
247
+ trace: tracePath,
248
+ events: events.length,
249
+ selectedToolExpandedCount: toolSelected.expanded_tool_count,
250
+ suppressedToolCount: toolSelected.suppressed_tool_count,
251
+ parentFullSchemasLoaded: false,
252
+ forbiddenRawStringsChecked: forbiddenRawStrings.length
253
+ }, null, 2));
@@ -0,0 +1,251 @@
1
+ #!/usr/bin/env node
2
+ import { createHash } from 'node:crypto';
3
+ import { readFileSync, writeFileSync } from 'node:fs';
4
+ import { dirname, 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-cli-progressive-disclosure-log.jsonl');
9
+ const receiptPath = process.argv[3] ? resolve(process.argv[3]) : join(here, 'cli-progressive-disclosure-receipt.ndjson');
10
+ const tracePath = process.argv[4] ? resolve(process.argv[4]) : join(here, 'cli-progressive-disclosure-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 tokenBucket(value) {
51
+ if (value < 100) return 'under_100';
52
+ if (value < 1_000) return 'under_1k';
53
+ if (value < 10_000) return 'under_10k';
54
+ if (value < 50_000) return 'under_50k';
55
+ return 'over_50k';
56
+ }
57
+
58
+ function byteBucket(value) {
59
+ if (value === 0) return 'zero';
60
+ if (value < 1_000) return 'under_1kb';
61
+ if (value < 10_000) return 'under_10kb';
62
+ if (value < 100_000) return 'under_100kb';
63
+ return 'over_100kb';
64
+ }
65
+
66
+ function countBucket(value) {
67
+ if (value === 0) return 'zero';
68
+ if (value <= 5) return 'under_5';
69
+ if (value <= 25) return 'under_25';
70
+ return 'over_25';
71
+ }
72
+
73
+ const records = readJsonl(inputPath);
74
+ const session = records.find((record) => record.type === 'session.start');
75
+ const prompt = records.find((record) => record.type === 'cli.agent_prompt.loaded');
76
+ const help = records.find((record) => record.type === 'cli.command_help.loaded');
77
+ const command = records.find((record) => record.type === 'cli.command.executed');
78
+ const completed = records.find((record) => record.type === 'cli.session.completed');
79
+
80
+ if (!session || !prompt || !help || !command || !completed) {
81
+ throw new Error(`Expected session.start, cli.agent_prompt.loaded, cli.command_help.loaded, cli.command.executed, and cli.session.completed records in ${inputPath}`);
82
+ }
83
+
84
+ const traceSeed = `${session.session_id}:${session.conversation_id}:cli-progressive-disclosure`;
85
+ const traceId = sha256(traceSeed).replace('sha256:', '').slice(0, 32);
86
+ const spanId = sha256(`${traceSeed}:span`).replace('sha256:', '').slice(0, 16);
87
+
88
+ const events = [
89
+ {
90
+ trace_id: traceId,
91
+ span_id: spanId,
92
+ name: 'cli.agent_prompt.loaded',
93
+ time: prompt.time,
94
+ attributes: {
95
+ 'session.id': session.session_id,
96
+ 'gen_ai.conversation.id': session.conversation_id,
97
+ 'agent.name': session.agent,
98
+ 'cli.name': prompt.cli_name,
99
+ 'cli.prompt.command_hash': hashRef(prompt.prompt_command),
100
+ 'cli.prompt.hash': sha256(prompt.raw_prompt),
101
+ 'cli.prompt.token_count_bucket': tokenBucket(prompt.prompt_token_count),
102
+ 'cli.full_openapi.token_count_bucket': tokenBucket(prompt.full_openapi_token_count),
103
+ 'cli.full_mcp_schema.token_count_bucket': tokenBucket(prompt.full_mcp_schema_token_count),
104
+ 'cli.startup.strategy': prompt.startup_strategy,
105
+ 'cli.install.target': prompt.install_target,
106
+ 'privacy.raw_agent_prompt_recorded': false,
107
+ 'privacy.raw_openapi_recorded': false,
108
+ 'privacy.raw_mcp_schemas_recorded': false
109
+ }
110
+ },
111
+ {
112
+ trace_id: traceId,
113
+ span_id: spanId,
114
+ name: 'cli.command_help.loaded',
115
+ time: help.time,
116
+ attributes: {
117
+ 'session.id': session.session_id,
118
+ 'gen_ai.conversation.id': session.conversation_id,
119
+ 'cli.name': help.cli_name,
120
+ 'cli.command.hash': hashRef(help.command),
121
+ 'cli.help.command_hash': hashRef(help.help_command),
122
+ 'cli.help.hash': sha256(help.raw_help),
123
+ 'cli.help.token_count_bucket': tokenBucket(help.help_token_count),
124
+ 'cli.help.load_reason_hash': hashRef(help.selection_reason),
125
+ 'cli.unselected_commands.hash': sha256(help.unselected_commands.join('\n')),
126
+ 'cli.unselected_help.loaded_count': help.unselected_help_loaded,
127
+ 'privacy.raw_help_recorded': false,
128
+ 'privacy.raw_unselected_commands_recorded': false
129
+ }
130
+ },
131
+ {
132
+ trace_id: traceId,
133
+ span_id: spanId,
134
+ name: 'cli.command.executed',
135
+ time: command.time,
136
+ attributes: {
137
+ 'session.id': session.session_id,
138
+ 'gen_ai.conversation.id': session.conversation_id,
139
+ 'cli.name': command.cli_name,
140
+ 'cli.command.hash': hashRef(command.command),
141
+ 'cli.command.status': command.status,
142
+ 'cli.command.arguments_hash': sha256(command.raw_arguments),
143
+ 'cli.command.result_sample_hash': sha256(command.raw_result_sample),
144
+ 'cli.command.result_count_bucket': countBucket(command.result_count),
145
+ 'cli.command.latency_ms': command.latency_ms,
146
+ 'cli.command.stdout_size_bucket': byteBucket(command.stdout_bytes),
147
+ 'cli.command.stderr_size_bucket': byteBucket(command.stderr_bytes),
148
+ 'privacy.raw_arguments_recorded': false,
149
+ 'privacy.raw_results_recorded': false
150
+ }
151
+ },
152
+ {
153
+ trace_id: traceId,
154
+ span_id: spanId,
155
+ name: 'cli.session.completed',
156
+ time: completed.time,
157
+ attributes: {
158
+ 'session.id': session.session_id,
159
+ 'gen_ai.conversation.id': session.conversation_id,
160
+ 'cli.session.status': completed.status,
161
+ 'cli.commands.executed': completed.commands_executed,
162
+ 'cli.command_help.loaded_count': completed.loaded_command_help_count,
163
+ 'cli.full_openapi.loaded': completed.loaded_full_openapi,
164
+ 'cli.full_mcp_schemas.loaded': completed.loaded_mcp_schemas,
165
+ 'cli.progressive_disclosure.audit_gap': completed.audit_gap
166
+ }
167
+ }
168
+ ];
169
+
170
+ writeFileSync(receiptPath, `${events.map((event) => JSON.stringify(event)).join('\n')}\n`);
171
+
172
+ const trace = {
173
+ resourceSpans: [
174
+ {
175
+ resource: {
176
+ attributes: attributesToOtel({
177
+ 'service.name': 'pluribus-cli-progressive-disclosure-receipt-demo',
178
+ 'service.version': '0.0.0-fixture',
179
+ 'deployment.environment.name': 'local-fixture'
180
+ })
181
+ },
182
+ scopeSpans: [
183
+ {
184
+ scope: {
185
+ name: 'pluribus.context_input_evidence.cli_progressive_disclosure_demo',
186
+ version: '0.0.0-fixture'
187
+ },
188
+ spans: [
189
+ {
190
+ traceId,
191
+ spanId,
192
+ parentSpanId: '',
193
+ name: 'agent.session.cli.progressive_disclosure',
194
+ kind: 1,
195
+ startTimeUnixNano: unixNano(prompt.time),
196
+ endTimeUnixNano: unixNano(completed.time),
197
+ attributes: attributesToOtel({
198
+ 'session.id': session.session_id,
199
+ 'gen_ai.conversation.id': session.conversation_id,
200
+ 'agent.name': session.agent,
201
+ 'workspace.name': session.workspace,
202
+ 'gen_ai.request.model': session.model,
203
+ 'cli.name': prompt.cli_name,
204
+ 'cli.disclosure.strategy': 'agent_prompt_then_command_help'
205
+ }),
206
+ events: events.map((event) => ({
207
+ name: event.name,
208
+ timeUnixNano: unixNano(event.time),
209
+ attributes: attributesToOtel(event.attributes)
210
+ }))
211
+ }
212
+ ]
213
+ }
214
+ ]
215
+ }
216
+ ]
217
+ };
218
+
219
+ writeFileSync(tracePath, `${JSON.stringify(trace, null, 2)}\n`);
220
+
221
+ const forbiddenRawStrings = [
222
+ 'Acme-Co',
223
+ 'private payroll sync payloads',
224
+ 'private-checkout-api',
225
+ 'sk_live_private_fixture',
226
+ 'cus_private_001',
227
+ 'finance@acme.example',
228
+ 'Stripe prod incident',
229
+ 'conn_acme_private'
230
+ ];
231
+ const exportedText = `${events.map((event) => JSON.stringify(event)).join('\n')}\n${JSON.stringify(trace)}`;
232
+ const rawTextCopiedToReceipt = forbiddenRawStrings.some((value) => exportedText.includes(value));
233
+
234
+ const summary = {
235
+ schema: 'pluribus.cliProgressiveDisclosureReceipt.demo.v0',
236
+ eventCount: events.length,
237
+ startupPromptTokenBucket: events[0].attributes['cli.prompt.token_count_bucket'],
238
+ fullOpenApiTokenBucket: events[0].attributes['cli.full_openapi.token_count_bucket'],
239
+ fullMcpSchemaTokenBucket: events[0].attributes['cli.full_mcp_schema.token_count_bucket'],
240
+ loadedCommandHelpCount: completed.loaded_command_help_count,
241
+ loadedFullOpenApi: completed.loaded_full_openapi,
242
+ loadedFullMcpSchemas: completed.loaded_mcp_schemas,
243
+ includesArgumentsHash: Boolean(events[2].attributes['cli.command.arguments_hash']),
244
+ includesResultSampleHash: Boolean(events[2].attributes['cli.command.result_sample_hash']),
245
+ rawTextCopiedToReceipt,
246
+ receiptPath: 'examples/context-input-evidence/cli-progressive-disclosure-receipt.ndjson',
247
+ tracePath: 'examples/context-input-evidence/cli-progressive-disclosure-otel-trace.json',
248
+ lesson: 'CLI progressive disclosure still needs receipts: prove a tiny agent prompt loaded, exactly one command help expanded, one command ran, and private arguments/results stayed out of the trace.'
249
+ };
250
+
251
+ console.log(JSON.stringify(summary, null, 2));