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,77 @@
1
+ ---
2
+ name: skill-policy-receipts
3
+ description: Use when a task must obey a hard project policy, such as "do not generate tests for internal services", "do not call production APIs", or "do not edit generated files". Emits a privacy-safe receipt before writes and after guard checks.
4
+ ---
5
+
6
+ # Skill Policy Receipts
7
+
8
+ This Skill turns natural-language guardrails into an inspectable policy receipt.
9
+
10
+ ## Preflight: decide before writing
11
+
12
+ Before creating or editing files:
13
+
14
+ 1. List intended targets using coarse paths or globs.
15
+ 2. For each target, decide `allowed` or `refused`.
16
+ 3. Give a short reason.
17
+ 4. If any target is refused, stop before writing.
18
+ 5. Emit a receipt with `write_started=false` and `stopped_at="policy_refused"`.
19
+
20
+ Receipt shape:
21
+
22
+ ```json
23
+ {
24
+ "receipt_type": "skill.policy.v1",
25
+ "skill": "skill-policy-receipts",
26
+ "policy_scope": "<short policy name>",
27
+ "targets": [
28
+ {
29
+ "target": "<coarse path or glob>",
30
+ "decision": "allowed|refused",
31
+ "reason": "<short reason>"
32
+ }
33
+ ],
34
+ "write_started": false,
35
+ "post_write_guard": "not_run",
36
+ "stopped_at": "policy_refused|all_targets_allowed"
37
+ }
38
+ ```
39
+
40
+ Do not include raw prompts, code, secrets, customer data, stack traces, or full tool output.
41
+
42
+ ## Write only after all targets are allowed
43
+
44
+ If every target is allowed:
45
+
46
+ 1. Emit or state `stopped_at="all_targets_allowed"`.
47
+ 2. Perform the write.
48
+ 3. Run the configured post-write guard.
49
+ 4. Emit whether the guard passed or failed.
50
+
51
+ Post-write receipt shape:
52
+
53
+ ```json
54
+ {
55
+ "receipt_type": "skill.policy.v1",
56
+ "skill": "skill-policy-receipts",
57
+ "policy_scope": "<short policy name>",
58
+ "write_started": true,
59
+ "post_write_guard": "passed|failed|not_configured",
60
+ "stopped_at": "guard_passed|guard_failed"
61
+ }
62
+ ```
63
+
64
+ ## Example policy: no internal-service unit tests
65
+
66
+ Policy:
67
+
68
+ > Do not generate unit tests for internal services. If the requested test imports `internal/`, `@/internal`, or a known private service module, refuse before writing and explain the safer target.
69
+
70
+ Example guard:
71
+
72
+ ```bash
73
+ grep -R "from ['\"]\.\./\.\./internal\|from ['\"]@/internal\|require(['\"]@/internal" \
74
+ -- '*test.*' '*spec.*'
75
+ ```
76
+
77
+ If the grep finds a match in generated tests, stop and report `post_write_guard="failed"`.
@@ -0,0 +1,31 @@
1
+ ## AI PR review receipt
2
+
3
+ This PR was prepared or modified by an AI coding agent. Review by blast radius, not by diff size alone.
4
+
5
+ ### Boundary receipt
6
+
7
+ | Boundary | Status | Evidence | Risk tier | Owner / blocker |
8
+ | --- | --- | --- | --- | --- |
9
+ | Schema / persisted data contract | `touched / not_touched / ambiguous` | | | |
10
+ | Live reader/writer compatibility | `checked / missing / n/a` | | | |
11
+ | Async jobs / queues / cron / webhooks | `touched / not_touched / ambiguous` | | | |
12
+ | Rollout gate / feature flag / kill switch | `present / missing / n/a` | | | |
13
+ | External side effects | `declared / not_touched / ambiguous` | | | |
14
+ | Generated files / public API / plugin config | `touched / not_touched / ambiguous` | | | |
15
+
16
+ ### Checks
17
+
18
+ - [ ] Tests relevant to touched boundaries passed.
19
+ - [ ] Migration/backfill/rollback behavior is explicit, or not applicable.
20
+ - [ ] External side effects are declared, or not touched.
21
+ - [ ] Any `ambiguous` boundary has an owner before merge.
22
+
23
+ ### Privacy
24
+
25
+ This receipt does not include raw prompts, transcripts, source code, secrets, customer data, stack traces, or raw tool output.
26
+
27
+ ### Decision
28
+
29
+ `merge_ready: yes/no`
30
+
31
+ `next_safe_action:`
@@ -0,0 +1,5 @@
1
+ # AI PR review receipts example
2
+
3
+ This example contains a copyable GitHub PR template for agent-generated or agent-modified pull requests.
4
+
5
+ Use it when review risk depends on blast radius: schema/data contracts, async paths, rollout gates, external side effects, generated/public interfaces, or security-sensitive config.
@@ -0,0 +1,55 @@
1
+ {
2
+ "type": "canonical.output.receipt.v1",
3
+ "artifact": {
4
+ "stable_id": "project-alpha-master-prompt-2026-05-30",
5
+ "name": "Project Alpha master prompt",
6
+ "kind": "master_prompt",
7
+ "canonical_path": "docs/prompts/project-alpha-master-prompt.md",
8
+ "current_version": "2026-05-30.1",
9
+ "content_hash": "sha256:example-only",
10
+ "status": "current",
11
+ "owner_label": "product-ops",
12
+ "created_at": "2026-05-30T21:40:00Z",
13
+ "last_reviewed_at": "2026-05-30T21:58:00Z"
14
+ },
15
+ "source": {
16
+ "workspace": "claude-project-alpha",
17
+ "source_session_id": "session-redacted-2026-05-30",
18
+ "source_tool": "claude-projects",
19
+ "source_chat_title": "Master prompt rebuild",
20
+ "source_url_or_path_redacted": true,
21
+ "raw_transcript_logged": false
22
+ },
23
+ "index": {
24
+ "exact_phrases_worth_grepping": [
25
+ "do not collapse escalation paths into summaries",
26
+ "billing exports are evidence, not source of truth",
27
+ "final prompt contract v3"
28
+ ],
29
+ "tags": ["master-prompt", "billing", "escalation", "current-state"],
30
+ "related_artifacts": ["billing-escalation-runbook-2026-05-28"]
31
+ },
32
+ "decisions": {
33
+ "accepted": [
34
+ "Use repo-owned markdown as the canonical copy, not old chats",
35
+ "Keep escalation criteria in the prompt body and test cases in a separate appendix"
36
+ ],
37
+ "rejected": [
38
+ {
39
+ "option": "Rely on Claude Project conversation search for recovery",
40
+ "reason": "exact phrase and project-scoped search were unreliable during rebuild"
41
+ }
42
+ ],
43
+ "open_questions": [
44
+ "Does support need a shorter handoff summary for weekend rotations?"
45
+ ],
46
+ "next_action": "Open a PR that adds the canonical prompt and this receipt to docs/prompts/"
47
+ },
48
+ "privacy": {
49
+ "raw_prompt_logged": false,
50
+ "raw_chat_logged": false,
51
+ "customer_data_logged": false,
52
+ "secrets_logged": false,
53
+ "proprietary_paths_logged": false
54
+ }
55
+ }
@@ -0,0 +1,74 @@
1
+ # Claude Code review hook bridge
2
+
3
+ This example wires the [review primitive gate](../review-primitive-gate/) into Claude Code hooks so a long agent run can be blocked at handoff time when the receipt says `partial` or `unsafe-to-resume`.
4
+
5
+ Use it when you already have Claude Code hooks, a local control-plane wrapper, or CI emitting `agent.review_primitive_receipt.v1` receipts and you want Claude Code to treat the receipt as a gate rather than a note.
6
+
7
+ ## Copy the hook
8
+
9
+ ```bash
10
+ mkdir -p .claude/hooks .pluribus/receipts
11
+ cp examples/claude-code-review-hook/check-review-receipt-hook.mjs .claude/hooks/
12
+ cp examples/review-primitive-gate/check-review-receipt.mjs .claude/hooks/
13
+ ```
14
+
15
+ Then add this to `.claude/settings.json`:
16
+
17
+ ```json
18
+ {
19
+ "hooks": {
20
+ "TaskCompleted": [
21
+ {
22
+ "matcher": "*",
23
+ "hooks": [
24
+ {
25
+ "type": "command",
26
+ "command": "node ${CLAUDE_PROJECT_DIR}/.claude/hooks/check-review-receipt-hook.mjs ${CLAUDE_PROJECT_DIR}/.pluribus/receipts/latest-review-receipt.json"
27
+ }
28
+ ]
29
+ }
30
+ ],
31
+ "PostCompact": [
32
+ {
33
+ "matcher": "*",
34
+ "hooks": [
35
+ {
36
+ "type": "command",
37
+ "command": "node ${CLAUDE_PROJECT_DIR}/.claude/hooks/check-review-receipt-hook.mjs ${CLAUDE_PROJECT_DIR}/.pluribus/receipts/latest-review-receipt.json"
38
+ }
39
+ ]
40
+ }
41
+ ]
42
+ }
43
+ }
44
+ ```
45
+
46
+ The same bridge can be attached to `SessionEnd` if your workflow writes the receipt only when a session exits.
47
+
48
+ ## What the hook does
49
+
50
+ Claude Code passes hook event JSON on stdin. The bridge reads that event for traceability, runs the review gate against the receipt path, and:
51
+
52
+ - exits `0` when the receipt is complete and privacy-safe;
53
+ - exits non-zero when required evidence is missing, checks failed/skipped, scope changes were unapproved, or `resume_state` is `partial` / `unsafe-to-resume`;
54
+ - prints a small JSON result that names the hook event, receipt path, and next safe action.
55
+
56
+ It does **not** log raw prompts, transcripts, tool output, source code, exact proprietary paths, secrets, or customer data.
57
+
58
+ ## Smoke test
59
+
60
+ ```bash
61
+ node examples/claude-code-review-hook/check-review-receipt-hook.mjs \
62
+ examples/review-primitive-gate/pass-review-receipt.json \
63
+ < examples/claude-code-review-hook/sample-task-completed-event.json
64
+
65
+ node examples/claude-code-review-hook/check-review-receipt-hook.mjs \
66
+ examples/review-primitive-gate/fail-review-receipt.json \
67
+ < examples/claude-code-review-hook/sample-task-completed-event.json
68
+ ```
69
+
70
+ The first command should pass. The second should fail and tell the reviewer why the handoff should not continue.
71
+
72
+ ## Why this exists
73
+
74
+ Claude Code hooks are good at triggering automation around `TaskCompleted`, `PostCompact`, and `SessionEnd`. Pluribus should not replace that control plane. This bridge makes the missing handoff proof explicit: before the next agent resumes, prove the assignment boundary, required checks, privacy flags, evidence path, and `complete / partial / unsafe-to-resume` state.
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env node
2
+ import { readFileSync } from 'node:fs'
3
+ import { spawnSync } from 'node:child_process'
4
+ import { dirname, resolve } from 'node:path'
5
+ import { fileURLToPath } from 'node:url'
6
+
7
+ const [receiptPathArg] = process.argv.slice(2)
8
+
9
+ if (!receiptPathArg) {
10
+ console.error(JSON.stringify({ ok: false, errors: ['usage: node check-review-receipt-hook.mjs <receipt.json>'] }, null, 2))
11
+ process.exit(2)
12
+ }
13
+
14
+ const stdin = readFileSync(0, 'utf8').trim()
15
+ let hookInput = {}
16
+ if (stdin) {
17
+ try {
18
+ hookInput = JSON.parse(stdin)
19
+ } catch (error) {
20
+ console.error(JSON.stringify({ ok: false, errors: [`invalid hook JSON on stdin: ${error.message}`] }, null, 2))
21
+ process.exit(2)
22
+ }
23
+ }
24
+
25
+ const here = dirname(fileURLToPath(import.meta.url))
26
+ const localGate = resolve(here, '../review-primitive-gate/check-review-receipt.mjs')
27
+ const copiedGate = resolve(here, 'check-review-receipt.mjs')
28
+ const gatePath = process.env.PLURIBUS_REVIEW_GATE || (exists(copiedGate) ? copiedGate : localGate)
29
+ const receiptPath = resolve(process.cwd(), receiptPathArg)
30
+
31
+ const result = spawnSync(process.execPath, [gatePath, receiptPath], {
32
+ encoding: 'utf8',
33
+ stdio: ['ignore', 'pipe', 'pipe']
34
+ })
35
+
36
+ let gateResult = null
37
+ try {
38
+ gateResult = JSON.parse(result.stdout || '{}')
39
+ } catch {
40
+ gateResult = { ok: false, errors: ['review gate did not return JSON'], raw_stdout: result.stdout.trim() }
41
+ }
42
+
43
+ const hookEventName = hookInput.hook_event_name || hookInput.hookEventName || hookInput.event || 'unknown'
44
+ const output = {
45
+ ok: result.status === 0 && gateResult.ok === true,
46
+ hook_event_name: hookEventName,
47
+ receipt_path: receiptPathArg,
48
+ resume_state: gateResult.resume_state,
49
+ assignment_id: gateResult.assignment_id,
50
+ run_id: gateResult.run_id,
51
+ next_safe_action: readNextSafeAction(receiptPath),
52
+ errors: gateResult.errors || [],
53
+ warnings: gateResult.warnings || []
54
+ }
55
+
56
+ if (output.ok) {
57
+ console.log(JSON.stringify(output, null, 2))
58
+ process.exit(0)
59
+ }
60
+
61
+ console.error(JSON.stringify(output, null, 2))
62
+ process.exit(result.status || 1)
63
+
64
+ function exists(path) {
65
+ try {
66
+ readFileSync(path)
67
+ return true
68
+ } catch {
69
+ return false
70
+ }
71
+ }
72
+
73
+ function readNextSafeAction(path) {
74
+ try {
75
+ const receipt = JSON.parse(readFileSync(path, 'utf8'))
76
+ return receipt?.handoff?.next_safe_action || null
77
+ } catch {
78
+ return null
79
+ }
80
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "hook_event_name": "TaskCompleted",
3
+ "session_id": "demo-session",
4
+ "transcript_path": "redacted/transcript.jsonl",
5
+ "cwd": "/repo/example"
6
+ }