@cairnkeep/cli 2.13.1 → 2.15.0

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 (70) hide show
  1. package/CHANGELOG.md +45 -1
  2. package/README.md +29 -6
  3. package/claude/commands/cairn-work.md +19 -0
  4. package/docs/context-packs.md +13 -3
  5. package/docs/design/team-mode.md +145 -0
  6. package/docs/harness-compatibility.md +12 -11
  7. package/docs/learning/CURRICULUM-MAP.md +8 -4
  8. package/docs/learning/FEATURE-GUIDE.md +13 -5
  9. package/docs/learning/README.md +3 -1
  10. package/docs/learning/lessons/L00-why-cairnkeep.md +1 -1
  11. package/docs/learning/lessons/L01-safe-trial.md +3 -3
  12. package/docs/learning/lessons/L02-installation.md +2 -2
  13. package/docs/learning/lessons/L03-first-project.md +1 -1
  14. package/docs/learning/lessons/L19-validated-skill-improvement.md +1 -1
  15. package/docs/learning/lessons/L20-mcp-tool-profiles.md +1 -1
  16. package/docs/learning/lessons/L21-context-packs.md +5 -1
  17. package/docs/learning/lessons/L22-native-windows.md +2 -2
  18. package/docs/learning/lessons/L23-guided-setup.md +2 -2
  19. package/docs/learning/lessons/L24-okf-exchange.md +111 -0
  20. package/docs/learning/lessons/L25-playbooks.md +114 -0
  21. package/docs/learning/tracks/operator.md +8 -2
  22. package/docs/learning/tracks/practitioner.md +5 -3
  23. package/docs/learning/video-scripts/V24-okf-exchange.md +31 -0
  24. package/docs/learning/video-scripts/V25-playbooks.md +38 -0
  25. package/docs/native-windows.md +12 -0
  26. package/docs/open-knowledge-format.md +100 -0
  27. package/docs/operating.md +68 -0
  28. package/docs/privacy-and-data-flow.md +25 -0
  29. package/docs/quickstart.md +17 -1
  30. package/docs/storage.md +28 -0
  31. package/examples/eval/bundled-fake.json +1 -1
  32. package/kimi/skills/cairn-work/SKILL.md +13 -0
  33. package/mcp-memory-server/dist/context-pack-cli.js +54 -1
  34. package/mcp-memory-server/dist/context-pack.js +243 -47
  35. package/mcp-memory-server/dist/index.js +13 -1
  36. package/mcp-memory-server/dist/mcp-tool-catalog.js +1 -0
  37. package/mcp-memory-server/dist/note-store.js +44 -2
  38. package/mcp-memory-server/dist/okf.js +432 -0
  39. package/mcp-memory-server/dist/playbook-cli.js +321 -0
  40. package/mcp-memory-server/dist/playbook-receipt.js +245 -0
  41. package/mcp-memory-server/dist/playbook-schema.js +56 -0
  42. package/mcp-memory-server/dist/playbook.js +383 -0
  43. package/mcp-memory-server/package.json +4 -1
  44. package/opencode/command/cairn-work.md +13 -0
  45. package/package.json +2 -1
  46. package/pi/prompts/cairn-work.md +12 -0
  47. package/schemas/context-pack.schema.json +9 -0
  48. package/schemas/playbook.schema.json +29 -0
  49. package/scripts/bootstrap.sh +17 -0
  50. package/scripts/cairn-cli.mjs +2 -0
  51. package/scripts/completion.sh +26 -6
  52. package/scripts/doctor.sh +14 -1
  53. package/scripts/playbook-instructions.mjs +108 -0
  54. package/scripts/setup-core.mjs +1 -0
  55. package/scripts/setup.mjs +8 -0
  56. package/scripts/sync-kimi-assets.sh +3 -3
  57. package/scripts/sync-opencode-memory-assets.sh +2 -1
  58. package/scripts/sync-pi-assets.sh +2 -1
  59. package/scripts/test-cli-dispatch.sh +2 -0
  60. package/scripts/test-completion.sh +11 -2
  61. package/scripts/test-graph-harness-adapters.sh +9 -3
  62. package/scripts/test-harness-registry.sh +11 -0
  63. package/scripts/test-learning-docs.sh +23 -2
  64. package/scripts/test-package-install.sh +26 -0
  65. package/scripts/test-playbook-instructions.sh +60 -0
  66. package/scripts/test-windows-native.mjs +7 -0
  67. package/scripts/uninstall.sh +16 -1
  68. package/scripts/windows-platform.mjs +24 -3
  69. package/templates/playbook-agent-instructions.md.template +14 -0
  70. package/templates/playbooks.json.template +5 -0
@@ -3,7 +3,7 @@
3
3
  **Status:** Ready
4
4
  **Track:** Quickstart and Operator
5
5
  **Time:** 35 minutes
6
- **Tested with:** Cairnkeep 2.13.1; Pi 0.84.1; Node.js 22, 24, and 26
6
+ **Tested with:** Cairnkeep 2.15.0; Pi 0.84.1; Node.js 22, 24, and 26
7
7
 
8
8
  ## Outcome
9
9
 
@@ -134,7 +134,7 @@ prompts, approve skills, create an autonomous loop, or add remote access.
134
134
 
135
135
  ## Release boundary
136
136
 
137
- Ready means this lesson and its deterministic contracts pass against v2.13.1.
137
+ Ready means this lesson and its deterministic contracts pass against v2.14.0.
138
138
  Release readiness requires a non-skipping acceptance run
139
139
  against separate Pi 0.84.1 minimum and explicitly versioned registry-current
140
140
  installations, plus the documented Node.js, Bash 3.2, and native Windows matrix.
@@ -0,0 +1,111 @@
1
+ # L24 - Reviewed knowledge exchange
2
+
3
+ **Status:** Ready
4
+ **Tested with:** Cairnkeep 2.15.0 and Node.js 22 or newer
5
+ **Time:** 35 minutes
6
+
7
+ ## Outcome
8
+
9
+ Validate and import an OKF bundle as immutable project context, inspect its
10
+ structured provenance and deterministic links, then export an explicitly
11
+ selected, redacted OKF 0.2 bundle without confusing exchange with durable
12
+ memory or publisher trust.
13
+
14
+ ## Exercise
15
+
16
+ Create a disposable OKF 0.2 bundle:
17
+
18
+ ```bash
19
+ lab=$(mktemp -d)
20
+ mkdir -p "$lab/source/concepts" "$lab/project"
21
+ cat >"$lab/source/index.md" <<'EOF'
22
+ ---
23
+ okf_version: "0.2"
24
+ ---
25
+ # Local catalog
26
+
27
+ * Policy
28
+ EOF
29
+ printf '%s%s\n' '* [Policy]' '(concepts/policy.md)' >>"$lab/source/index.md"
30
+ cat >"$lab/source/concepts/policy.md" <<'EOF'
31
+ ---
32
+ type: Policy
33
+ title: Synthetic policy
34
+ description: Offline course fixture.
35
+ sources:
36
+ - resource: urn:course:fixture
37
+ verified: { by: human:course-reviewer }
38
+ ---
39
+ # Synthetic policy
40
+
41
+ This content is deliberately non-sensitive.
42
+ EOF
43
+ export CAIRN_PACK_BASE_DIR="$lab/store"
44
+ cairn pack validate-okf "$lab/source"
45
+ cairn pack import-okf "$lab/source" --id course-okf \
46
+ --version 1.0.0 --license CC0-1.0 --json >"$lab/import.json"
47
+ digest=$(node -e 'process.stdout.write(require(process.argv[1]).digest)' "$lab/import.json")
48
+ cairn pack enable "$digest" --project "$lab/project"
49
+ ```
50
+
51
+ Start the project memory server with `CAIRN_CONTEXT_PACKS=1`. Through an MCP
52
+ client, confirm that list/search/read results contain `okf.version`, concept
53
+ type, source, trust tier, freshness state, links, and diagnostics. Call
54
+ `context_pack_related` for `concepts/policy.md`; it performs no URL fetch and
55
+ returns only enabled files from the same digest-pinned pack.
56
+
57
+ Now preview and apply an allowlist-only export:
58
+
59
+ ```bash
60
+ mkdir -p "$lab/project/docs"
61
+ printf '# Reviewed decision\n\nSynthetic approved text.\n' \
62
+ >"$lab/project/docs/decision.md"
63
+ cairn pack export-okf --project "$lab/project" --output "$lab/export" \
64
+ --file docs/decision.md --check
65
+ # Copy the printed preview digest only after inspecting the file list.
66
+ cairn pack export-okf --project "$lab/project" --output "$lab/export" \
67
+ --file docs/decision.md --apply --confirm PREVIEW-DIGEST
68
+ cairn pack validate-okf "$lab/export"
69
+ ```
70
+
71
+ ## Common failures
72
+
73
+ - A concept without YAML `type`, a YAML alias, a symlink, invalid UTF-8, or an
74
+ unsafe path fails validation.
75
+ - Git input needs an explicit `--ref`; local validation/import does not use the
76
+ network.
77
+ - Export rejects broad private/runtime paths and accepts only named Markdown or
78
+ promoted shared notes.
79
+ - Any selected-byte or redaction change invalidates the preview digest. An
80
+ existing output directory is never replaced.
81
+
82
+ ## Privacy and trust boundary
83
+
84
+ Import metadata is reported, not vouched for. A pack digest proves byte
85
+ integrity but not publisher authenticity, and OKF computation/attestation
86
+ metadata is never executed. Optional embedding search can send chunks to the
87
+ configured endpoint; substring search and link traversal stay local. Export
88
+ applies redaction, but explicit review of both preview and output is still
89
+ required before publication.
90
+
91
+ An external knowledge adapter remains deferred unless a representative task
92
+ demonstrates a necessary capability that memory, promoted notes, context packs,
93
+ links, embeddings, and OKF exchange cannot provide with lower operational and
94
+ privacy cost.
95
+
96
+ ## Recovery and acceptance
97
+
98
+ ```bash
99
+ cairn pack disable course-okf --project "$lab/project"
100
+ cairn pack remove "$digest"
101
+ unset CAIRN_PACK_BASE_DIR
102
+ rm -rf "$lab"
103
+ ```
104
+
105
+ - Validation and import preserve OKF 0.1/0.2 provenance without modifying the
106
+ source.
107
+ - Related-document retrieval is deterministic, closed-world, and read-only.
108
+ - The regression fixture detects wrong top results, stale metadata, missing
109
+ provenance, and broken links.
110
+ - Export check performs no writes; apply requires the exact recomputed digest
111
+ and creates only the reviewed destination.
@@ -0,0 +1,114 @@
1
+ # L25 - Bounded workflow playbooks
2
+
3
+ **Status:** Ready
4
+ **Tested with:** Cairnkeep 2.15.0 and Node.js 22 or newer
5
+ **Time:** 35 minutes
6
+
7
+ ## Outcome
8
+
9
+ Configure a project playbook, evaluate it at start and finish, satisfy a
10
+ deterministic `must` gate with honest evidence, and inspect one private receipt
11
+ without mistaking agent self-selection for authorization or execution.
12
+
13
+ ## Exercise
14
+
15
+ Create a disposable project and a strict policy:
16
+
17
+ ```bash
18
+ lab=$(mktemp -d)
19
+ mkdir -p "$lab/project/.ai"
20
+ cd "$lab/project"
21
+ cairn playbook init strict
22
+ cairn playbook status
23
+ cairn playbook check start --session course-playbook \
24
+ --complexity complex --familiarity unfamiliar
25
+ ```
26
+
27
+ The start decision should select recall, focused exploration, and a bounded
28
+ plan. It displays existing Cairnkeep actions; it does not run them. In a real
29
+ task, perform the applicable actions through the harness and retain truthful
30
+ evidence.
31
+
32
+ Now model a security-sensitive public code-and-documentation change. First
33
+ observe the enforcement failure:
34
+
35
+ ```bash
36
+ set +e
37
+ cairn playbook check finish --session course-playbook \
38
+ --changed src/auth.ts docs/security.md --risk security --public-change \
39
+ --enforce --json >"$lab/missing.json"
40
+ test "$?" -eq 3
41
+ set -e
42
+ ```
43
+
44
+ Inspect `blocking_actions`; do not merely label them complete. After running
45
+ the relevant tests, repository review, security audit, and documentation
46
+ checks, provide the resulting evidence:
47
+
48
+ ```bash
49
+ cairn playbook check finish --session course-playbook \
50
+ --changed src/auth.ts docs/security.md --risk security --public-change \
51
+ --completed verify.tests review.repository review.security docs.update \
52
+ --skipped learning.capture='no stable reusable learning' \
53
+ --enforce --json >"$lab/decision.json"
54
+ ```
55
+
56
+ Record one material result with the exact returned digests:
57
+
58
+ ```bash
59
+ policy=$(node -p "require('$lab/decision.json').policy_digest")
60
+ decision=$(node -p "require('$lab/decision.json').decision_digest")
61
+ cairn playbook record --policy "$policy" --decision "$decision" \
62
+ --event finish --action verify.tests --outcome completed \
63
+ --session course-playbook --reason 'targeted synthetic tests passed'
64
+ cairn playbook receipts list
65
+ cairn playbook doctor
66
+ ```
67
+
68
+ Try a bounded customization, then restore the profile behavior:
69
+
70
+ ```bash
71
+ cairn playbook disable learning.capture
72
+ cairn playbook reset learning.capture
73
+ cairn playbook set balanced
74
+ ```
75
+
76
+ ## Common failures
77
+
78
+ - Exit 3 is missing required evidence, not a request to weaken the policy.
79
+ - `--skipped` and `--failed` require `ACTION=REASON`; they do not satisfy a
80
+ `must` action.
81
+ - Unknown actions, fields, modes, commands, URLs, path traversal, symlinks,
82
+ unsafe permissions, and oversized policy files fail closed.
83
+ - A changed policy makes an old policy digest stale for new receipts.
84
+ - `CAIRN_PLAYBOOK_PROFILE` overrides the project profile for that process; use
85
+ `cairn playbook status` to see the effective source.
86
+
87
+ ## Privacy and trust boundary
88
+
89
+ Checks are offline and store nothing. Explicit receipts contain bounded
90
+ identifiers, digests, event/action/outcome/reason, and a timestamp, but no
91
+ prompt, file body, diff, command output, credential, or environment snapshot.
92
+ Changed-path labels affect the decision but are not stored in the receipt.
93
+
94
+ The v2.15 actor field is caller-supplied and unauthenticated. It is useful for
95
+ local provenance, not access control, employee monitoring, or non-repudiation.
96
+ Playbooks cannot enable capabilities, grant mutation approval, execute harness
97
+ commands, or promote a learning into durable memory. Team authentication,
98
+ ACLs, tenant isolation, and shared review queues remain design-only.
99
+
100
+ ## Recovery and acceptance
101
+
102
+ ```bash
103
+ cairn playbook instructions remove --project "$lab/project"
104
+ cd /
105
+ rm -rf "$lab"
106
+ ```
107
+
108
+ - Identical policy, signals, event, and evidence produce the same decision
109
+ digest.
110
+ - Missing applicable `must` evidence exits 3 under `--enforce`; completed
111
+ evidence clears the relevant block.
112
+ - The receipt is private, project-bound, bounded, and visible to `doctor`.
113
+ - Removing managed instructions preserves all surrounding `AGENTS.md` content.
114
+ - No check executes an action, contacts a network service, or grants approval.
@@ -2,7 +2,7 @@
2
2
 
3
3
  **Audience:** advanced users and platform maintainers
4
4
  **Prerequisite:** Practitioner track; L13 before operating captured evidence
5
- **Total time:** about 5 hours 35 minutes
5
+ **Total time:** about 6 hours 45 minutes
6
6
 
7
7
  1. [L09 - Domain knowledge with RAG](../lessons/L09-domain-knowledge.md)
8
8
  2. [L10 - Faster context exploration](../lessons/L10-context-exploration.md)
@@ -14,14 +14,20 @@
14
14
  8. [L21 - Immutable context packs and skill approval](../lessons/L21-context-packs.md)
15
15
  9. [L22 - Operate Cairnkeep on native Windows](../lessons/L22-native-windows.md)
16
16
  10. [L23 - Guided setup and Pi memory](../lessons/L23-guided-setup.md)
17
+ 11. [L24 - Reviewed knowledge exchange](../lessons/L24-okf-exchange.md)
18
+ 12. [L25 - Bounded workflow playbooks](../lessons/L25-playbooks.md)
17
19
 
18
20
  All modules are optional. The track is complete when the operator can add and
19
21
  remove each integration without breaking the standalone local workflow and can
20
22
  explain its storage, network, credential, and rollback boundaries. L23 adds the
21
23
  v2.11 setup/Pi lifecycle only after the earlier storage, governance, trust, and
22
24
  native-platform boundaries.
25
+ L24 adds portable exchange only after the immutable-pack and privacy boundaries
26
+ are understood.
27
+ L25 adds policy enforcement and the unauthenticated local actor boundary before
28
+ any future team deployment.
23
29
 
24
30
  Hands-on spine: `course-04-operation`, `course-06-governance`, and
25
31
  `course-07-evaluation`, `course-10-trust-context`, and
26
- `course-12-guided-setup` in the public
32
+ `course-12-guided-setup`, and `course-13-playbooks` in the public
27
33
  [course labs](https://github.com/cairnkeep/cairnkeep-course-labs).
@@ -2,7 +2,7 @@
2
2
 
3
3
  **Audience:** developers adopting Cairnkeep in daily work
4
4
  **Prerequisite:** Quickstart track
5
- **Total time:** about 4 hours
5
+ **Total time:** about 4 hours 35 minutes
6
6
 
7
7
  1. [L04 - Memory fundamentals](../lessons/L04-memory-fundamentals.md)
8
8
  2. [L05 - The daily workflow](../lessons/L05-daily-workflow.md)
@@ -11,11 +11,13 @@
11
11
  5. [L07 - Privacy and storage](../lessons/L07-privacy-and-storage.md)
12
12
  6. [L08 - Multiple machines](../lessons/L08-multiple-machines.md)
13
13
  7. [L13 - Session evidence and hindsight](../lessons/L13-session-evidence.md)
14
+ 8. [L25 - Bounded workflow playbooks](../lessons/L25-playbooks.md)
14
15
 
15
16
  The track is complete when the learner can decide what should become memory,
16
17
  review derived knowledge, run governed repository checks, locate the store, and
17
- perform a reversible backup or migration.
18
+ perform a reversible backup or migration, and distinguish playbook selection
19
+ from execution and approval.
18
20
 
19
21
  Hands-on spine: `course-02-memory`, `course-03-quality`, and
20
- `course-05-evidence` in the public
22
+ `course-05-evidence`, and `course-13-playbooks` in the public
21
23
  [course labs](https://github.com/cairnkeep/cairnkeep-course-labs).
@@ -0,0 +1,31 @@
1
+ # V24 - Reviewed knowledge exchange
2
+
3
+ **Companion lesson:** [L24](../lessons/L24-okf-exchange.md)
4
+ **Target length:** 9 minutes
5
+
6
+ ## Recording outline
7
+
8
+ 1. State the boundary: OKF is portable context exchange, not a second memory
9
+ owner, agent loop, trust authority, or background sync service.
10
+ 2. Show a two-concept synthetic OKF 0.2 directory and run
11
+ `cairn pack validate-okf`.
12
+ 3. Import it with an ID, semantic version, and license; point out that the
13
+ source directory remains unchanged and the pack digest is authoritative.
14
+ 4. Enable the digest for one disposable project. Show structured `okf`
15
+ provenance in list/search/read and traverse one local link with
16
+ `context_pack_related`.
17
+ 5. Break a link and make a concept stale in a second fixture. Show diagnostics
18
+ without implying that Cairnkeep verified the source claims.
19
+ 6. Select one project Markdown file, run `export-okf --check`, and emphasize
20
+ that no output exists. Inspect the allowlist, redaction count, and digests.
21
+ 7. Apply with the exact preview digest and validate the result. Demonstrate one
22
+ rejected private path and one mismatched confirmation.
23
+ 8. Close with the external-adapter gate: demand a measured, otherwise
24
+ impossible workflow before accepting another network and data owner.
25
+
26
+ ## Recording cautions
27
+
28
+ - Use only synthetic paths, content, sources, and credentials.
29
+ - Keep embeddings disabled so the recording proves the offline fallback.
30
+ - Do not claim publisher authenticity, semantic correctness, or quality gains.
31
+ - Remove the disposable pack object and project pointer on camera.
@@ -0,0 +1,38 @@
1
+ # V25 - Bounded workflow playbooks
2
+
3
+ **Companion lesson:** [L25](../lessons/L25-playbooks.md)
4
+ **Target length:** 9 minutes
5
+
6
+ ## Recording outline
7
+
8
+ 1. Open with the boundary: Cairnkeep selects existing workflow actions; the
9
+ harness remains the agent runtime and every approval remains in force.
10
+ 2. Run guided setup in a synthetic project. Show `.ai/playbooks.json` mode and
11
+ the delimited Cairnkeep block inside an `AGENTS.md` that already has user
12
+ content.
13
+ 3. Compare `minimal`, `balanced`, and `strict` with `cairn playbook status`.
14
+ Customize one canonical action and show that an arbitrary command or unknown
15
+ field is rejected.
16
+ 4. Run `check start` for a complex unfamiliar task. Explain deterministic
17
+ signals versus the model-supplied complexity/familiarity assertion.
18
+ 5. Run a security-sensitive `check finish --enforce` without evidence and show
19
+ exit 3. Perform synthetic verification, then re-run with completed and
20
+ reasoned skipped evidence.
21
+ 6. Record one outcome with exact policy and decision digests. Inspect the
22
+ private receipt and show that changed paths, prompts, source, and output are
23
+ absent.
24
+ 7. Show `/cairn-work` in Claude or OpenCode and the portable `AGENTS.md`
25
+ guidance for Codex/Qwen. State that adapters route to the same CLI and do not
26
+ automatically activate skills.
27
+ 8. Remove the managed instruction block, prove user instructions remain, and
28
+ close on the design-only team boundary.
29
+
30
+ ## Recording cautions
31
+
32
+ - Use only synthetic paths, actors, reasons, and project data.
33
+ - Do not imply that an agent's `completed` assertion proves an action ran;
34
+ demonstrate the evidence boundary explicitly.
35
+ - Do not describe local actor labels as authenticated identities.
36
+ - Do not claim productivity or quality improvement without a separate measured
37
+ evaluation.
38
+ - Keep all network-capable optional integrations disabled during the demo.
@@ -32,6 +32,11 @@ recovery contract as POSIX. It writes a restricted `.ai/cairnkeep.json` setup
32
32
  record and never syncs machine assets automatically. `cairn bootstrap` remains
33
33
  the deterministic compatibility primitive for existing scripts.
34
34
 
35
+ Setup also writes private `.ai/playbooks.json` and reconciles Cairnkeep's
36
+ delimited workflow block in `AGENTS.md` without replacing surrounding rules.
37
+ The Node-native `cairn playbook` lifecycle, deterministic enforcement, private
38
+ receipts, and instruction management are identical on Windows and POSIX.
39
+
35
40
  For Codex memory without a harness-wide sync, select only Codex:
36
41
 
37
42
  ```powershell
@@ -89,6 +94,9 @@ Load completion for the current session:
89
94
  Invoke-Expression (& cairn completion powershell | Out-String)
90
95
  ```
91
96
 
97
+ The completer includes playbook profiles, lifecycle events, canonical actions,
98
+ and check/record options as well as the top-level command.
99
+
92
100
  Place the same expression in `$PROFILE` to load it in future sessions.
93
101
 
94
102
  ## Storage and permissions
@@ -135,6 +143,10 @@ mutation it creates a timestamped bundle under
135
143
  `revert.ps1`. Durable memory and context packs remain unless their separate
136
144
  purge flags are supplied.
137
145
 
146
+ Uninstall removes only Cairnkeep's managed `AGENTS.md` block and preserves
147
+ surrounding project instructions. Pi and Kimi playbook adapters are handled as
148
+ precisely owned paths alongside their graph adapters.
149
+
138
150
  ## Verification boundary
139
151
 
140
152
  The release gate runs from `windows-latest` using PowerShell for Node 22, 24,
@@ -0,0 +1,100 @@
1
+ # Open Knowledge Format exchange
2
+
3
+ Cairnkeep can ingest Open Knowledge Format (OKF) 0.1 and 0.2 bundles as
4
+ immutable context packs and can export an explicitly reviewed subset of local
5
+ knowledge as OKF 0.2. This is an exchange boundary, not a second memory store,
6
+ an agent runtime, or a synchronization service.
7
+
8
+ ## Validate and import
9
+
10
+ ```bash
11
+ cairn pack validate-okf ./knowledge
12
+ cairn pack import-okf ./knowledge \
13
+ --id reviewed-knowledge --version 1.0.0 --license CC-BY-4.0
14
+ cairn pack enable reviewed-knowledge --project ./project
15
+ ```
16
+
17
+ The importer accepts a local directory without network access. A Git source
18
+ requires `--ref`; Cairnkeep resolves and records the exact commit using the
19
+ system `git` executable. Repository metadata is excluded. Import copies only
20
+ validated UTF-8 bundle files into a new immutable object and never modifies the
21
+ source.
22
+
23
+ Validation rejects symlinks, devices, unsafe paths, invalid UTF-8, YAML aliases,
24
+ missing concept `type`, duplicate YAML keys, and the normal context-pack size
25
+ limits. Unknown concept metadata remains available for forward-compatible
26
+ reading. A future OKF version produces a diagnostic and is consumed on a
27
+ best-effort basis rather than being treated as fully supported.
28
+
29
+ OKF 0.2 provenance is preserved in the `okf` field returned by
30
+ `context_pack_list`, `context_pack_search`, and `context_pack_read`. It includes
31
+ the format version, file role, concept identity and type, declared sources,
32
+ generation and verification events, trust tier, status, staleness, links, and
33
+ diagnostics. These are source assertions: Cairnkeep reports them but does not
34
+ turn them into publisher authenticity or executable authority.
35
+
36
+ ## Deterministic links and retrieval
37
+
38
+ With `CAIRN_CONTEXT_PACKS=1`, imported packs also expose the read-only,
39
+ closed-world `context_pack_related` MCP tool. It traverses local Markdown links
40
+ in `outbound`, `inbound`, or `both` directions. External URLs are never fetched.
41
+ Broken and unsafe local links remain diagnostics. The derived graph cache lives
42
+ outside immutable objects and is keyed by the authoritative pack digest; it can
43
+ always be rebuilt from the object.
44
+
45
+ Search still follows the context-pack retrieval contract: deterministic
46
+ substring matching is always available, while configured embeddings are an
47
+ optional enhancement with a clean lexical fallback. Regression fixtures cover
48
+ the expected top result, source/trust preservation, stale-content warnings,
49
+ missing-metadata diagnostics, broken links, and embedding-independent graph
50
+ results.
51
+
52
+ ## Privacy-reviewed export
53
+
54
+ Export is allowlist-only and uses a two-step confirmation:
55
+
56
+ ```bash
57
+ cairn pack export-okf --project ./project --output ./reviewed-okf \
58
+ --file docs/decision.md --note shared-example --check
59
+
60
+ cairn pack export-okf --project ./project --output ./reviewed-okf \
61
+ --file docs/decision.md --note shared-example \
62
+ --apply --confirm PREVIEW-DIGEST
63
+ ```
64
+
65
+ `--check` writes nothing. It reads only the named Markdown files and promoted
66
+ shared notes, applies the local redaction policy, and returns the exact output
67
+ list, output digests, redaction count, and confirmation digest. `--apply`
68
+ recomputes that plan and writes atomically only when the digest matches. It
69
+ refuses an existing output directory.
70
+
71
+ Private runtime directories, Git metadata, dependencies, and most planning
72
+ state cannot be selected. The reviewed wiki subtree is the sole planning-state
73
+ exception and is mapped to `wiki/`. Project hindsight and provenance notes are
74
+ not exportable: only already-corroborated `shared` notes pass the note reader.
75
+ The resulting bundle can still contain sensitive domain content, so review the
76
+ preview and the output before publishing it.
77
+
78
+ ## External adapter decision gate
79
+
80
+ No live external knowledge-system adapter is included. Native memory, promoted
81
+ notes, immutable packs, deterministic links, optional embeddings, and OKF
82
+ import/export already cover local capture, reviewed sharing, retrieval, and
83
+ portable exchange.
84
+
85
+ An adapter should be added only when a concrete workflow demonstrates all of
86
+ the following:
87
+
88
+ 1. It needs a capability Cairnkeep cannot express through those native
89
+ surfaces, not merely another UI or duplicate graph.
90
+ 2. The benefit is measured on a representative task set and exceeds the added
91
+ privacy, availability, migration, and operational cost.
92
+ 3. Cairnkeep remains the sole owner of durable-memory mutations; the adapter is
93
+ read-only or has an explicit, reversible write boundary.
94
+ 4. Authentication, data egress, deletion, backup, and failure behavior are
95
+ testable without weakening local/offline defaults.
96
+ 5. A provider-neutral interface and fixture can be maintained without adding a
97
+ background agent loop or automatic activation.
98
+
99
+ Until a use case passes that gate, OKF exchange is the smaller and safer
100
+ integration seam.
package/docs/operating.md CHANGED
@@ -830,6 +830,60 @@ is not an authorization boundary. See [Memory storage and deployment](storage.md
830
830
  for the placement rules, client registration, TLS requirements, project headers,
831
831
  and backup boundaries.
832
832
 
833
+ ## Project playbooks
834
+
835
+ Guided setup and tracked bootstrap create private `.ai/playbooks.json` mode
836
+ `0600` with the `balanced` profile and reconcile a delimited block in the
837
+ project's `AGENTS.md`. `--untracked` bootstrap leaves the shared `AGENTS.md`
838
+ untouched. The policy can select only eight canonical Cairnkeep actions; it
839
+ cannot contain commands, prompts, URLs, or extensions.
840
+
841
+ ```bash
842
+ cairn playbook list
843
+ cairn playbook status --project .
844
+ cairn playbook set strict
845
+ cairn playbook enable review.security must
846
+ cairn playbook disable learning.capture
847
+ cairn playbook reset learning.capture
848
+ ```
849
+
850
+ At task start, use `check start`; after a material risk or scope change, use
851
+ `check check`; before completion, use `check finish`. Supply actual changed
852
+ paths and evidence rather than trusting a model's unsupported claim:
853
+
854
+ ```bash
855
+ cairn playbook check finish --changed src/auth.ts docs/security.md \
856
+ --risk security --public-change \
857
+ --completed verify.tests review.repository review.security docs.update \
858
+ --enforce
859
+ ```
860
+
861
+ Exit 3 means applicable `must` evidence is missing. Exit 2 means the policy has
862
+ diagnostic issues. Otherwise the check succeeded. `should` actions remain
863
+ advisory and should carry a concrete `--skipped ACTION=REASON` when omitted.
864
+ Checking never executes the displayed commands, contacts a service, enables a
865
+ capability, or grants approval.
866
+
867
+ Material outcomes can be stored with `cairn playbook record` using the exact
868
+ policy and decision digests from the check. Inspect them with `cairn playbook
869
+ receipts list|show`; validate state with `cairn playbook doctor`. Actor and
870
+ session options are provenance labels only: v2.15 does not authenticate them
871
+ and does not provide team ACLs. See [team mode](design/team-mode.md) for the
872
+ future admission contract.
873
+
874
+ The managed instruction lifecycle is explicit and ownership-safe:
875
+
876
+ ```bash
877
+ cairn playbook instructions check
878
+ cairn playbook instructions install
879
+ cairn playbook instructions remove
880
+ ```
881
+
882
+ Claude and OpenCode receive `/cairn-work`; Pi and Kimi receive corresponding
883
+ thin prompt/Skill adapters when their explicit machine sync runs. Codex and
884
+ Qwen follow the project `AGENTS.md` block. These surfaces route to the same CLI
885
+ and do not create a Cairnkeep-owned agent loop.
886
+
833
887
  ## The workflow
834
888
 
835
889
  Once installed, the operating layer gives you:
@@ -1302,3 +1356,17 @@ an `--apply --confirm CANDIDATE-DIGEST`. Use `cairn pack skills` and exact-diges
1302
1356
  approval before a bundled skill can be read through MCP. HTTP needs the separate
1303
1357
  `CAIRN_CONTEXT_PACK_HTTP=1` flag and all existing authentication/Host/CORS
1304
1358
  controls. See [Immutable context packs](context-packs.md).
1359
+
1360
+ Validate and import an OKF bundle without converting it by hand:
1361
+
1362
+ ```bash
1363
+ cairn pack validate-okf ./knowledge
1364
+ cairn pack import-okf ./knowledge --id reviewed-knowledge \
1365
+ --version 1.0.0 --license CC-BY-4.0
1366
+ ```
1367
+
1368
+ Imported OKF packs preserve structured source/trust/freshness metadata and add
1369
+ read-only related-document traversal. Privacy-reviewed export is an explicit
1370
+ `export-okf --check` followed by `--apply --confirm PREVIEW-DIGEST`; only named
1371
+ Markdown files and promoted shared notes are eligible. See
1372
+ [Open Knowledge Format exchange](open-knowledge-format.md).
@@ -19,6 +19,8 @@ request unless the corresponding endpoint and credential are configured.
19
19
  | Local context-pack install/list/read/substring search | None | Verified immutable files and project pointers under `CAIRN_PACK_BASE_DIR` |
20
20
  | Embedding-ranked context-pack search | Enabled file chunks not already cached, plus the query | The explicitly configured embedding endpoint; failure falls back locally |
21
21
  | Authenticated HTTP context-pack retrieval | MCP requests and enabled document/approved-skill content | The explicit Cairnkeep HTTP server; requires separate pack HTTP consent |
22
+ | Local OKF validation/import/link traversal | None | Source files are read locally; immutable object and digest-keyed graph cache remain under `CAIRN_PACK_BASE_DIR` |
23
+ | Privacy-reviewed OKF export | None | Only explicitly named Markdown/promoted shared notes are redacted into the operator-selected local output directory after exact preview confirmation |
22
24
  | Optional Graphify workflow | The repository path, exact query/symbol names, root `graphify-out/` work directory, and local `.planning/graphs/` publication are passed to or produced by the operator-installed `graphify` executable | Local Graphify subprocess with a minimal environment and no provider credentials; managed build uses code-only `update`, never semantic document extraction |
23
25
  | Remote HTTP memory | MCP requests and responses, including memory content | The explicitly registered Cairnkeep HTTP server |
24
26
  | Opt-in trajectory capture | None | Local `<project>/.agentfs/trajectory.db` only; no model or HTTP path exists |
@@ -41,12 +43,35 @@ request unless the corresponding endpoint and credential are configured.
41
43
  | Guided project setup | None | Selected scaffold assets and private `.ai/cairnkeep.json` state in the target; machine sync is never automatic |
42
44
  | Codex project setup and launcher | None | Local `.codex/config.toml` starts `cairn memory-server` over stdio only after the operator trusts the project |
43
45
  | Pi memory extension | None | Local `cairn memory-server` stdio child; no HTTP transport is inherited |
46
+ | Playbook policy check | None | Reads local `.ai/playbooks.json`; returns bounded action IDs, rationales, commands, and digests without executing them |
47
+ | Explicit playbook receipt | None | Private project-local `.agentfs/playbooks/receipts/`; no prompts, source bodies, diffs, credentials, or environment snapshot |
44
48
 
45
49
  Model endpoints may be local or remote. Cairnkeep cannot determine a provider's
46
50
  retention, training, or logging policy; verify it before sending confidential
47
51
  material. Disabling `CAIRN_LLM_API_KEY`, `ANYTHINGLLM_API_KEY`, remote HTTP
48
52
  registration, and delegated tools keeps the core memory workflow local.
49
53
 
54
+ ## Playbook decision and receipt flow
55
+
56
+ Playbooks are local workflow policy, not model inference. A check reads the
57
+ strict project policy, bounded caller signals, changed-path labels, and explicit
58
+ evidence. It deterministically returns applicable canonical actions and policy
59
+ and decision digests. It performs no network request, tool action, capability
60
+ change, approval, or durable-memory promotion.
61
+
62
+ Only an explicit `cairn playbook record` writes a receipt. The receipt stores
63
+ project identity, digests, event, canonical action, outcome, bounded reason,
64
+ timestamp, and the supplied actor/session labels. It excludes prompt content,
65
+ file content, patches, command output, secrets, endpoint values, and environment
66
+ snapshots. Changed paths influence a decision but are not copied into receipts.
67
+
68
+ In v2.15, actor identity is an unauthenticated local assertion even when a
69
+ harness supplies it. Do not use receipts for employee monitoring,
70
+ authorization, non-repudiation, or team access decisions. The future
71
+ [team-mode contract](design/team-mode.md) requires authenticated subjects,
72
+ deny-by-default ACLs, tenant isolation, retention, and append-only auditing
73
+ before shared operation can ship.
74
+
50
75
  ## Data at rest
51
76
 
52
77
  Memories are stored in SQLite databases. They are not encrypted by Cairnkeep at
@@ -69,7 +69,9 @@ result should survive the restart.
69
69
  ## What setup owns
70
70
 
71
71
  `cairn setup` creates only the selected harness assets plus the common `.ai`,
72
- `.planning`, and `.agentfs` scaffold. It initializes Git only with explicit
72
+ `.planning`, and `.agentfs` scaffold. It also reconciles Cairnkeep's delimited
73
+ playbook block in `AGENTS.md` while preserving every surrounding user byte and
74
+ file mode. It initializes Git only with explicit
73
75
  `--git init`, preserves unrelated files, does not overwrite modified files it
74
76
  does not own, and records managed digests in private `.ai/cairnkeep.json`.
75
77
 
@@ -81,6 +83,20 @@ cairn doctor # diagnose
81
83
  cairn uninstall --dry-run . # preview removal
82
84
  ```
83
85
 
86
+ The generated balanced policy helps compatible agents decide which existing
87
+ workflow checks apply. Inspect it directly before relying on agent routing:
88
+
89
+ ```bash
90
+ cairn playbook status
91
+ cairn playbook check start --complexity standard --familiarity mixed
92
+ cairn playbook check finish --changed README.md --completed docs.update --enforce
93
+ ```
94
+
95
+ `must` can produce a non-zero enforcement result; `should` is advisory with a
96
+ recorded reason when skipped; `may` is optional. A decision executes nothing
97
+ and grants no permission. `cairn playbook instructions remove` removes only the
98
+ managed `AGENTS.md` block.
99
+
84
100
  For all harnesses, remote HTTP, storage, profiles, context packs, overlays, and
85
101
  recovery details, continue with [Operating Cairnkeep](operating.md) or the
86
102
  [learning path](learning/README.md).