@cairnkeep/cli 2.8.0 → 2.9.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 (43) hide show
  1. package/CHANGELOG.md +23 -1
  2. package/README.md +28 -2
  3. package/bin/cairn +13 -1
  4. package/docs/context-packs.md +94 -0
  5. package/docs/harness-compatibility.md +7 -1
  6. package/docs/learning/CURRICULUM-MAP.md +9 -4
  7. package/docs/learning/FEATURE-GUIDE.md +7 -2
  8. package/docs/learning/README.md +6 -2
  9. package/docs/learning/lessons/L00-why-cairnkeep.md +1 -1
  10. package/docs/learning/lessons/L01-safe-trial.md +3 -3
  11. package/docs/learning/lessons/L02-installation.md +2 -2
  12. package/docs/learning/lessons/L03-first-project.md +1 -1
  13. package/docs/learning/lessons/L19-validated-skill-improvement.md +52 -21
  14. package/docs/learning/lessons/L20-mcp-tool-profiles.md +67 -0
  15. package/docs/learning/lessons/L21-context-packs.md +79 -0
  16. package/docs/learning/tracks/operator.md +4 -2
  17. package/docs/mcp-tool-profiles.md +43 -0
  18. package/docs/operating.md +38 -0
  19. package/docs/privacy-and-data-flow.md +17 -0
  20. package/docs/storage.md +17 -0
  21. package/examples/eval/bundled-fake.json +1 -1
  22. package/mcp-memory-server/dist/context-pack-cli.js +185 -0
  23. package/mcp-memory-server/dist/context-pack.js +830 -0
  24. package/mcp-memory-server/dist/eval-report.js +1 -0
  25. package/mcp-memory-server/dist/eval-runner.js +2 -0
  26. package/mcp-memory-server/dist/eval-schema.js +1 -0
  27. package/mcp-memory-server/dist/index.js +68 -17
  28. package/mcp-memory-server/dist/mcp-tool-catalog.js +47 -0
  29. package/mcp-memory-server/dist/mcp-tool-cli.js +85 -0
  30. package/mcp-memory-server/dist/mcp-tool-profile.js +162 -0
  31. package/mcp-memory-server/package.json +3 -1
  32. package/package.json +1 -1
  33. package/schemas/context-pack.schema.json +33 -0
  34. package/schemas/eval-report.schema.json +1 -0
  35. package/scripts/completion.sh +24 -5
  36. package/scripts/doctor.sh +39 -0
  37. package/scripts/test-cli-dispatch.sh +6 -0
  38. package/scripts/test-completion.sh +5 -0
  39. package/scripts/test-learning-docs.sh +4 -3
  40. package/scripts/test-package-install.sh +17 -0
  41. package/scripts/test-uninstall.sh +21 -0
  42. package/scripts/uninstall.sh +26 -1
  43. package/templates/env.example.template +11 -0
package/CHANGELOG.md CHANGED
@@ -5,6 +5,27 @@ All notable user-facing changes are documented here. This project follows
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [2.9.0] - 2026-08-06
9
+
10
+ ### Added
11
+
12
+ - Publish complete, centralized MCP tool annotations and add project-scoped
13
+ `full`, derived `read-only`, and exact custom tool profiles with strict
14
+ environment precedence and canonical provenance digests.
15
+ - Add immutable context-pack manifests, local and commit-pinned Git installs,
16
+ atomic project enablement and confirmed updates, retained object storage,
17
+ integrity diagnostics, and explicit uninstall purge consent.
18
+ - Add read-only context-pack list/search/read tools behind separate local and
19
+ authenticated-HTTP consent gates. Documents include full provenance; skills
20
+ remain invisible until their exact project/pack/path/file digest is approved.
21
+ - Add deterministic Markdown chunking, optional embedding-ranked retrieval with
22
+ offline substring fallback, shell completion, lifecycle tests, operator docs,
23
+ and learning-path exercises.
24
+
25
+ Context packs add no runtime dependency, telemetry, background synchronization,
26
+ publisher-authenticity claim, ACL system, automatic skill activation, or
27
+ provider-specific runtime integration.
28
+
8
29
  ## [2.8.0] - 2026-08-03
9
30
 
10
31
  ### Added
@@ -252,7 +273,8 @@ stored memories.
252
273
  - Preserve executable permissions and Bash 3.2 portability on macOS.
253
274
  - Add backup-first uninstall and SQLite-safe memory export/import guidance.
254
275
 
255
- [Unreleased]: https://github.com/cairnkeep/cairnkeep/compare/v2.8.0...HEAD
276
+ [Unreleased]: https://github.com/cairnkeep/cairnkeep/compare/v2.9.0...HEAD
277
+ [2.9.0]: https://github.com/cairnkeep/cairnkeep/compare/v2.8.0...v2.9.0
256
278
  [2.8.0]: https://github.com/cairnkeep/cairnkeep/compare/v2.7.0...v2.8.0
257
279
  [2.7.0]: https://github.com/cairnkeep/cairnkeep/compare/v2.6.0...v2.7.0
258
280
  [2.6.0]: https://github.com/cairnkeep/cairnkeep/compare/v2.5.0...v2.6.0
package/README.md CHANGED
@@ -15,7 +15,7 @@ Qwen Code, Pi, and other MCP clients).
15
15
  ## Status
16
16
 
17
17
  Shipped: the memory server, the `cairn` CLI (`bootstrap`, `memory-server`, `sync`, `sync-pi`, `sync-kimi`,
18
- `doctor`, `trajectory`, `artifact`, `notes`, `memory`, `eval`, `audit-timer`, `completion`, `uninstall`) installable via
18
+ `doctor`, `trajectory`, `artifact`, `mcp-tools`, `pack`, `notes`, `memory`, `eval`, `audit-timer`, `completion`, `uninstall`) installable via
19
19
  `npm i -g @cairnkeep/cli`, and the
20
20
  operating layer (commands,
21
21
  agents, hooks) installed on Claude Code and OpenCode, plus a native Pi
@@ -41,7 +41,7 @@ and 20 are end-of-life upstream.
41
41
  | Qwen Code on Linux/macOS | Memory MCP server plus project launcher; no Cairnkeep operating-layer assets yet |
42
42
  | Pi on Linux/macOS | Native opt-in trajectory extension, launcher, and `/graphify` prompt; no bundled MCP bridge |
43
43
  | Codex CLI | Memory MCP server; no Cairnkeep operating-layer assets |
44
- | Other MCP clients | Memory and optional domain-knowledge MCP tools |
44
+ | Other MCP clients | Memory plus optional domain-knowledge and context-pack MCP tools |
45
45
  | Native Windows | Not supported by the Bash-based installer; use WSL (not yet CI-verified) |
46
46
 
47
47
  The `cairn graph` CLI is harness-independent and can be run from a project
@@ -82,6 +82,9 @@ storage paths, secrets, and private derived images, see
82
82
  `.ai/` launchers + env; `cairn doctor` health-checks the configured pieces;
83
83
  `cairn trajectory list|show|prune` manages opt-in local session trajectories;
84
84
  `cairn artifact list|show|delete|prune` manages opt-in local artifacts;
85
+ `cairn mcp-tools list|status|set|reset` applies least-authority discovery
86
+ profiles; `cairn pack` validates, installs, pins, updates, and approves
87
+ immutable external context;
85
88
  `cairn eval validate|run|ablate|report|prune|delete` coordinates explicit
86
89
  local two-pass and one-capability-at-a-time measurements;
87
90
  `cairn skill harvest|list|show|review|propose|evaluate|apply|rollback`
@@ -262,6 +265,11 @@ search):
262
265
  | `CAIRN_MEMORY_EMBEDDING_MODEL` | Embedding model name (required for semantic search) |
263
266
  | `CAIRN_MEMORY_EMBEDDING_TIMEOUT_MS` | Embedding request timeout before substring fallback (default `15000`) |
264
267
  | `CAIRN_AGENTFS_BASE_DIR` | Base dir for global memory scopes (default `~/.cairnkeep`) |
268
+ | `CAIRN_MCP_TOOL_PROFILE` | Process override for MCP exposure: `full`, `read-only`, or `custom` |
269
+ | `CAIRN_MCP_ALLOWED_TOOLS` | Comma-separated exact allowlist required by a custom process profile |
270
+ | `CAIRN_CONTEXT_PACKS` | Opt in to local context-pack list/search/read tools (default off) |
271
+ | `CAIRN_CONTEXT_PACK_HTTP` | Separately consent to context-pack tools over authenticated HTTP (default off) |
272
+ | `CAIRN_PACK_BASE_DIR` | Immutable pack objects, source records, pointers, and retrieval cache (default `~/.cairnkeep/packs`) |
265
273
  | `CAIRN_TRAJECTORY_CAPTURE` | Opt in to local structured session capture (`1`, `true`, `yes`, or `on`; default off) |
266
274
  | `CAIRN_TRAJECTORY_SESSION_MAX_BYTES` | Maximum serialized bytes per captured session (default `5242880`, 5 MiB) |
267
275
  | `CAIRN_TRAJECTORY_STORE_MAX_BYTES` | Maximum logical bytes across local trajectories (default `268435456`, 256 MiB) |
@@ -308,6 +316,22 @@ remote memory, and delegated exploration can send content to endpoints you
308
316
  configure. Review [Privacy and data flow](docs/privacy-and-data-flow.md) before
309
317
  enabling them.
310
318
 
319
+ ### MCP authority and context packs
320
+
321
+ Every tool publishes a stable title and all four MCP annotation hints. Use
322
+ `cairn mcp-tools set read-only` for observation-only clients, or an exact custom
323
+ allowlist when a workflow needs fewer tools. Process settings override the
324
+ strict project file; the default remains `full`. Profiles only remove tools and
325
+ cannot bypass capability or feature gates. See
326
+ [MCP tool profiles](docs/mcp-tool-profiles.md).
327
+
328
+ Context packs are immutable, digest-addressed local document/skill bundles.
329
+ They are installed and project-pinned manually; no background Git sync occurs.
330
+ With `CAIRN_CONTEXT_PACKS=1`, enabled documents are searchable through three
331
+ read-only MCP tools. Skills remain invisible until their exact file digest is
332
+ approved, and are never copied or executed. See
333
+ [Immutable context packs](docs/context-packs.md).
334
+
311
335
  ### Managed capability contract (opt-in)
312
336
 
313
337
  `CAIRN_CAPABILITY_CONTRACT=1` enables one versioned, typed boundary around the
@@ -482,6 +506,8 @@ exposes trajectory data. See the [operating guide](docs/operating.md#compaction-
482
506
  - **Memory storage and deployment** — [docs/storage.md](docs/storage.md)
483
507
  - **Podman and OCI containers** — [docs/containers.md](docs/containers.md)
484
508
  - **Privacy and data flow** — [docs/privacy-and-data-flow.md](docs/privacy-and-data-flow.md)
509
+ - **MCP tool profiles** — [docs/mcp-tool-profiles.md](docs/mcp-tool-profiles.md)
510
+ - **Immutable context packs** — [docs/context-packs.md](docs/context-packs.md)
485
511
  - **Validated skill improvement** — [docs/skill-improvement.md](docs/skill-improvement.md)
486
512
  - **Git providers** — [docs/git-providers.md](docs/git-providers.md)
487
513
  - **Support** — [SUPPORT.md](SUPPORT.md)
package/bin/cairn CHANGED
@@ -52,6 +52,12 @@ Usage:
52
52
  Inspect and manage project capability state. MCP changes
53
53
  require a memory-server restart; operating changes apply
54
54
  on the next invocation.
55
+ cairn mcp-tools <list|status|set|reset>
56
+ Inspect and restrict MCP tool exposure with full,
57
+ read-only, or exact custom project profiles.
58
+ cairn pack <init|lock|validate|install|list|show|remove|enable|disable|update|skills|approve-skill|revoke-skill>
59
+ Build, verify, install, pin, and retrieve immutable
60
+ context packs. Packs stay local and disabled by default.
55
61
  cairn notes <distill|search-error|promote|doctor>
56
62
  Compile closed trajectories into local hindsight notes,
57
63
  search exact failure signatures, promote corroborated
@@ -72,7 +78,7 @@ Usage:
72
78
  cairn audit-timer [--on-calendar SPEC] [--para-root PATH] [--render-only DIR]
73
79
  Install (opt-in) a systemd user timer that runs the
74
80
  memory+wiki audit on a schedule; prints a cron alternative.
75
- cairn uninstall [--dry-run] [--yes] [--purge-memory] [--live-root DIR]
81
+ cairn uninstall [--dry-run] [--yes] [--purge-memory] [--purge-packs] [--live-root DIR]
76
82
  [--pi-live-root DIR] [--kimi-live-root DIR] [PROJECT ...]
77
83
  Reverse what cairnkeep installed/modified (operating
78
84
  layer, hook registrations, MCP registration, audit
@@ -113,6 +119,12 @@ case "$cmd" in
113
119
  capabilities)
114
120
  exec node "$CAIRN_ROOT/mcp-memory-server/dist/capability-cli.js" "$@"
115
121
  ;;
122
+ mcp-tools)
123
+ exec node "$CAIRN_ROOT/mcp-memory-server/dist/mcp-tool-cli.js" "$@"
124
+ ;;
125
+ pack)
126
+ exec node "$CAIRN_ROOT/mcp-memory-server/dist/context-pack-cli.js" "$@"
127
+ ;;
116
128
  notes)
117
129
  exec node "$CAIRN_ROOT/mcp-memory-server/dist/note-cli.js" "$@"
118
130
  ;;
@@ -0,0 +1,94 @@
1
+ # Immutable context packs
2
+
3
+ Context packs provide project-approved reference documents and skills without
4
+ copying them into a harness or promoting them into durable memory. They are
5
+ local, immutable, disabled by default, and never execute instructions.
6
+
7
+ ## Format and identity
8
+
9
+ The root `context-pack.json` follows
10
+ [`schemas/context-pack.schema.json`](../schemas/context-pack.schema.json). It
11
+ declares a kebab-case ID, semantic version, descriptive metadata, license, and
12
+ an ordered list of UTF-8 `document` or `skill` files with SHA-256 digests.
13
+
14
+ Validation rejects unknown manifest fields, absolute or traversing paths,
15
+ symlinks, devices, duplicate, missing or undeclared files, invalid UTF-8, and
16
+ digest mismatches. Limits are 1 MiB per file, 1,024 entries, and 64 MiB total.
17
+ The authoritative pack digest covers the exact manifest bytes plus sorted
18
+ path/content bytes. The version label is informative; the digest is identity.
19
+
20
+ ```bash
21
+ cairn pack init ./my-pack --id my-pack --version 1.0.0 \
22
+ --title "My pack" --description "Reviewed local guidance" --license Apache-2.0
23
+ # Edit metadata/kinds if needed, then refresh file hashes.
24
+ cairn pack lock ./my-pack
25
+ cairn pack validate ./my-pack
26
+ ```
27
+
28
+ ## Installation and project pinning
29
+
30
+ ```bash
31
+ cairn pack install ./my-pack
32
+ cairn pack install https://example.invalid/repository.git --ref v1.0.0
33
+ cairn pack list
34
+ cairn pack show PACK-DIGEST
35
+ cairn pack enable PACK-DIGEST --project ./project
36
+ cairn pack disable my-pack --project ./project
37
+ cairn pack remove PACK-DIGEST
38
+ ```
39
+
40
+ Local installation performs no network operation. Git installation requires
41
+ `--ref`, invokes the system `git` executable with an argument array, records
42
+ the exact resolved commit, rejects credentials embedded in URLs, and stores no
43
+ checkout metadata. Immutable objects live under `CAIRN_PACK_BASE_DIR` (default
44
+ `~/.cairnkeep/packs`). Project pointers are atomic and digest-pinned. Remote
45
+ administration may use a validated `--project-id` instead of a local path.
46
+
47
+ Objects are retained until explicitly removed. Removal is refused while any
48
+ project points to the digest. Ordinary uninstall retains them; use
49
+ `cairn uninstall --purge-packs` only after reviewing the dry run and backup.
50
+
51
+ Updates never synchronize in the background:
52
+
53
+ ```bash
54
+ cairn pack update my-pack --check --project ./project
55
+ cairn pack update my-pack --apply --confirm CANDIDATE-DIGEST --project ./project
56
+ ```
57
+
58
+ `--check` does not install or switch a project. `--apply` re-inspects the source,
59
+ requires the candidate digest, installs an immutable object, and atomically
60
+ switches only the named project.
61
+
62
+ ## Retrieval and skill approval
63
+
64
+ Set `CAIRN_CONTEXT_PACKS=1` and restart the memory server to register the three
65
+ read-only, closed-world tools: `context_pack_list`, `context_pack_search`, and
66
+ `context_pack_read`. Every file or search result includes pack ID, version,
67
+ pack digest, path, kind, and file digest. Search uses the existing optional
68
+ embedding configuration and falls back to deterministic substring matching if
69
+ configuration or the endpoint is unavailable. Embedding cache data is stored
70
+ outside immutable objects.
71
+
72
+ Markdown is split deterministically at headings and paragraphs, with chunks
73
+ bounded to 8 KiB and 512-byte overlap. Only packs enabled for the current
74
+ project are searched.
75
+
76
+ Skills remain invisible until their exact file digest is approved:
77
+
78
+ ```bash
79
+ cairn pack skills --project ./project
80
+ cairn pack approve-skill PACK-DIGEST path/to/SKILL.md \
81
+ --confirm FILE-DIGEST --project ./project
82
+ cairn pack revoke-skill PACK-DIGEST path/to/SKILL.md --project ./project
83
+ ```
84
+
85
+ Approval binds the project identity, pack digest, path, and file digest. A pack
86
+ update invalidates approval. Approved skills are only discoverable/readable
87
+ through the context-pack tools; Cairnkeep does not copy, activate, or execute
88
+ them.
89
+
90
+ Authenticated HTTP deployments need the separate
91
+ `CAIRN_CONTEXT_PACK_HTTP=1` consent flag in addition to
92
+ `CAIRN_CONTEXT_PACKS=1`, the existing bearer token, Host/CORS guards, and a
93
+ project header. Pack digests prove integrity, not publisher authenticity.
94
+ Publisher signatures remain future work.
@@ -14,13 +14,19 @@ commands, hooks, plugins, or trajectory adapters.
14
14
  | Qwen Code | Memory MCP, launcher | Launcher tested; stdio and remote MCP tested with Qwen Code 0.21.1 |
15
15
  | Pi | Native opt-in trajectory extension, launcher, and graph prompt | Exercised by Cairnkeep tests; no bundled MCP bridge |
16
16
  | Codex CLI | Memory MCP | Configuration supported; no Cairnkeep operating-layer assets or launcher |
17
- | Other MCP clients | Memory and optional domain-knowledge tools | Protocol-compatible; not automatically runtime-tested |
17
+ | Other MCP clients | Memory plus optional domain-knowledge and context-pack tools | Protocol-compatible; not automatically runtime-tested |
18
18
 
19
19
  Only Claude Code and OpenCode currently receive the complete operating layer.
20
20
  Kimi receives one narrow graph Skill, while Pi receives one narrow graph prompt;
21
21
  neither is equivalent to the full commands, agents, hooks, and plugins surface.
22
22
  Qwen skills and hooks still require harness-specific adaptation and validation.
23
23
 
24
+ Every MCP client receives complete tool annotations and may use a Cairnkeep
25
+ least-authority profile independent of harness assets. Context-pack tools are
26
+ ordinary read-only MCP tools and require the pack feature gate; authenticated
27
+ HTTP additionally requires separate pack-HTTP consent. Approved pack skills
28
+ remain context documents, not native harness Skills or automatic instructions.
29
+
24
30
  `cairn graph` is a separate, harness-independent project-shell CLI. Kimi Code,
25
31
  Pi, Qwen Code, Codex, and other shell-capable clients can invoke
26
32
  `cairn graph build|query|status|diff|explain|path` when `cairn` and the isolated
@@ -1,7 +1,7 @@
1
1
  # Curriculum Coverage Map
2
2
 
3
- **Baseline:** Cairnkeep 2.8.0
4
- **Last reviewed:** 2026-08-03
3
+ **Baseline:** Cairnkeep 2.9.0
4
+ **Last reviewed:** 2026-08-06
5
5
 
6
6
  This map prevents the course from drifting behind the product. It assigns each
7
7
  user-facing surface to a lesson and records whether the lesson is complete or
@@ -31,7 +31,9 @@ been rehearsed.
31
31
  | Deterministic two-pass evaluation and one-capability ablation | L16 | L16 | Brief; default off |
32
32
  | Shell completion | L02 | L02 | Ready; optional convenience |
33
33
  | Bounded meta-agent configuration loop | L17 | None | Design-only; not shipped |
34
- | Reviewed, evaluated, reversible skill-file improvement | L19 | L19 | Brief; explicit and default off |
34
+ | Reviewed, evaluated, reversible skill-file improvement | L19 | L19 | Ready; explicit and default off |
35
+ | Complete MCP annotations and least-authority tool profiles | L20 | L20 | Ready; default profile remains full |
36
+ | Immutable context packs and exact-digest skill approval | L21 | L21 | Ready; default off |
35
37
 
36
38
  ## Release Review
37
39
 
@@ -61,7 +63,8 @@ repository remains the canonical source for explanations and scripts.
61
63
  | `course-06-governance` | L15 | Capability precedence and restart boundaries |
62
64
  | `course-07-evaluation` | L16-L17 | Package-owned offline fixture and design boundary |
63
65
  | `course-08-graph` | L18 | Optional local structural graph workflow |
64
- | Planned: `course-09-skill` | L19 | Validated skill improvement after a disposable lab exists |
66
+ | `course-09-skill` | L19 | Validated skill improvement in a disposable project |
67
+ | `course-10-trust-context` | L20-L21 | MCP authority profiles and offline context-pack lifecycle |
65
68
 
66
69
  ## Command Ownership
67
70
 
@@ -79,6 +82,8 @@ against `cairn help` so a new command cannot bypass a curriculum decision.
79
82
  | `cairn trajectory` | L13 |
80
83
  | `cairn artifact` | L13 |
81
84
  | `cairn capabilities` | L15 |
85
+ | `cairn mcp-tools` | L20 |
86
+ | `cairn pack` | L21 |
82
87
  | `cairn notes` | L13 |
83
88
  | `cairn eval` | L16 |
84
89
  | `cairn skill` | L19 |
@@ -1,6 +1,6 @@
1
1
  # Cairnkeep feature guide
2
2
 
3
- **Baseline:** Cairnkeep 2.8.0
3
+ **Baseline:** Cairnkeep 2.9.0
4
4
 
5
5
  This is the step-back map for choosing and operating Cairnkeep features. The
6
6
  [course labs](https://github.com/cairnkeep/cairnkeep-course-labs) provide one
@@ -33,6 +33,8 @@ Run setup in that order, then confirm `cairn doctor`, `cairn sync --check`, and
33
33
  | 6 | Typed nodes and capability governance | Filtering and centrally inspectable feature state are needed |
34
34
  | 7 | Evaluation and ablation | A concrete change needs bounded measurement |
35
35
  | 8 | Validated skill improvement | Repeated resolved hindsight warrants a measured skill change |
36
+ | 9 | Least-authority MCP profiles | A client should receive fewer tools than the default catalog |
37
+ | 10 | Immutable context packs | Reviewed external context should be pinned without becoming memory |
36
38
 
37
39
  Every stage is independently useful. Stages 4-8 are opt-in and are not
38
40
  prerequisites for ordinary memory.
@@ -58,6 +60,8 @@ prerequisites for ordinary memory.
58
60
  | Context exploration | Configure an operator-owned exploration binary or route endpoint | Source/context goes only to the selected local or remote component | Check citations/cache; remove variables and relaunch | `course-04-operation` |
59
61
  | Containers | Rootless memory or workspace launcher | Named volumes persist; shared checkout mode is read/write, sandbox mode copies into a volume | Inspect mounts/volumes; remove only explicitly named disposable resources | `course-04-operation` |
60
62
  | Managed overlays | Separate distribution manifest, wrapper, profile lock, fleet and rollback gates | Policy and secrets belong in the private distribution/machine config, never core | `overlay info`, doctor, fleet dry run/current state, rollback | `course-04-operation` |
63
+ | MCP tool profiles | `cairn mcp-tools set full|read-only|custom` | Strict mode-`0600` project config; process overrides take precedence; profile only removes tools | Inspect catalog/status digest; reset and restart MCP | `course-10-trust-context` |
64
+ | Context packs | Manual local or commit-pinned Git install plus project enablement | Immutable objects and atomic pointers under `CAIRN_PACK_BASE_DIR`; no background sync | Validate, inspect digest, check/apply update, disable/remove | `course-10-trust-context` |
61
65
 
62
66
  ## Evidence, governance, and measurement
63
67
 
@@ -71,8 +75,9 @@ prerequisites for ordinary memory.
71
75
  | Typed nodes/import | `CAIRN_TYPED_MEMORY_NODES=1` | Restart MCP server; tool schema changes | Hard-filter search; dry-run, replay-safe import; `cairn doctor --repair` only for derived state | `course-05-evidence` |
72
76
  | Capability contract | `CAIRN_CAPABILITY_CONTRACT=1` | MCP changes require restart; operating changes apply next invocation | `cairn capabilities list|status|enable|disable|reset|logging`; digest identifies state only | `course-06-governance` |
73
77
  | Evaluation | `CAIRN_EVAL=1` for the coordinator process | No harness chosen by Cairnkeep | `validate` before `run`; inspect report, missingness and evidence scope; dry-run prune/delete | `course-07-evaluation` |
74
- | Validated skill improvement | Reviewed recurring hindsight; proposal adapter; `CAIRN_EVAL=1` for evaluation | No server restart; explicit subprocesses only | `cairn skill list|show`; exact-digest apply; concurrent-edit-safe rollback | Planned: `course-09-skill` |
78
+ | Validated skill improvement | Reviewed recurring hindsight; proposal adapter; `CAIRN_EVAL=1` for evaluation | No server restart; explicit subprocesses only | `cairn skill list|show`; exact-digest apply; concurrent-edit-safe rollback | `course-09-skill` |
75
79
  | General meta-agent loop | Not shipped | Not applicable | Skill-file lifecycle only; no generic configuration loop or scheduler | `course-07-evaluation` |
80
+ | Pack retrieval and skills | `CAIRN_CONTEXT_PACKS=1`; HTTP needs separate consent; skills need exact-digest approval | Restart MCP server | `cairn pack skills`; revoke approval or disable pack; no automatic execution | `course-10-trust-context` |
76
81
 
77
82
  ## Harness and maintenance checks
78
83
 
@@ -49,7 +49,9 @@ expanded only after their labs are executable.
49
49
  | L16 | [Evaluation and ablation](lessons/L16-evaluation.md) | Brief | 50 min |
50
50
  | L17 | [The agent boundary](lessons/L17-agent-boundary.md) | Brief | 25 min |
51
51
  | L18 | [Local code graph](lessons/L18-local-code-graph.md) | Brief | 35 min |
52
- | L19 | [Validated skill improvement](lessons/L19-validated-skill-improvement.md) | Brief | 50 min |
52
+ | L19 | [Validated skill improvement](lessons/L19-validated-skill-improvement.md) | Ready | 50 min |
53
+ | L20 | [Least-authority MCP tool profiles](lessons/L20-mcp-tool-profiles.md) | Ready | 25 min |
54
+ | L21 | [Immutable context packs and skill approval](lessons/L21-context-packs.md) | Ready | 40 min |
53
55
 
54
56
  The [curriculum coverage map](CURRICULUM-MAP.md) records where every public
55
57
  feature is introduced, practised, and operated. It also marks design-only work
@@ -68,7 +70,9 @@ Every complete lesson contains:
68
70
 
69
71
  The learner should never need optional infrastructure to complete L00-L06.
70
72
  Remote memory, RAG, routing, containers, graph indexing, structured capture,
71
- typed nodes, capability governance, and evaluation are separate opt-in modules.
73
+ typed nodes, capability governance, evaluation, and context packs are separate
74
+ opt-in modules. MCP profiles are restrictive and never activate an optional
75
+ feature.
72
76
 
73
77
  ## For contributors
74
78
 
@@ -3,7 +3,7 @@
3
3
  **Status:** Ready
4
4
  **Track:** Quickstart
5
5
  **Time:** 10 minutes
6
- **Tested with:** Cairnkeep 2.8.0
6
+ **Tested with:** Cairnkeep 2.9.0
7
7
 
8
8
  ## Outcome
9
9
 
@@ -3,7 +3,7 @@
3
3
  **Status:** Ready
4
4
  **Track:** Quickstart
5
5
  **Time:** 15 minutes
6
- **Tested with:** Cairnkeep 2.8.0
6
+ **Tested with:** Cairnkeep 2.9.0
7
7
 
8
8
  ## Outcome
9
9
 
@@ -26,7 +26,7 @@ ephemeral; the named course volume is persistent.
26
26
  1. Pull the public image:
27
27
 
28
28
  ```bash
29
- podman pull ghcr.io/cairnkeep/cairnkeep:2.8.0
29
+ podman pull ghcr.io/cairnkeep/cairnkeep:2.9.0
30
30
  ```
31
31
 
32
32
  2. Start the stdio server with a read-only root filesystem and no Linux
@@ -38,7 +38,7 @@ ephemeral; the named course volume is persistent.
38
38
  --read-only --cap-drop=all --security-opt=no-new-privileges \
39
39
  --tmpfs=/tmp:rw,noexec,nosuid,size=64m,mode=1777 \
40
40
  --volume cairnkeep-course-data:/data:Z,U \
41
- ghcr.io/cairnkeep/cairnkeep:2.8.0 stdio
41
+ ghcr.io/cairnkeep/cairnkeep:2.9.0 stdio
42
42
  ```
43
43
 
44
44
  3. The process waits quietly for MCP input. Press `Ctrl-C` after confirming it
@@ -3,7 +3,7 @@
3
3
  **Status:** Ready
4
4
  **Track:** Quickstart
5
5
  **Time:** 25 minutes
6
- **Tested with:** Cairnkeep 2.8.0 and Node.js 22 or newer
6
+ **Tested with:** Cairnkeep 2.9.0 and Node.js 22 or newer
7
7
 
8
8
  ## Outcome
9
9
 
@@ -41,7 +41,7 @@ machine-level steps.
41
41
  2. Install Cairnkeep:
42
42
 
43
43
  ```bash
44
- npm install --global @cairnkeep/cli@2.8.0
44
+ npm install --global @cairnkeep/cli@2.9.0
45
45
  cairn --version
46
46
  ```
47
47
 
@@ -3,7 +3,7 @@
3
3
  **Status:** Ready
4
4
  **Track:** Quickstart
5
5
  **Time:** 25 minutes
6
- **Tested with:** Cairnkeep 2.8.0
6
+ **Tested with:** Cairnkeep 2.9.0
7
7
 
8
8
  ## Outcome
9
9
 
@@ -1,9 +1,9 @@
1
1
  # L19 - Validated skill improvement
2
2
 
3
- **Status:** Brief
3
+ **Status:** Ready
4
4
  **Track:** Evidence and Evaluation
5
- **Planned time:** 50 minutes
6
- **Introduced in:** Cairnkeep 2.8.0
5
+ **Time:** 50 minutes
6
+ **Tested with:** Cairnkeep 2.9.0
7
7
 
8
8
  ## Outcome
9
9
 
@@ -12,7 +12,7 @@ skill proposal, measure it on separate exploration and confirmation tasks,
12
12
  apply only the exact eligible digest, and prove rollback without risking a real
13
13
  project.
14
14
 
15
- ## Planned lesson
15
+ ## Lesson
16
16
 
17
17
  - Why harvest requires failures from at least two sessions and at least one
18
18
  recorded resolution.
@@ -31,30 +31,45 @@ project.
31
31
 
32
32
  ## Hands-on lab
33
33
 
34
- Use a future disposable `course-09-skill` checkpoint containing synthetic
35
- hindsight evidence, a small `SKILL.md`, deterministic proposal and evaluation
36
- adapters, and separate committed task sets. The lab will run:
34
+ Use the disposable `course-09-skill` checkpoint from the synthetic course
35
+ repository. It contains bounded hindsight evidence, one existing `SKILL.md`,
36
+ deterministic proposal and evaluation adapters, and separate committed task
37
+ sets. Keep every generated artifact under `.course-state/`:
37
38
 
38
39
  ```bash
39
- cairn skill harvest --project . --json
40
- cairn skill show --kind candidate --id CANDIDATE_ID
41
- cairn skill review --candidate CANDIDATE_ID --approve --json
42
- cairn skill propose --candidate CANDIDATE_ID --target skills/demo/SKILL.md \
43
- --adapter fixtures/proposal-adapter.json --json
40
+ git switch --detach course-09-skill
41
+ scripts/reset-course-state.sh --yes
42
+ node scripts/setup-skill-lab.mjs
43
+ core=$(node scripts/locate-cairnkeep-core.mjs)
44
+ lab="$PWD/.course-state/skill-project"
45
+ export CAIRN_AGENTFS_BASE_DIR="$PWD/.course-state/agentfs"
46
+
47
+ "$core/bin/cairn" skill harvest --project "$lab" --json
48
+ "$core/bin/cairn" skill show --project "$lab" \
49
+ --kind candidate --id CANDIDATE_ID
50
+ "$core/bin/cairn" skill review --project "$lab" \
51
+ --candidate CANDIDATE_ID --approve --json
52
+ "$core/bin/cairn" skill propose --project "$lab" \
53
+ --candidate CANDIDATE_ID --target skills/course-review/SKILL.md \
54
+ --adapter "$lab/fixtures/proposal-adapter.json" --json
44
55
 
45
56
  export CAIRN_EVAL=1
46
- cairn skill evaluate --proposal PROPOSAL_ID \
47
- --exploration-task-set eval/exploration.json \
48
- --confirmation-task-set eval/confirmation.json \
49
- --adapter eval/adapter.json --repetitions 2 --yes --json
50
-
51
- cairn skill apply --proposal PROPOSAL_ID --evaluation EVALUATION_ID \
57
+ "$core/bin/cairn" skill evaluate --project "$lab" \
58
+ --proposal PROPOSAL_ID \
59
+ --exploration-task-set "$lab/eval/exploration.json" \
60
+ --confirmation-task-set "$lab/eval/confirmation.json" \
61
+ --adapter "$lab/eval/eval-adapter.json" \
62
+ --repetitions 1 --minimum-improvement 1 --yes --json
63
+
64
+ "$core/bin/cairn" skill apply --project "$lab" \
65
+ --proposal PROPOSAL_ID --evaluation EVALUATION_ID \
52
66
  --confirm FULL_PROPOSAL_DIGEST --json
53
- cairn skill rollback --application APPLICATION_ID --confirm --json
67
+ "$core/bin/cairn" skill rollback --project "$lab" \
68
+ --application APPLICATION_ID --confirm --json
54
69
  ```
55
70
 
56
- The lesson remains a Brief until that checkpoint is public and every command is
57
- rehearsed against the release package.
71
+ Before applying, deliberately try an incorrect digest and verify it is rejected.
72
+ After rollback, compare the target with `fixtures/skill/SKILL.md` byte for byte.
58
73
 
59
74
  ## Acceptance criteria
60
75
 
@@ -69,6 +84,22 @@ rehearsed against the release package.
69
84
  - The learner can explain why an eligible small task set supports one local
70
85
  decision but not a universal performance claim.
71
86
 
87
+ ## Common failures
88
+
89
+ - If harvest returns no candidate, confirm the evidence contains the same
90
+ failure family in at least two distinct sessions and a recorded resolution.
91
+ - If proposal validation rejects the adapter program, regenerate the lab and
92
+ verify its configuration resolves to the reviewed executable by absolute
93
+ path.
94
+ - If evaluation is disabled, set `CAIRN_EVAL=1` only for this disposable lab
95
+ and retain the explicit `--yes` confirmation.
96
+ - If task validation reports overlap or a mutable revision, use the committed
97
+ exploration and confirmation fixtures from `course-09-skill` unchanged.
98
+ - If apply rejects the confirmation, copy the full `proposal_digest` from the
99
+ reviewed proposal rather than an ID, prefix, or candidate-content digest.
100
+ - If rollback reports a concurrent target change, stop and inspect that edit;
101
+ do not overwrite it by copying the backup manually.
102
+
72
103
  ## Privacy and trust boundary
73
104
 
74
105
  Hindsight excerpts and skill content remain local until candidate approval.
@@ -0,0 +1,67 @@
1
+ # L20 - Least-authority MCP tool profiles
2
+
3
+ **Status:** Ready
4
+ **Tested with:** Cairnkeep 2.9.0 and Node.js 22 or newer
5
+ **Time:** 25 minutes
6
+
7
+ ## Outcome
8
+
9
+ Classify every MCP tool as an observation or mutation, apply a read-only project
10
+ profile, replace it with an exact allowlist, and prove that invalid authority is
11
+ rejected before server startup.
12
+
13
+ ## Exercise
14
+
15
+ Use a disposable directory so no real project policy changes:
16
+
17
+ ```bash
18
+ lab=$(mktemp -d)
19
+ cairn mcp-tools list --json >"$lab/catalog.json"
20
+ cairn mcp-tools status --project "$lab" --json
21
+ cairn mcp-tools set read-only --project "$lab"
22
+ cairn mcp-tools status --project "$lab" --json >"$lab/read-only.json"
23
+ test "$(stat -c '%a' "$lab/.ai/mcp-tools.json" 2>/dev/null || stat -f '%Lp' "$lab/.ai/mcp-tools.json")" = 600
24
+ cairn mcp-tools set custom --tool memory_read --tool memory_search --project "$lab"
25
+ cairn mcp-tools status --project "$lab" --json >"$lab/custom.json"
26
+ ```
27
+
28
+ Inspect the catalog. Every entry must contain a title and four Boolean hints.
29
+ The read-only profile must contain only tools whose `readOnlyHint` is true. The
30
+ custom profile contains exactly the two named tools in canonical discovery
31
+ order.
32
+
33
+ Confirm environment precedence without changing the project file:
34
+
35
+ ```bash
36
+ CAIRN_MCP_TOOL_PROFILE=full cairn mcp-tools status --project "$lab" --json
37
+ ```
38
+
39
+ The source is `environment`; the project remains custom when the override is
40
+ removed. A profile cannot enable a feature-gated tool, and a disabled capability
41
+ still removes its tool. Restart the memory server after profile changes.
42
+
43
+ ## Common failures
44
+
45
+ - `custom` without `--tool` is invalid because an empty accidental server is
46
+ more likely to be a configuration mistake than useful least authority.
47
+ - Unknown names and a group/world-readable project config fail closed.
48
+ - A running MCP session keeps its discovery snapshot until restarted.
49
+
50
+ ## Privacy and trust boundary
51
+
52
+ Profiles do not read tool payloads or add telemetry. The digest identifies the
53
+ allowlist, not the user's identity or the independent capability state. Client
54
+ approval remains necessary for mutations even when a profile exposes them.
55
+
56
+ ## Recovery and acceptance
57
+
58
+ ```bash
59
+ cairn mcp-tools reset --project "$lab"
60
+ test ! -e "$lab/.ai/mcp-tools.json"
61
+ rm -rf "$lab"
62
+ ```
63
+
64
+ - Unknown custom tool names fail `set`, server startup, and `cairn doctor`.
65
+ - Profile and capability digests are independent.
66
+ - Conservative clients may execute read-only observations; mutations still
67
+ require their approval policy.