pluribus-context 0.3.35 → 0.3.36

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 (58) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +1 -1
  3. package/bin/pluribus.js +12 -0
  4. package/docs/agent-firewall-denial-audit.md +95 -0
  5. package/docs/ai-pr-review-receipts.md +20 -0
  6. package/docs/compaction-resume-receipts.md +43 -0
  7. package/docs/controlled-learning-queue.md +48 -0
  8. package/docs/install-plan-receipts.md +2 -0
  9. package/docs/loaded-resource-boundary.md +97 -0
  10. package/docs/memory-write-policy-receipts.md +41 -0
  11. package/docs/parallel-session-review-ledger.md +103 -0
  12. package/docs/phase-boundary-contracts.md +87 -0
  13. package/docs/review-primitive-gate.md +2 -0
  14. package/docs/skill-install-receipts.md +102 -0
  15. package/docs/skill-use-rate-receipts.md +104 -0
  16. package/examples/agent-firewall-denial-audit/README.md +14 -0
  17. package/examples/agent-firewall-denial-audit/check-denial-audit.mjs +116 -0
  18. package/examples/agent-firewall-denial-audit/denial-envelope.json +9 -0
  19. package/examples/agent-firewall-denial-audit/operator-audit-record.json +20 -0
  20. package/examples/ai-pr-review-receipts/.github/workflows/ai-pr-review-receipt.yml +25 -0
  21. package/examples/ai-pr-review-receipts/README.md +51 -1
  22. package/examples/ai-pr-review-receipts/incomplete-review-primitive-receipt.json +43 -0
  23. package/examples/ai-pr-review-receipts/review-primitive-receipt.json +60 -0
  24. package/examples/compaction-resume-receipts/README.md +12 -0
  25. package/examples/compaction-resume-receipts/check-resume-receipt.mjs +116 -0
  26. package/examples/compaction-resume-receipts/safe-resume-receipt.json +52 -0
  27. package/examples/compaction-resume-receipts/unsafe-resume-receipt.json +41 -0
  28. package/examples/controlled-learning-queue/README.md +26 -0
  29. package/examples/controlled-learning-queue/check-learning-queue.mjs +44 -0
  30. package/examples/controlled-learning-queue/leads/acme-job-card.md +12 -0
  31. package/examples/controlled-learning-queue/learning_queue.md +27 -0
  32. package/examples/controlled-learning-queue/memory/durable.md +10 -0
  33. package/examples/controlled-learning-queue/memory/working-notes.md +5 -0
  34. package/examples/controlled-learning-queue/role/job-contract.md +18 -0
  35. package/examples/controlled-learning-queue/skills/qualify-lead.md +17 -0
  36. package/examples/loaded-resource-boundary/README.md +22 -0
  37. package/examples/loaded-resource-boundary/check-loaded-resource-boundary.mjs +65 -0
  38. package/examples/loaded-resource-boundary/loaded-resource-boundary.json +69 -0
  39. package/examples/memory-write-policy/README.md +28 -0
  40. package/examples/memory-write-policy/approved-memory-update.json +48 -0
  41. package/examples/memory-write-policy/check-memory-update.mjs +120 -0
  42. package/examples/memory-write-policy/quarantined-memory-update.json +43 -0
  43. package/examples/parallel-session-review-ledger/README.md +13 -0
  44. package/examples/parallel-session-review-ledger/check-parallel-session-review-ledger.mjs +69 -0
  45. package/examples/parallel-session-review-ledger/parallel-session-review-ledger.json +72 -0
  46. package/examples/phase-boundary-contract/README.md +23 -0
  47. package/examples/phase-boundary-contract/check-phase-boundary.mjs +73 -0
  48. package/examples/phase-boundary-contract/phase-boundary-contract.json +68 -0
  49. package/examples/skill-install-receipts/README.md +31 -0
  50. package/examples/skill-install-receipts/check-skill-install-receipt.mjs +75 -0
  51. package/examples/skill-install-receipts/skill-install-receipt.json +79 -0
  52. package/examples/skill-use-rate-receipts/README.md +16 -0
  53. package/examples/skill-use-rate-receipts/check-skill-use-rate.mjs +89 -0
  54. package/examples/skill-use-rate-receipts/skill-use-rate-receipt.json +79 -0
  55. package/package.json +1 -1
  56. package/src/commands/demo.js +155 -0
  57. package/src/index.js +1 -0
  58. package/src/utils/version.js +1 -1
@@ -0,0 +1,116 @@
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-resume-receipt.mjs <compaction-resume-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.compaction_resume_receipt.v1') {
23
+ errors.push('type must be agent.compaction_resume_receipt.v1')
24
+ }
25
+
26
+ for (const key of ['compaction_event_id', 'session_id', 'trigger']) {
27
+ if (!receipt[key] || typeof receipt[key] !== 'string') {
28
+ errors.push(`${key} is required`)
29
+ }
30
+ }
31
+
32
+ const transcript = receipt.transcript || {}
33
+ if (!transcript.range || typeof transcript.range !== 'string') {
34
+ errors.push('transcript.range is required')
35
+ }
36
+ if (!transcript.content_hash || typeof transcript.content_hash !== 'string') {
37
+ errors.push('transcript.content_hash is required; do not log raw transcript text')
38
+ }
39
+ if (transcript.raw_text_logged !== false) {
40
+ errors.push('transcript.raw_text_logged must be false')
41
+ }
42
+
43
+ const summary = receipt.summary || {}
44
+ if (!summary.content_hash || typeof summary.content_hash !== 'string') {
45
+ errors.push('summary.content_hash is required')
46
+ }
47
+ if (!Number.isInteger(summary.token_count) || summary.token_count <= 0) {
48
+ errors.push('summary.token_count must be a positive integer')
49
+ }
50
+
51
+ const reloads = Array.isArray(receipt.instruction_sources_reloaded)
52
+ ? receipt.instruction_sources_reloaded
53
+ : []
54
+ if (reloads.length === 0) {
55
+ errors.push('instruction_sources_reloaded must include at least one source')
56
+ }
57
+ for (const [index, source] of reloads.entries()) {
58
+ if (!source.kind || typeof source.kind !== 'string') {
59
+ errors.push(`instruction_sources_reloaded[${index}].kind is required`)
60
+ }
61
+ if (!source.ref || typeof source.ref !== 'string') {
62
+ errors.push(`instruction_sources_reloaded[${index}].ref is required`)
63
+ }
64
+ if (!source.content_hash || typeof source.content_hash !== 'string') {
65
+ errors.push(`instruction_sources_reloaded[${index}].content_hash is required`)
66
+ }
67
+ if (source.raw_body_logged !== false) {
68
+ errors.push(`instruction_sources_reloaded[${index}].raw_body_logged must be false`)
69
+ }
70
+ }
71
+
72
+ const state = receipt.state || {}
73
+ const kept = Array.isArray(state.kept) ? state.kept : []
74
+ const lost = Array.isArray(state.lost) ? state.lost : []
75
+ if (kept.length === 0) {
76
+ warnings.push('state.kept is empty; reviewers may not know what survived compaction')
77
+ }
78
+ if (!Array.isArray(state.lost)) {
79
+ errors.push('state.lost must be an array, even when empty')
80
+ }
81
+
82
+ const verdict = receipt.resume_verdict || {}
83
+ if (!['true', 'false', 'unknown'].includes(String(verdict.safe_to_resume))) {
84
+ errors.push('resume_verdict.safe_to_resume must be true, false, or unknown')
85
+ }
86
+ if (!Array.isArray(verdict.reasons) || verdict.reasons.length === 0) {
87
+ errors.push('resume_verdict.reasons must explain the verdict')
88
+ }
89
+ if (String(verdict.safe_to_resume) !== 'true') {
90
+ errors.push(`safe_to_resume is ${verdict.safe_to_resume}; stop, reload, or ask before continuing`)
91
+ }
92
+ if (lost.some((item) => item && item.blocks_resume === true)) {
93
+ errors.push('state.lost contains at least one blocks_resume=true item')
94
+ }
95
+
96
+ const privacy = receipt.privacy || {}
97
+ for (const key of ['raw_prompts_logged', 'raw_tool_output_logged', 'secrets_logged', 'full_instruction_bodies_logged']) {
98
+ if (privacy[key] !== false) {
99
+ errors.push(`privacy.${key} must be false`)
100
+ }
101
+ }
102
+
103
+ const result = {
104
+ ok: errors.length === 0,
105
+ file,
106
+ compaction_event_id: receipt.compaction_event_id,
107
+ session_id: receipt.session_id,
108
+ safe_to_resume: verdict.safe_to_resume,
109
+ reloaded_sources: reloads.map((source) => `${source.kind}:${source.ref}`),
110
+ lost: lost.map((item) => item.ref || item.kind || 'unknown'),
111
+ errors,
112
+ warnings
113
+ }
114
+
115
+ console.log(JSON.stringify(result, null, 2))
116
+ process.exit(result.ok ? 0 : 1)
@@ -0,0 +1,52 @@
1
+ {
2
+ "type": "agent.compaction_resume_receipt.v1",
3
+ "compaction_event_id": "compact-2026-06-01T15-02-59Z",
4
+ "session_id": "codex-session-42",
5
+ "trigger": "PostCompact",
6
+ "transcript": {
7
+ "range": "messages:1-184",
8
+ "content_hash": "sha256-7f8f6fbf8a3e3fe0e9f6b59efac0e771d8f64a9ebff3e9b0f5162e43c2e3e89a",
9
+ "raw_text_logged": false
10
+ },
11
+ "summary": {
12
+ "content_hash": "sha256-8a4f6242e9800f1452bcfd5dbec7e9f1f0b543d72b0c96e57dece44f6c4b8de4",
13
+ "token_count": 1240
14
+ },
15
+ "instruction_sources_reloaded": [
16
+ {
17
+ "kind": "AGENTS.md",
18
+ "ref": "repo-root/AGENTS.md",
19
+ "content_hash": "sha256-06c39dfb1ba74f5ac6f0e1a6d6b4c65358c3f1a872e96f3fe8d61da947caa1d4",
20
+ "mtime": "2026-06-01T14:58:02Z",
21
+ "raw_body_logged": false
22
+ },
23
+ {
24
+ "kind": "plan",
25
+ "ref": "memory/current-plan.md#active",
26
+ "content_hash": "sha256-a9b30f8a50dd31ec3c818c9c0d05282bf97f54991a4032f2d547a30174de1c61",
27
+ "mtime": "2026-06-01T14:59:44Z",
28
+ "raw_body_logged": false
29
+ }
30
+ ],
31
+ "state": {
32
+ "kept": [
33
+ { "kind": "active_plan", "ref": "plan:fix-auth-smoke", "summary_hash": "sha256-4c0f7fd0a72b8cf7e45c0fb97b893590fa12e931f914a34b94756de0d876182c" },
34
+ { "kind": "open_diff", "ref": "git:working-tree", "summary_hash": "sha256-2e5a0da4b6b4e9d07f11c8f10f332fc74497ef6d052a46997c4f5d0bdb0e1b07" }
35
+ ],
36
+ "lost": []
37
+ },
38
+ "resume_verdict": {
39
+ "safe_to_resume": true,
40
+ "reasons": [
41
+ "instruction sources reloaded with hashes",
42
+ "active plan and open diff summarized",
43
+ "no blocking lost fields recorded"
44
+ ]
45
+ },
46
+ "privacy": {
47
+ "raw_prompts_logged": false,
48
+ "raw_tool_output_logged": false,
49
+ "secrets_logged": false,
50
+ "full_instruction_bodies_logged": false
51
+ }
52
+ }
@@ -0,0 +1,41 @@
1
+ {
2
+ "type": "agent.compaction_resume_receipt.v1",
3
+ "compaction_event_id": "compact-2026-06-01T15-02-59Z",
4
+ "session_id": "codex-session-42",
5
+ "trigger": "PostCompact",
6
+ "transcript": {
7
+ "range": "messages:1-184",
8
+ "content_hash": "sha256-7f8f6fbf8a3e3fe0e9f6b59efac0e771d8f64a9ebff3e9b0f5162e43c2e3e89a",
9
+ "raw_text_logged": true
10
+ },
11
+ "summary": {
12
+ "content_hash": "sha256-8a4f6242e9800f1452bcfd5dbec7e9f1f0b543d72b0c96e57dece44f6c4b8de4",
13
+ "token_count": 880
14
+ },
15
+ "instruction_sources_reloaded": [
16
+ {
17
+ "kind": "AGENTS.md",
18
+ "ref": "repo-root/AGENTS.md",
19
+ "content_hash": "",
20
+ "mtime": "2026-06-01T14:58:02Z",
21
+ "raw_body_logged": true
22
+ }
23
+ ],
24
+ "state": {
25
+ "kept": [],
26
+ "lost": [
27
+ { "kind": "rejected_decisions", "ref": "decision-log:missing", "blocks_resume": true },
28
+ { "kind": "pending_tests", "ref": "test-plan:unknown", "blocks_resume": true }
29
+ ]
30
+ },
31
+ "resume_verdict": {
32
+ "safe_to_resume": "unknown",
33
+ "reasons": ["AGENTS.md hash missing and blocking state was lost"]
34
+ },
35
+ "privacy": {
36
+ "raw_prompts_logged": true,
37
+ "raw_tool_output_logged": false,
38
+ "secrets_logged": false,
39
+ "full_instruction_bodies_logged": true
40
+ }
41
+ }
@@ -0,0 +1,26 @@
1
+ # Controlled learning queue example
2
+
3
+ A copyable layout for Claude Code/OpenClaw/Cursor-style "AI employee" agents that use a role file, Skills, memory, and external tools.
4
+
5
+ The pattern is simple:
6
+
7
+ - `role/job-contract.md` defines what the agent is allowed to do.
8
+ - `skills/*.md` define procedures with inputs, outputs, and stop conditions.
9
+ - `memory/durable.md` contains approved facts only.
10
+ - `memory/working-notes.md` can hold temporary observations.
11
+ - `learning_queue.md` is where the agent proposes durable memory changes as reviewable diffs.
12
+ - `leads/*.md` are tiny active job cards.
13
+
14
+ Run the smoke check:
15
+
16
+ ```bash
17
+ node check-learning-queue.mjs learning_queue.md
18
+ ```
19
+
20
+ Expected output:
21
+
22
+ ```text
23
+ learning queue ok: 2 proposal(s), 1 pending review
24
+ ```
25
+
26
+ Why it exists: agents can learn from outcomes, but durable cross-run memory should not be rewritten by one edge case without source, scope, expiry, and a promote/reject decision.
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs';
3
+
4
+ const file = process.argv[2] || new URL('./learning_queue.md', import.meta.url).pathname;
5
+ const text = fs.readFileSync(file, 'utf8');
6
+ const proposals = text.split(/^## Proposal /m).slice(1);
7
+ const required = ['Status', 'Source', 'Observed', 'Proposed durable change', 'Reason', 'Scope', 'Expiry', 'Reviewer', 'Decision'];
8
+ const rawRisk = /(api[_-]?key|secret|password|token\s*[:=]|-----BEGIN|raw transcript|verbatim customer|full email)/i;
9
+ const errors = [];
10
+ let pending = 0;
11
+
12
+ if (proposals.length === 0) errors.push('missing proposals');
13
+
14
+ for (const [index, block] of proposals.entries()) {
15
+ const id = block.split('\n', 1)[0].trim() || `#${index + 1}`;
16
+ for (const field of required) {
17
+ if (!new RegExp(`^${field}:\\s*\\S`, 'mi').test(block)) {
18
+ errors.push(`${id}: missing ${field}`);
19
+ }
20
+ }
21
+
22
+ const status = block.match(/^Status:\s*(.+)$/mi)?.[1]?.trim().toLowerCase();
23
+ const reviewer = block.match(/^Reviewer:\s*(.+)$/mi)?.[1]?.trim().toLowerCase();
24
+ const decision = block.match(/^Decision:\s*(.+)$/mi)?.[1]?.trim().toLowerCase();
25
+
26
+ if (status === 'proposed') pending += 1;
27
+ if (status === 'promoted' && (!reviewer || reviewer === 'pending' || !decision || decision === 'pending')) {
28
+ errors.push(`${id}: promoted proposal needs reviewer and decision`);
29
+ }
30
+ if (/(auto-promote|autopromote|self-approved|self approved)/i.test(block)) {
31
+ errors.push(`${id}: auto-promotion is not allowed`);
32
+ }
33
+ if (rawRisk.test(block)) {
34
+ errors.push(`${id}: possible raw secret/private payload in learning queue`);
35
+ }
36
+ }
37
+
38
+ if (errors.length) {
39
+ console.error(`learning queue failed (${errors.length}):`);
40
+ for (const error of errors) console.error(`- ${error}`);
41
+ process.exit(1);
42
+ }
43
+
44
+ console.log(`learning queue ok: ${proposals.length} proposal(s), ${pending} pending review`);
@@ -0,0 +1,12 @@
1
+ # Lead job card: acme
2
+
3
+ ## Goal
4
+ Prepare a qualification summary for a human owner.
5
+
6
+ ## Known facts
7
+ - Source: demo form `lead-acme-2026-06-02`.
8
+ - Interest: AI agent workflows for sales operations.
9
+ - Constraint: no pricing promises without human owner.
10
+
11
+ ## Next safe action
12
+ Draft questions about current workflow, systems of record, and approval boundaries.
@@ -0,0 +1,27 @@
1
+ # Learning queue
2
+
3
+ Agents may propose durable memory updates here. Humans or maintainers promote/reject them.
4
+
5
+ ## Proposal 2026-06-02-001
6
+
7
+ Status: proposed
8
+ Source: lead-acme-2026-06-02 job card, redacted summary only
9
+ Observed: Prospect asked how to prevent a role-based agent from changing ICP after one edge case.
10
+ Proposed durable change: Add "role-based agents may propose ICP changes, but ICP memory changes require human promote/reject review" to `memory/durable.md`.
11
+ Reason: This is a reusable safety boundary for future lead qualification runs.
12
+ Scope: sales-ops-agent / ICP memory
13
+ Expiry: 2026-07-02
14
+ Reviewer: pending
15
+ Decision: pending
16
+
17
+ ## Proposal 2026-06-02-002
18
+
19
+ Status: rejected
20
+ Source: lead-beta-2026-06-01 job card, redacted summary only
21
+ Observed: One prospect wanted a custom discount workflow.
22
+ Proposed durable change: Add "discount requests are common" to `memory/durable.md`.
23
+ Reason: Rejected because one request is not enough to change durable market assumptions.
24
+ Scope: sales-ops-agent / pricing assumptions
25
+ Expiry: 2026-06-15
26
+ Reviewer: owner@example.invalid
27
+ Decision: reject; keep as working note only
@@ -0,0 +1,10 @@
1
+ # Durable memory
2
+
3
+ Approved facts only.
4
+
5
+ ## ICP
6
+ - Early-stage teams adopting AI coding agents need lightweight reviewable context, not another opaque memory dump.
7
+
8
+ ## Boundaries
9
+ - Do not store raw customer messages, secrets, or private transcripts.
10
+ - Pricing, legal commitments, and delivery promises require human review.
@@ -0,0 +1,5 @@
1
+ # Working notes
2
+
3
+ Temporary notes may live here during an active job. Promote nothing from this file into durable memory without a `learning_queue.md` proposal.
4
+
5
+ - 2026-06-02 lead-acme: asked about using Skills for sales ops. Needs human review before any pricing language.
@@ -0,0 +1,18 @@
1
+ # Sales ops agent role
2
+
3
+ ## Mission
4
+ Help qualify inbound leads and prepare concise handoff notes for a human owner.
5
+
6
+ ## Allowed
7
+ - Read approved lead/job cards.
8
+ - Draft next-step suggestions.
9
+ - Propose changes to durable memory through `learning_queue.md`.
10
+
11
+ ## Not allowed
12
+ - Promise pricing, discounts, contracts, legal terms, or delivery dates.
13
+ - Rewrite `memory/durable.md` directly.
14
+ - Store raw private email/chat text in durable memory.
15
+
16
+ ## Escalate when
17
+ - A lead asks for legal/financial commitments.
18
+ - A proposed learning would change ICP, pricing assumptions, compliance boundaries, or data-retention rules.
@@ -0,0 +1,17 @@
1
+ # Skill: qualify lead
2
+
3
+ ## Inputs
4
+ - Lead job card path.
5
+ - Current durable memory.
6
+ - Any approved working notes for this lead.
7
+
8
+ ## Output
9
+ - Qualification summary.
10
+ - Open questions.
11
+ - Suggested next action.
12
+ - Optional `learning_queue.md` proposal if the case reveals a reusable durable fact.
13
+
14
+ ## Stop conditions
15
+ - Missing consent or unclear data source.
16
+ - Request requires a human commitment.
17
+ - Proposed durable learning lacks source, scope, or expiry.
@@ -0,0 +1,22 @@
1
+ # Loaded-resource boundary example
2
+
3
+ This example turns "my Skill works in chat but disappears in ACP/Zed/CLI" into a stage-level receipt.
4
+
5
+ Run:
6
+
7
+ ```bash
8
+ node check-loaded-resource-boundary.mjs loaded-resource-boundary.json
9
+ ```
10
+
11
+ Expected output:
12
+
13
+ ```text
14
+ loaded-resource boundary ok: 1 required resource/runtime gap recorded
15
+ ```
16
+
17
+ The sample records the same project skills across two sessions:
18
+
19
+ - `chat` discovers, attaches, injects, and reads `skill:pr-review`;
20
+ - `acp`/`zed` discovers and attaches it, but never injects it, so the receipt records `runtime_does_not_inject_resources` and sets `safe_to_continue=false`.
21
+
22
+ Use this shape when prompt instructions cannot explain a missing Skill. The host/runtime needs to prove the resource crossed the boundary, not merely that it exists on disk.
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs';
3
+
4
+ const file = process.argv[2] ?? new URL('./loaded-resource-boundary.json', import.meta.url);
5
+ const receipt = JSON.parse(fs.readFileSync(file, 'utf8'));
6
+ const fail = (message) => {
7
+ console.error(`loaded-resource boundary invalid: ${message}`);
8
+ process.exit(1);
9
+ };
10
+
11
+ if (receipt.receipt_type !== 'pluribus.loaded_resource_boundary.v1') fail('unexpected receipt_type');
12
+ if (!Array.isArray(receipt.expected_resources) || receipt.expected_resources.length === 0) fail('expected_resources must be non-empty');
13
+ if (!Array.isArray(receipt.sessions) || receipt.sessions.length < 2) fail('sessions must include at least two runtimes for parity checks');
14
+
15
+ const expectedIds = new Set(receipt.expected_resources.map((resource) => resource.id));
16
+ const requiredIds = new Set(receipt.expected_resources.filter((resource) => resource.required !== false).map((resource) => resource.id));
17
+ for (const resource of receipt.expected_resources) {
18
+ if (!resource.id || !resource.kind || !resource.source_ref || !resource.source_hash?.startsWith('sha256:')) {
19
+ fail(`expected resource ${resource.id ?? '<missing>'} needs id, kind, source_ref, and sha256 source_hash`);
20
+ }
21
+ }
22
+
23
+ const allowedSkipReasons = new Set([
24
+ 'not_discovered',
25
+ 'not_attached_to_agent',
26
+ 'runtime_does_not_inject_resources',
27
+ 'trigger_not_matched',
28
+ 'resource_read_failed'
29
+ ]);
30
+
31
+ let mismatches = 0;
32
+ for (const session of receipt.sessions) {
33
+ for (const key of ['runtime', 'client', 'agent']) {
34
+ if (!session[key]) fail(`session ${session.session_id ?? '<missing>'} missing ${key}`);
35
+ }
36
+ for (const listName of ['discovered_resources', 'attached_resources', 'injected_resources', 'readable_resources', 'skipped_resources']) {
37
+ if (!Array.isArray(session[listName])) fail(`${session.session_id}: ${listName} must be an array`);
38
+ }
39
+
40
+ const stageSets = {
41
+ discovered: new Set(session.discovered_resources),
42
+ attached: new Set(session.attached_resources),
43
+ injected: new Set(session.injected_resources),
44
+ readable: new Set(session.readable_resources)
45
+ };
46
+ const skipped = new Map(session.skipped_resources.map((skip) => [skip.id, skip]));
47
+
48
+ for (const id of expectedIds) {
49
+ if (stageSets.readable.has(id)) continue;
50
+ const skip = skipped.get(id);
51
+ if (!skip) {
52
+ if (requiredIds.has(id)) fail(`${session.session_id}: ${id} is required, not readable, and has no skipped_resources entry`);
53
+ continue;
54
+ }
55
+ if (!allowedSkipReasons.has(skip.reason)) fail(`${session.session_id}: ${id} has unknown skip reason ${skip.reason}`);
56
+ if (!skip.stage) fail(`${session.session_id}: ${id} skip entry needs a stage`);
57
+ if (requiredIds.has(id)) mismatches += 1;
58
+ }
59
+ }
60
+
61
+ if (receipt.safe_to_continue !== false && mismatches > 0) {
62
+ fail('safe_to_continue must be false when expected resources are missing or skipped');
63
+ }
64
+
65
+ console.log(`loaded-resource boundary ok: ${mismatches} required resource/runtime gaps recorded`);
@@ -0,0 +1,69 @@
1
+ {
2
+ "receipt_type": "pluribus.loaded_resource_boundary.v1",
3
+ "scenario": "custom-agent skill parity across chat and ACP/Zed",
4
+ "expected_resources": [
5
+ {
6
+ "id": "skill:pr-review",
7
+ "kind": "skill",
8
+ "scope": "project",
9
+ "source_ref": ".kiro/skills/pr-review/SKILL.md",
10
+ "source_hash": "sha256:7fb8c53b1b1f9b0e0f5a6fdab315b748c64c8b926fdff3d1d6fe6b3f5c8c6a01",
11
+ "required": true
12
+ },
13
+ {
14
+ "id": "skill:release-notes",
15
+ "kind": "skill",
16
+ "scope": "project",
17
+ "source_ref": ".kiro/skills/release-notes/SKILL.md",
18
+ "source_hash": "sha256:290d6bbf8d43b5b3f9134718ce9f7b6d08cc25f1a0e9255f5b8ceadcab4e6c18",
19
+ "required": false
20
+ }
21
+ ],
22
+ "sessions": [
23
+ {
24
+ "session_id": "chat-reviewer-2026-06-03",
25
+ "runtime": "chat",
26
+ "client": "kiro-desktop",
27
+ "client_version": "2.5.1",
28
+ "agent": "reviewer",
29
+ "task_hash": "sha256:9ed0fd91ef88f64a7de10e7fbab4e979ec6b13701d8a7569e3d4ad4ed9932a9a",
30
+ "discovered_resources": ["skill:pr-review", "skill:release-notes"],
31
+ "attached_resources": ["skill:pr-review", "skill:release-notes"],
32
+ "injected_resources": ["skill:pr-review"],
33
+ "readable_resources": ["skill:pr-review"],
34
+ "skipped_resources": [
35
+ {
36
+ "id": "skill:release-notes",
37
+ "stage": "injected",
38
+ "reason": "trigger_not_matched"
39
+ }
40
+ ]
41
+ },
42
+ {
43
+ "session_id": "acp-zed-reviewer-2026-06-03",
44
+ "runtime": "acp",
45
+ "client": "zed",
46
+ "client_version": "2.5.1",
47
+ "agent": "reviewer",
48
+ "task_hash": "sha256:9ed0fd91ef88f64a7de10e7fbab4e979ec6b13701d8a7569e3d4ad4ed9932a9a",
49
+ "discovered_resources": ["skill:pr-review", "skill:release-notes"],
50
+ "attached_resources": ["skill:pr-review", "skill:release-notes"],
51
+ "injected_resources": [],
52
+ "readable_resources": [],
53
+ "skipped_resources": [
54
+ {
55
+ "id": "skill:pr-review",
56
+ "stage": "injected",
57
+ "reason": "runtime_does_not_inject_resources"
58
+ },
59
+ {
60
+ "id": "skill:release-notes",
61
+ "stage": "injected",
62
+ "reason": "trigger_not_matched"
63
+ }
64
+ ]
65
+ }
66
+ ],
67
+ "safe_to_continue": false,
68
+ "next_action": "file a host/runtime bug with stage-level evidence; do not fix this with stronger prompt wording alone"
69
+ }
@@ -0,0 +1,28 @@
1
+ # Memory write policy receipt gate
2
+
3
+ Shared memory systems are useful when many agents can read the same durable facts. They become risky when every run can also write to that memory without review.
4
+
5
+ This example treats a memory write like a code change:
6
+
7
+ 1. the agent proposes a memory diff;
8
+ 2. the diff is scoped to a repo/project/org/user boundary;
9
+ 3. the source is hashed instead of copied;
10
+ 4. stale facts get an expiry or review date;
11
+ 5. future sessions can see what memory was injected;
12
+ 6. private/sensitive writes are quarantined until a human or external policy approves them.
13
+
14
+ Run the passing fixture:
15
+
16
+ ```bash
17
+ node examples/memory-write-policy/check-memory-update.mjs \
18
+ examples/memory-write-policy/approved-memory-update.json
19
+ ```
20
+
21
+ Run the failing fixture:
22
+
23
+ ```bash
24
+ node examples/memory-write-policy/check-memory-update.mjs \
25
+ examples/memory-write-policy/quarantined-memory-update.json
26
+ ```
27
+
28
+ Use this shape when evaluating cross-agent memory MCPs, knowledge graphs, or shared `CLAUDE.md`/`AGENTS.md` update flows. The point is not to store the memory body in the receipt. The point is to prove that a durable memory update had source, scope, lifecycle, visibility, approval, and privacy checks before it could teach every harness the same fact.
@@ -0,0 +1,48 @@
1
+ {
2
+ "type": "agent.memory_update_receipt.v1",
3
+ "update_id": "memupd_2026_06_01_001",
4
+ "run_id": "agent_run_8742",
5
+ "source": {
6
+ "kind": "claude-code-session",
7
+ "ref": "repo:acme/shop#issue-4812",
8
+ "content_hash": "sha256:4df7b1b9d6f4a2c51ad3e1ce761a8f0f918c9a0f4d26c4c8fd9f1e21ad1a19f4"
9
+ },
10
+ "scope": {
11
+ "kind": "repo",
12
+ "id": "acme/shop",
13
+ "path_prefix": "apps/checkout"
14
+ },
15
+ "proposed_diff": {
16
+ "adds": [
17
+ {
18
+ "memory_ref": "memory:checkout:idempotency-key-policy",
19
+ "summary_hash": "sha256:dad59f7764d0a6dd8db8f2d6f23d9dd30b3e6b1e1197d5478c05f9d093bc5fed",
20
+ "reason": "captured repo-local invariant after failing duplicate-charge test"
21
+ }
22
+ ],
23
+ "updates": [],
24
+ "supersedes": [],
25
+ "expires": []
26
+ },
27
+ "write_policy": {
28
+ "status": "approved",
29
+ "policy_ref": "repo-memory-policy:v2",
30
+ "approved_by": "maintainer:checkout-platform",
31
+ "approval_channel": "pull-request-review",
32
+ "private_or_sensitive_detected": false
33
+ },
34
+ "lifecycle": {
35
+ "review_after": "2026-07-01T00:00:00Z",
36
+ "supersedes_required": false
37
+ },
38
+ "injection_visibility": {
39
+ "next_session_visible": true,
40
+ "preview_path": ".pluribus/memory-previews/checkout-idempotency-key-policy.md"
41
+ },
42
+ "privacy": {
43
+ "raw_memory_text_logged": false,
44
+ "raw_prompts_logged": false,
45
+ "raw_tool_output_logged": false,
46
+ "secrets_logged": false
47
+ }
48
+ }