pi-braid 0.40.1 → 0.40.2

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 (84) hide show
  1. package/CONTRIBUTING.md +27 -3
  2. package/README.md +13 -13
  3. package/TOOLS.md +27 -3
  4. package/build-info.json +9 -0
  5. package/dist/extensions/cognitive/metacognition/handlers/hypothesize.d.ts +9 -0
  6. package/dist/extensions/cognitive/metacognition/handlers/hypothesize.js +13 -1
  7. package/dist/extensions/cognitive/metacognition/handlers/verify.js +35 -4
  8. package/dist/extensions/core/prompt-builder/inspect.js +9 -3
  9. package/dist/extensions/enforcement/handlers/register-tool-result-formatting.d.ts +1 -1
  10. package/dist/extensions/enforcement/handlers/register-tool-result-formatting.js +1 -1
  11. package/dist/extensions/enforcement/handlers/turn-end-handler.js +1 -1
  12. package/dist/extensions/enforcement/self-state-claims.d.ts +1 -1
  13. package/dist/extensions/enforcement/self-state-claims.js +3 -2
  14. package/dist/extensions/manifest.js +2 -2
  15. package/dist/extensions/memory/context-manager/handlers/tool-batch-boundary.d.ts +22 -5
  16. package/dist/extensions/memory/context-manager/handlers/tool-batch-boundary.js +43 -11
  17. package/dist/extensions/memory/context-manager/handlers/tools/context-compress.js +174 -50
  18. package/dist/extensions/memory/context-manager/handlers/tools/context-navigate.js +4 -1
  19. package/dist/extensions/memory/memory-agent-bridge/memory-store-tool.js +16 -0
  20. package/dist/extensions/memory/memory-agent-bridge/memory-tool.js +21 -9
  21. package/dist/extensions/memory/scratchpad/format.js +8 -2
  22. package/dist/extensions/memory/scratchpad/index.js +11 -2
  23. package/dist/extensions/memory/session-recall/index.js +19 -6
  24. package/dist/extensions/memory/three-memory-stores/episodes.d.ts +1 -1
  25. package/dist/extensions/memory/three-memory-stores/episodes.js +2 -2
  26. package/dist/extensions/orchestrator/index.js +73 -8
  27. package/dist/extensions/self/health-maintenance/index.js +112 -9
  28. package/dist/lib/config/braid-settings.d.ts +21 -0
  29. package/dist/lib/config/braid-settings.js +36 -0
  30. package/dist/lib/constants/session-thresholds.d.ts +2 -3
  31. package/dist/lib/constants/session-thresholds.js +2 -3
  32. package/dist/lib/enforcement/turn-dedup.d.ts +2 -2
  33. package/dist/lib/enforcement/turn-dedup.js +2 -2
  34. package/dist/lib/harness/index.d.ts +1 -1
  35. package/dist/lib/harness/index.js +1 -1
  36. package/dist/lib/harness/types.d.ts +1 -1
  37. package/dist/lib/harness/types.js +1 -1
  38. package/dist/lib/orchestrator/index.d.ts +2 -2
  39. package/dist/lib/orchestrator/index.js +1 -1
  40. package/dist/lib/orchestrator/workers.d.ts +184 -2
  41. package/dist/lib/orchestrator/workers.js +521 -6
  42. package/dist/lib/utils/injection-tracker.js +1 -1
  43. package/docs/CONTEXT-POLICY.md +13 -5
  44. package/docs/LOCAL_DEV.md +31 -5
  45. package/docs/ROADMAP.md +10 -7
  46. package/docs/SETUP.md +3 -2
  47. package/package.json +11 -8
  48. package/skills/braid-reference/SKILL.md +23 -23
  49. package/skills/release-pipeline/SKILL.md +46 -37
  50. package/skills/subagent-orchestration/SKILL.md +51 -1
  51. package/src/extensions/cognitive/metacognition/handlers/hypothesize.ts +14 -1
  52. package/src/extensions/cognitive/metacognition/handlers/verify.ts +39 -5
  53. package/src/extensions/core/prompt-builder/inspect.ts +10 -3
  54. package/src/extensions/enforcement/AGENTS.md +25 -19
  55. package/src/extensions/enforcement/handlers/register-tool-result-formatting.ts +1 -1
  56. package/src/extensions/enforcement/handlers/turn-end-handler.ts +1 -1
  57. package/src/extensions/enforcement/self-state-claims.ts +3 -2
  58. package/src/extensions/heartbeat/heartbeat-scheduler/AGENTS.md +6 -3
  59. package/src/extensions/manifest.ts +2 -2
  60. package/src/extensions/memory/AGENTS.md +13 -5
  61. package/src/extensions/memory/context-manager/handlers/tool-batch-boundary.ts +45 -11
  62. package/src/extensions/memory/context-manager/handlers/tools/context-compress.ts +202 -60
  63. package/src/extensions/memory/context-manager/handlers/tools/context-navigate.ts +4 -1
  64. package/src/extensions/memory/memory-agent-bridge/memory-store-tool.ts +16 -0
  65. package/src/extensions/memory/memory-agent-bridge/memory-tool.ts +22 -9
  66. package/src/extensions/memory/scratchpad/format.ts +8 -2
  67. package/src/extensions/memory/scratchpad/index.ts +12 -2
  68. package/src/extensions/memory/session-recall/index.ts +20 -8
  69. package/src/extensions/memory/three-memory-stores/episodes.ts +2 -2
  70. package/src/extensions/orchestrator/index.ts +100 -11
  71. package/src/extensions/scheduling/timer/AGENTS.md +7 -0
  72. package/src/extensions/self/health-maintenance/index.ts +143 -14
  73. package/src/extensions/self/watchdog/AGENTS.md +1 -0
  74. package/src/lib/AGENTS.md +21 -21
  75. package/src/lib/config/braid-settings.ts +74 -0
  76. package/src/lib/constants/session-thresholds.ts +2 -3
  77. package/src/lib/enforcement/turn-dedup.ts +2 -2
  78. package/src/lib/harness/AGENTS.md +1 -1
  79. package/src/lib/harness/index.ts +1 -1
  80. package/src/lib/harness/types.ts +1 -1
  81. package/src/lib/orchestrator/index.ts +26 -0
  82. package/src/lib/orchestrator/workers.ts +705 -7
  83. package/src/lib/utils/AGENTS.md +1 -1
  84. package/src/lib/utils/injection-tracker.ts +1 -1
package/docs/ROADMAP.md CHANGED
@@ -51,16 +51,19 @@ provenance; they are no longer work.
51
51
  2. **Version-drift cleanup** - RESOLVED: the four workspace packages declare
52
52
  the pi peer as `"*"`; the root manifest pins the installed version
53
53
  (`package.json`, the `@earendil-works/*` deps).
54
- 3. **Tag-scheme unification** - RESOLVED: two tag roles under one `v` prefix, recorded in
55
- the root `CHANGELOG.md` - iteration tags `v0.40.0-main.N` (`package.json`
56
- `0.40.0-main.N`), release tag `v0.40.0`.
54
+ 3. **Tag-scheme unification** - RESOLVED: two tag roles, one namespace per package, recorded in
55
+ the root `CHANGELOG.md` - core keeps the bare `v` (iteration tags `v0.40.0-main.N`,
56
+ `package.json` `0.40.0-main.N`; release tag `v0.40.0`), every sibling tags as
57
+ `<workspace>-v<version>` (`telegram-v0.1.4`).
57
58
  4. **CI private-data gate** - RESOLVED: `check-private-data.mjs` is a CI step
58
59
  and scans the whole tree by default (tracked plus untracked); the
59
60
  staged-file checks are a local pre-commit convenience.
60
- 5. **Skills pack** - finish validating the six skills still marked
61
+ 5. **Skills pack** - finish validating the five skills still marked
61
62
  `verdict: UNVALIDATED` (`braid-reference`, `misdirection-audit`,
62
- `placement-discipline`, `probe-evaluation`, `v2raytun-reconnect`,
63
- `voice-replies`); keep the pack catalog fresh as decision rows land.
63
+ `placement-discipline`, `probe-evaluation`, `voice-replies`); keep the pack
64
+ catalog fresh as decision rows land. The machine-local `tunnel-control`
65
+ skill is `KEEP` with its v2RayTun arm validated; its Happ and Incy arms
66
+ stay unvalidated until a host installs those clients.
64
67
  6. **Extension surface** - ongoing de-bloat of tool/extension counts;
65
68
  subagent-RPC hardening. Worker-stats reporting shipped (`list-workers`
66
69
  `includeStats`); the orchestrator's metrics-emission half (writing
@@ -79,7 +82,7 @@ knowledge base.
79
82
  8. **Small-correctness batch** - RESOLVED: the `prompt_inspect` exclusion is
80
83
  pinned by `test-prompt-inspect-exclusion.mjs`; the watchdog tunnel-counter
81
84
  canary is a getMe-based liveness probe
82
- (`telegram/src/lib/inbound-poller.ts`); the v2raytun status description is
85
+ (`telegram/src/lib/inbound-poller.ts`); the tunnel status description is
83
86
  complete in the shipped skill. Effort S.
84
87
  9. **Cross-provider fallback on quota death** - RESOLVED: the route-order
85
88
  engine walks to the next route, with bounded turn-level fail-back
package/docs/SETUP.md CHANGED
@@ -303,7 +303,7 @@ The user-global file always exists; the project one is optional and belongs to p
303
303
  | `braid.modules.<ref>` | boolean | per manifest | Force-enable (`true`) or disable (`false`) an extension id or module group (`memory`, `heartbeat`); a persisted `false` removes a default-enabled extension from the boot set (see [§ Module toggling](#module-toggling)). |
304
304
  | `braid.suppressNudges` | boolean | `false` | Silence all cognitive nudges (enforcement whispers, heartbeat suggestions, feedback reminders). |
305
305
  | `braid.timezone` | IANA name | `Europe/Moscow` | Time zone for all braid-facing time rendering. |
306
- | `braid.enforcement.nudgeConfigs.<type>` | object | built-in per-type defaults | Per-nudge-type overrides with fields `baseCooldownMs` (number), `escalateAfter` (number), `deduplicate` (boolean). Types: `validation`, `recordFailure`, `malformed`, `memory`, `scratchpad`, `context`, `sessionSignals`. Invalid entries are logged and dropped. |
306
+ | `braid.enforcement.nudgeConfigs.<type>` | object | built-in per-type defaults | Per-nudge-type overrides with leaf shape `braid.enforcement.nudgeConfigs.<type>.<key>`; accepted fields are `baseCooldownMs` (number), `escalateAfter` (number), and `deduplicate` (boolean). Types: `validation`, `recordFailure`, `malformed`, `memory`, `scratchpad`, `context`, `sessionSignals`. Invalid entries are logged and dropped. |
307
307
  | `braid.memory.writeGate` | object | gate ON, 20-min cooldown, `enforce` | Review-before-write gate on episode writes; `mode: "warn"` logs decisions and writes anyway; `sites` opts individual writers out. |
308
308
  | `braid.timers.maxWakeAttempts` | integer 1..10 | `3` | Redelivery cap for a failed timer wake before it is dropped with a visible notice. |
309
309
  | `braid.timers.wakeAlert` | object | ON, `outcomeTimeouts: 2` | Dead-wake page: repeated outcome timeouts / exhausted redeliveries feed the watchdog's wake-delivery condition, which pages the owner out of band (telegram) once per episode plus one recovery line. `mode: "off"` disables the feed (delivery itself is unchanged); `outcomeTimeouts` is an integer 2..10 (1 would page on every normal long turn). |
@@ -315,6 +315,7 @@ The user-global file always exists; the project one is optional and belongs to p
315
315
  | `braid.telegram.notifyMaxChars` | positive number | `1200` | Craft target and guard for turn-end notifications. |
316
316
  | `braid.telegram.pauseStateFile` | path string | built-in default | Override for the `/telegram` pause-state file path. |
317
317
  | `braid.contrib.<name>` | boolean or object | enabled / per-extension | Per-contrib-extension config - see [§ Contrib extensions](#contrib-extensions). |
318
+ | `braid.contrib.<extensionName>.enabled` | string[] | unset | Generic per-extension tool-enable list. The shared helper reads and writes string entries; the `/tools` surface stores its shared list in `braid.contrib._global.enabled`. |
318
319
 
319
320
  ### Worked example
320
321
 
@@ -348,7 +349,7 @@ The 12 contrib extension names: `browser`, `codebase`, `diff`, `healthcheck`, `n
348
349
  - `braid.contrib.browserAdvanced: true` - the 7 advanced browser tools (opt-in).
349
350
  - `braid.contrib.pathSecurity.block: true` - hard-block dangerous operations instead of soft-warn.
350
351
  - `braid.contrib.observatory.record: true` - record session lifecycle events.
351
- - `braid.contrib.networkMonitor` - `{ profileName, reachabilityUrl, curlTimeoutSecs, disconnectDelayMs, connectTimeoutMs, pollIntervalMs, cooldownMs, autoReconnect, autoWatch, probeIntervalMs, maxAttemptsPerOutage, reconnectCooldownMs }`.
352
+ - `braid.contrib.networkMonitor` - `{ client, profileName, reachabilityUrl, curlTimeoutSecs, disconnectDelayMs, connectTimeoutMs, pollIntervalMs, cooldownMs, autoReconnect, autoWatch, probeIntervalMs, outageThreshold, maxAttemptsPerOutage, reconnectCooldownMs, logFile }`. The watcher toggles only after `outageThreshold` consecutive failed probes (default 3, probes spaced by `probeIntervalMs`); the toggle mechanism comes from the client adapter (app deep links, or the NE profile via `scutil --nc stop|start`), and settings are re-read while the extension runs.
352
353
  - `braid.contrib["rate-limiter"]` - `{ rpm, tpm, providers: { <provider>: { rpm, tpm } } }` ceilings; note the hyphenated key (the bundle toggle name for the extension itself is `rateLimiter`).
353
354
  - `braid.contrib._global.enabled: [...]` - global tool list managed by the tool-config extension.
354
355
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-braid",
3
- "version": "0.40.1",
3
+ "version": "0.40.2",
4
4
  "description": "Metacognitive extension suite for pi-coding-agent: enforcement, memory, reasoning, self-improvement, and structured cognitive signals.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -19,7 +19,8 @@
19
19
  "LICENSE",
20
20
  "AGENTS.md",
21
21
  "CONTRIBUTING.md",
22
- "TOOLS.md"
22
+ "TOOLS.md",
23
+ "build-info.json"
23
24
  ],
24
25
  "repository": {
25
26
  "type": "git",
@@ -56,11 +57,13 @@
56
57
  "check:instruction-strings": "node scripts/check-instruction-strings.mjs",
57
58
  "check:doc-index": "node scripts/check-doc-index.mjs",
58
59
  "check:schema": "node scripts/check-braid-schema.mjs",
60
+ "check:settings-docs": "node scripts/check-settings-doc-coverage.mjs",
59
61
  "ci:check": "npm run check:docs && npm run check:doc-drift && npm run check:instruction-strings && npm run check:doc-index && npm run check:deps && npm run check:labels && npx tsc --noEmit && npm test",
60
62
  "release:local": "node scripts/publish-local.mjs",
61
63
  "publish:local": "node scripts/publish-local.mjs",
62
64
  "dev:link": "npm link && cd ~/.pi/agent/local-packages && npm link pi-braid",
63
- "prepack": "npm run build"
65
+ "prepack": "npm run build && node scripts/pack-provenance.mjs write",
66
+ "postpack": "node scripts/pack-provenance.mjs remove"
64
67
  },
65
68
  "devDependencies": {
66
69
  "@eslint/js": "10.0.1",
@@ -73,11 +76,11 @@
73
76
  "typescript-eslint": "8.59.1"
74
77
  },
75
78
  "peerDependencies": {
76
- "@earendil-works/pi-agent-core": "*",
77
- "@earendil-works/pi-ai": "*",
78
- "@earendil-works/pi-coding-agent": "*",
79
- "@earendil-works/pi-tui": "*",
80
- "typebox": "*"
79
+ "@earendil-works/pi-agent-core": "^1.2.0",
80
+ "@earendil-works/pi-ai": "^1.2.0",
81
+ "@earendil-works/pi-coding-agent": "^1.2.0",
82
+ "@earendil-works/pi-tui": "^1.2.0",
83
+ "typebox": "^1.1.38"
81
84
  },
82
85
  "keywords": [
83
86
  "pi-package",
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: braid-reference
3
3
  description: "Find braid's own documentation: context policy and compaction, timers and wakes, workers and the orchestrator registry, the Telegram channel, prompt and discipline rules, memory stores, the skills catalog, release and install paths, health maintenance, extensions and the polyfill. Use when a question is about braid internals, before editing braid, or when a braid behavior needs its owning doc named instead of guessed."
4
- validated: 2026-10-08
4
+ validated: 2026-10-18
5
5
  verdict: KEEP
6
6
  ---
7
7
 
@@ -21,7 +21,7 @@ Braid ships as separate packages, and docs live under each package root. Find th
21
21
  | `skills` | the on-demand pack: `skills/<name>/SKILL.md`, `README.md`, `AGENTS.md` |
22
22
  | `telegram` | `README.md`, `docs/` |
23
23
 
24
- This file sits at `<core>/skills/braid-reference/SKILL.md`, so the core root is two levels up. The core skill set ships with the core package; the `skills` package root carries only the on-demand pack; machine-local skills such as `v2raytun-reconnect` live in `~/.pi/agent/skills/`.
24
+ This file sits at `<core>/skills/braid-reference/SKILL.md`, so the core root is two levels up. The core skill set ships with the core package; the `skills` package root carries only the on-demand pack; machine-local skills such as `tunnel-control` live in `~/.pi/agent/skills/`.
25
25
 
26
26
  ```bash
27
27
  # 1. core root — two levels above this SKILL.md
@@ -40,27 +40,27 @@ In the monorepo the roots are `packages/core`, `packages/skills`, `packages/tele
40
40
 
41
41
  Paths below are checkout paths: strip the leading `packages/<name>/` and prepend that package's root. The `Shipped` column says whether the file is in the published tarball (`npm`) or exists only in a checkout (`checkout`).
42
42
 
43
- | Topic | Doc | Shipped |
44
- | --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------- |
45
- | What braid is, install paths, module toggling, storage | `packages/core/README.md`, `packages/core/docs/SETUP.md` | npm |
46
- | First walkthrough: anatomy of an extension, writing one | `packages/core/docs/BEGINNERS.md` | npm |
47
- | Context policy: window, reserve, bands, caps, offload | `packages/core/docs/CONTEXT-POLICY.md` | npm |
48
- | Context map: contexts, owners, seam registry, where state lives | `packages/core/docs/CONTEXT-MAP.md` | npm |
49
- | Context automation: proposals, policy engine, cooldown | `packages/core/src/extensions/memory/context-lifecycle/AGENTS.md` | npm |
50
- | What compaction loses and which guards exist | `packages/core/docs/COMPACTION-LOSS-INVESTIGATION.md` | npm |
51
- | Timers, wakes, wake retry, wake-delivery alerts | `packages/core/src/extensions/scheduling/timer/AGENTS.md` | npm |
52
- | Workers, the `orchestrate` tool, locks, merge verification | `packages/core/skills/subagent-orchestration/SKILL.md` | npm |
53
- | Telegram channel: live update, pause control | `packages/telegram/docs/live-update.md`, `packages/telegram/docs/pause-control.md` | npm |
54
- | Telegram package overview: tools, env vars, components; turn-complete auto-notify | `packages/telegram/README.md`, `packages/telegram/docs/turn-complete-notify.md` | npm |
55
- | System prompt composition, identity, whisper sections | `packages/core/src/extensions/core/prompt-builder/AGENTS.md` | npm |
56
- | Enforcement: whisper cap, dedup, nudges, verification judge | `packages/core/src/extensions/enforcement/AGENTS.md` | npm |
57
- | Memory stores: episodes, semantic, heuristics | `packages/core/src/extensions/memory/three-memory-stores/AGENTS.md`, `packages/core/src/extensions/memory/AGENTS.md` | npm |
58
- | Skills: the core set and the on-demand pack, catalog, adding a skill | `packages/skills/README.md`, `packages/skills/AGENTS.md` | npm |
59
- | Release, publish, install paths, upstream pi updates | `packages/core/skills/release-pipeline/SKILL.md`, `packages/core/scripts/update-pipeline.mjs` (plan -> pins -> publishes -> runtime update), `packages/core/scripts/publish-local.mjs` (one target per run, core by default; republish every package whose content changed), `packages/core/docs/LOCAL_DEV.md`, `packages/core/docs/SETUP.md`, `packages/core/CONTRIBUTING.md` | npm |
60
- | Health maintenance, checkpoints, self-repair | `packages/core/src/extensions/self/health-maintenance/AGENTS.md` | npm |
61
- | Extension loading, manifest, module toggles, the polyfill | `packages/core/AGENTS.md`, `packages/core/src/AGENTS.md`, `packages/core/src/extensions/core/AGENTS.md` | npm |
62
- | Every tool and command braid adds | `packages/core/TOOLS.md` | npm |
63
- | Roadmap (forward-looking) and history | `packages/core/docs/ROADMAP.md`, `packages/core/docs/HISTORY.md` | npm |
43
+ | Topic | Doc | Shipped |
44
+ | --------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------- |
45
+ | What braid is, install paths, module toggling, storage | `packages/core/README.md`, `packages/core/docs/SETUP.md` | npm |
46
+ | First walkthrough: anatomy of an extension, writing one | `packages/core/docs/BEGINNERS.md` | npm |
47
+ | Context policy: window, reserve, bands, caps, offload | `packages/core/docs/CONTEXT-POLICY.md` | npm |
48
+ | Context map: contexts, owners, seam registry, where state lives | `packages/core/docs/CONTEXT-MAP.md` | npm |
49
+ | Context automation: proposals, policy engine, cooldown | `packages/core/src/extensions/memory/context-lifecycle/AGENTS.md` | npm |
50
+ | What compaction loses and which guards exist | `packages/core/docs/COMPACTION-LOSS-INVESTIGATION.md` | npm |
51
+ | Timers, wakes, wake retry, wake-delivery alerts | `packages/core/src/extensions/scheduling/timer/AGENTS.md` | npm |
52
+ | Workers, the `orchestrate` tool, locks, merge verification | `packages/core/skills/subagent-orchestration/SKILL.md` | npm |
53
+ | Telegram channel: live update, pause control | `packages/telegram/docs/live-update.md`, `packages/telegram/docs/pause-control.md` | npm |
54
+ | Telegram package overview: tools, env vars, components; turn-complete auto-notify | `packages/telegram/README.md`, `packages/telegram/docs/turn-complete-notify.md` | npm |
55
+ | System prompt composition, identity, whisper sections | `packages/core/src/extensions/core/prompt-builder/AGENTS.md` | npm |
56
+ | Enforcement: whisper cap, dedup, nudges, verification judge | `packages/core/src/extensions/enforcement/AGENTS.md` | npm |
57
+ | Memory stores: episodes, semantic, heuristics | `packages/core/src/extensions/memory/three-memory-stores/AGENTS.md`, `packages/core/src/extensions/memory/AGENTS.md` | npm |
58
+ | Skills: the core set and the on-demand pack, catalog, adding a skill | `packages/skills/README.md`, `packages/skills/AGENTS.md` | npm |
59
+ | Release, publish, install paths, upstream pi updates | `packages/core/skills/release-pipeline/SKILL.md` (local release and remote npm publication through GitHub Actions OIDC) | npm |
60
+ | Health maintenance, checkpoints, self-repair | `packages/core/src/extensions/self/health-maintenance/AGENTS.md` | npm |
61
+ | Extension loading, manifest, module toggles, the polyfill | `packages/core/AGENTS.md`, `packages/core/src/AGENTS.md`, `packages/core/src/extensions/core/AGENTS.md` | npm |
62
+ | Every tool and command braid adds | `packages/core/TOOLS.md` | npm |
63
+ | Roadmap (forward-looking) and history | `packages/core/docs/ROADMAP.md`, `packages/core/docs/HISTORY.md` | npm |
64
64
 
65
65
  Related skills in the core set: `dox` (the AGENTS.md tree), `placement-discipline` (which layer owns a fact), `release-pipeline` (the local publish flow), `skill-usage` (adoption measurement), `pi-reference` (pi core, the layer braid extends).
66
66
 
@@ -1,21 +1,21 @@
1
1
  ---
2
2
  name: release-pipeline
3
- description: "Generic local npm release pipeline for braid packages. Covers: building, packing, installing to local registry, and verifying packages. Extensible for remote publication to npm."
3
+ description: "Release pipeline for braid packages: local builds, packing, installs, and verification; remote npm publication through GitHub Actions OIDC."
4
4
  trigger: "releasing packages, npm publish, local package install, building packages, packing npm packages, package verification"
5
- validated: 2026-08-16
5
+ validated: 2026-10-18
6
6
  verdict: IMPROVE
7
7
  ---
8
8
 
9
9
  # Release Pipeline
10
10
 
11
- Generic local npm release pipeline for braid packages. Extensible for remote publication.
11
+ Local package release and install flow, with remote npm publication through GitHub Actions OIDC.
12
12
 
13
13
  ## Principles
14
14
 
15
15
  1. **Isolation** - workers operate on git worktrees, never the live repo
16
16
  2. **Hygiene** - worktrees and .tgz files are cleaned up after release
17
17
  3. **Traceability** - every release has a version, commit, and timestamp
18
- 4. **Extensibility** - local release is the default; remote publication is a flag
18
+ 4. **Separation** - local package installs use this pipeline; npm publication runs in a separate GitHub Actions OIDC workflow
19
19
 
20
20
  ## Worktree Management
21
21
 
@@ -48,12 +48,9 @@ clean apart from a symlinked `node_modules` - and remove any resurrected path (`
48
48
 
49
49
  ### Step 1: Build
50
50
 
51
- ```
52
- cd <package-dir>
53
- npm run build
54
- ```
55
-
56
- Verify: `npm run typecheck` (or `npx tsc --noEmit`).
51
+ From `<package-dir>`, run `npm run build` when the package defines a build
52
+ script. Run `npm run typecheck` or `npx tsc --noEmit` when the package has a
53
+ TypeScript check.
57
54
 
58
55
  ### Step 2: Pack
59
56
 
@@ -144,25 +141,30 @@ Rules the script enforces:
144
141
  `npm --prefix <global-prefix> install -g @earendil-works/pi-coding-agent@<version>`.
145
142
  - **Publish, do not repack.** `--apply` composes `publish-local.mjs` per braid
146
143
  package; it never packs inline.
147
- - **Verify is static.** `--verify` reads the installed tree, evaluates every
148
- item (it does not short-circuit), and exits non-zero if any item failed; the
149
- live-session checks are printed as a checklist for a real session rather than
150
- automated. It is standalone: it refuses to combine with `--apply`/`--runtime`.
144
+ - **Verify does not start a pi session.** `--verify` reads installed package
145
+ files and settings, evaluates every item, and exits non-zero if any item
146
+ fails. It resolves the current upstream version with `npm view`; live-session
147
+ checks remain a human checklist. It is standalone and refuses
148
+ `--apply`/`--runtime`.
151
149
 
152
150
  ## Remote Publication
153
151
 
154
- To publish to npm (instead of local), override Step 3:
152
+ Remote publication uses `.github/workflows/publish.yml`, separate from the
153
+ local install path. A bare core release tag (`v<core version>`) runs the
154
+ workflow. To publish one sibling package, dispatch it from `main` with
155
+ `only=<package>`; sibling tags do not run this release workflow, and iteration
156
+ tags are refused by its job condition. A release-tag run publishes each stable
157
+ workspace version not already present on npm through trusted publishing (OIDC);
158
+ the workflow uses no npm token.
155
159
 
156
- ```
157
- npm publish
158
- ```
160
+ Preparation:
159
161
 
160
- Pre-requisites:
162
+ - Commit the intended stable package versions. Refresh `package-lock.json` as
163
+ a release convention, as described in `CONTRIBUTING.md`.
164
+ - Configure trusted publishing for the package on npmjs.com.
161
165
 
162
- - `npm login` completed
163
- - Version bumped (`npm version patch|minor|major`)
164
- - CHANGELOG.md updated
165
- - Git tag created (`git tag v<version>`)
166
+ Local CLI publishing is not a fallback: `npm publish` needs 2FA, and this
167
+ account's passkey second factor leaves the CLI OTP prompt nothing to answer.
166
168
 
167
169
  ## Disk Hygiene
168
170
 
@@ -175,17 +177,24 @@ After release:
175
177
 
176
178
  ## Version Convention
177
179
 
178
- - Local releases use the same version as the source package.json
179
- - Bump version before remote publication only
180
- - Use `npm version` for semver bumps: `npm version patch`
181
- - Tag the commit: `git tag v<version> && git push origin v<version>`
182
-
183
- ## CWD Scoping
184
-
185
- Timers and release artifacts are scoped by CWD:
186
-
187
- - Timer files: `~/.pi/agent/braid/projects/<sanitized-cwd>/pending-timers.jsonl`
188
- - Release artifacts are in the package directory, not the pi config directory
189
-
190
- This ensures independent timer pools per project and prevents cross-project
191
- interference.
180
+ - `publish-local.mjs` normally derives `<base>-<branch>.<iteration>` from the
181
+ workspace version; if that version already carries a prerelease, it uses it
182
+ verbatim. The script restores the original manifest after packing.
183
+ - Commit stable package versions before remote npm publication. Local snapshots
184
+ use the derived iteration version instead.
185
+ - Use `npm version` for semver bumps in the target workspace.
186
+ - A bare core release tag (`v<core version>`) runs the publish workflow. Publish
187
+ a sibling package by dispatching from `main` with `only=<package>`.
188
+ `tag-prerelease.mjs` creates package-scoped iteration tags; they do not
189
+ publish.
190
+
191
+ ## Timer and Artifact Locations
192
+
193
+ Timer files are project-scoped at
194
+ `<braid-home>/projects/<canonical-sanitized-cwd>/pending-timers.jsonl`; the
195
+ default braid home is `~/.pi/agent/braid`, and `BRAID_HOME` can override it.
196
+
197
+ `publish-local.mjs` creates a tarball in the workspace directory, copies it
198
+ to `~/.pi/agent/local-packages` (or `LOCAL_PKG`), then removes the workspace
199
+ copy. The installed package and retained tarball use the destination, not the
200
+ project CWD.
@@ -210,6 +210,56 @@ When a worker signals completion, review critically before closing the pane.
210
210
  - **Worker crashes mid-task**: orchestrator detects via `agent_get` status change, spawns replacement.
211
211
  - **Orchestrator is busy**: worker retries signal with backoff (max 3, 60s apart), then writes results to a well-known path.
212
212
 
213
+ ### Gate evidence rows and the population stamp
214
+
215
+ `close-worker` takes `gates` as `{cmd, exit}` rows, one per gate the wave ran. A gate whose
216
+ subject is a file or row population records what it scanned, and at which revision, as an
217
+ optional `stamp` on its row:
218
+
219
+ ```json
220
+ {
221
+ "cmd": "node scripts/check-placement.mjs --strict",
222
+ "exit": 0,
223
+ "stamp": "scanned 914 files at <revision>"
224
+ }
225
+ ```
226
+
227
+ `n` is a non-negative integer, `unit` one lowercase word (`files`, `rows`, `cases`, `lines`),
228
+ and `revision` a 7-to-40-char hex sha or a ref name. `check-result` warns; it does not fail
229
+ when a row whose command carries a walk, list or count verb (`ls`, `find`, `fd`, `git ls-files`,
230
+ `wc`, `rg`, `grep`) carries no stamp or an unreadable one.
231
+
232
+ `verify-and-merge` reads the close's stamped `files` rows and compares each number against that
233
+ revision's tracked-entry census. A recorded number below the census refuses the merge and names
234
+ the delta: the gate certified fewer files than the commit carries, which is what a run before
235
+ `git add` looks like. Re-run the gate on the staged tree and re-issue the close. A close with no
236
+ stamped `files` row prints `no recorded population` and merges.
237
+
238
+ | Setting | Default | Effect | Read cadence |
239
+ | -------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- |
240
+ | `braid.orchestrator.closeGateWellFormedness` | `shadow` | `shadow` logs invalid `{cmd, exit}` rows and allows close; `enforce` refuses an invalid row; `off` skips validation. Commands are not rerun. | Re-read at use time on every `close-worker` close. |
241
+
242
+ ### Claim verifiers and the instrument-capability warn
243
+
244
+ Each claim's `verified_by` is read against a small registry of instrument shapes: search and <!-- doc-ref-exempt: seat-side result-block field; the parser lives in the orchestrator seat, not this repo -->
245
+ count verbs (`grep`, `rg`, `wc`, `count`, `hits`), artifact citations (a report, a readme, a
246
+ description), execution verbs (`boot`, `install`, `exit`, `suite`), content verbs (`read`,
247
+ `measured`, `bytes`, `entries`), and enumeration instruments (`git ls-files`, an AST or
248
+ type-aware census, a suite run, a row count). The claim's wording is read against the property
249
+ class it asserts, and `check-result` warns; it does not fail, when the pair cannot observe
250
+ what the claim asserts:
251
+
252
+ - a coverage or elimination claim ("gone", "no remaining", "every reader") grounded on a
253
+ search or count verb with no census named;
254
+ - a content claim grounded only on an artifact citation (a description is not the content);
255
+ - a classification claim ("only", "private", "leak") grounded on a bare count with no
256
+ decomposition named.
257
+
258
+ The warn names the census shape it wants (`git ls-files`, an AST or type-aware census, a suite
259
+ run, or an explicit row count) and the counter line `claim-capability: k/n checked, m warn(s)`
260
+ reports the share. The tier is warn-only: a mismatched pair leaves the block valid and the exit
261
+ code unchanged. A verifier the registry cannot classify is left to the seat's re-derivation.
262
+
213
263
  ## Completion Signal
214
264
 
215
265
  ### For orchestrate-spawned workers
@@ -239,7 +289,7 @@ braid ships a context-manager: `context_navigate` (tag / checkout) and `context_
239
289
 
240
290
  Enforce a HARD context budget BEFORE degradation begins. Mistakes and loop-risk rise sharply at ~75–100k tokens, independent of window size.
241
291
 
242
- **Trigger (absolute, not %):** when `context_inspect` reports **>80k tokens** OR **>35% of the window** (whichever comes first):
292
+ **Trigger (absolute, not %):** when `context_inspect` reports **>80k tokens** OR **>35% of the window** (whichever comes first). `context_inspect` ships deferred: if it is not in your active set, find it with `tool_search` first:
243
293
 
244
294
  1. `context_navigate action=tag name="pre-archive-<n>"` - mark your position
245
295
  2. `context_compress action=archive topic="<task>"` - archive everything before the tag
@@ -50,6 +50,18 @@ export function emptyResponseRetryOptions(lastError: string): LlmCallOptions | n
50
50
  return { temperature: 0.3, maxTokens: 4000, reasoning: "off" };
51
51
  }
52
52
 
53
+ /**
54
+ * The hypothesis count a call asks for. Argument validation converts a blank
55
+ * string to 0 for `Type.Optional(Type.Number())` and the converted value passes,
56
+ * so a handler cannot tell a blank from a typed 0; a prompt asking the model for
57
+ * zero hypotheses is never a usable request, so a non-positive or non-finite
58
+ * value is read as absent and the documented default (3) applies. Exported pure
59
+ * for the fixture, like emptyResponseRetryOptions above.
60
+ */
61
+ export function resolveMaxHypotheses(value: unknown): number {
62
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 3;
63
+ }
64
+
53
65
  const FORMAT_OPTIONS = ["ranked", "tree", "list"] as const;
54
66
 
55
67
  const hypothesizeSchema = Type.Object({
@@ -133,7 +145,8 @@ export function createHypothesizeTool(): ToolDefinition<any, any, any> {
133
145
  _onUpdate: unknown,
134
146
  ctx: ExtensionContext | undefined,
135
147
  ) => {
136
- const { problem, evidence, maxHypotheses = 3, format = "ranked", verificationPlan } = params;
148
+ const { problem, evidence, format = "ranked", verificationPlan } = params;
149
+ const maxHypotheses = resolveMaxHypotheses(params.maxHypotheses);
137
150
 
138
151
  if (!ctx?.model) {
139
152
  throw new Error(
@@ -83,6 +83,23 @@ const DEFAULT_CRITERIA: Record<VerificationTarget, string[]> = {
83
83
  ],
84
84
  };
85
85
 
86
+ /** A blank string is "not provided": clients that emit every schema key send "" for the unused ones. */
87
+ function optionalString(v: unknown): string | undefined {
88
+ return typeof v === "string" && v.trim().length > 0 ? v : undefined;
89
+ }
90
+
91
+ /**
92
+ * Drop blank criteria entries before use. A list left empty names nothing
93
+ * usable, so the target's defaults stand in: the LLM tier must never receive
94
+ * an empty rubric.
95
+ */
96
+ function resolveCriteria(provided: unknown, target: VerificationTarget): string[] {
97
+ const cleaned = Array.isArray(provided)
98
+ ? provided.filter((c): c is string => typeof c === "string" && c.trim().length > 0)
99
+ : [];
100
+ return cleaned.length > 0 ? cleaned : DEFAULT_CRITERIA[target];
101
+ }
102
+
86
103
  /** Auto-detect the most recent code/reasoning/plan from session messages. */
87
104
  function autoDetectTarget(
88
105
  ctx: ExtensionContext,
@@ -325,16 +342,31 @@ export function createVerifyTool(): ToolDefinition<any, any, any> {
325
342
  const startMs = Date.now();
326
343
  const target = p.target ?? "result";
327
344
  const depth = p.depth ?? "standard";
328
- const criteria = p.criteria ?? DEFAULT_CRITERIA[target];
329
- const confidenceThreshold = p.confidenceThreshold ?? 0.5;
330
-
331
- const text = p.targetText ?? autoDetectTarget(ctx)?.text;
345
+ const criteria = resolveCriteria(p.criteria, target);
346
+ // A blank selector arrives as 0, and a value outside (0,1] can never
347
+ // gate a 0-1 confidence: both are "not provided", and the documented
348
+ // default is 0.5. The default is documented, so this substitutes -
349
+ // it never refuses the call.
350
+ const rawThreshold = p.confidenceThreshold;
351
+ const confidenceThreshold =
352
+ typeof rawThreshold === "number" &&
353
+ Number.isFinite(rawThreshold) &&
354
+ rawThreshold > 0 &&
355
+ rawThreshold <= 1
356
+ ? rawThreshold
357
+ : 0.5;
358
+
359
+ // A blank targetText is "not provided" too: the documented path
360
+ // auto-detects from recent context. Only when that finds nothing does
361
+ // the tool refuse, and the refusal names auto-detection as what ran.
362
+ const providedText = optionalString(p.targetText);
363
+ const text = providedText ?? autoDetectTarget(ctx)?.text;
332
364
  if (!text) {
333
365
  return {
334
366
  content: [
335
367
  {
336
368
  type: "text",
337
- text: "[verify] Could not auto-detect target text from recent context. Provide targetText explicitly.",
369
+ text: "[verify] Auto-detection ran over recent context and found no target text. Provide targetText explicitly.",
338
370
  },
339
371
  ],
340
372
  details: { passed: false, reason: "no-text" },
@@ -431,6 +463,8 @@ export function createVerifyTool(): ToolDefinition<any, any, any> {
431
463
  suggestions: result.suggestions,
432
464
  target: result.target,
433
465
  checksRun: result.checksRun,
466
+ confidenceThreshold,
467
+ criteria,
434
468
  verificationMs: result.verificationMs,
435
469
  blockedFinalize: !passed,
436
470
  },
@@ -30,7 +30,7 @@ const inspectSchema = Type.Object({
30
30
  truncate: Type.Optional(
31
31
  Type.Number({
32
32
  description:
33
- "Max characters (0 = no limit, default 5000); applied after tool/skill exclusion.",
33
+ "Max characters before truncation (default 5000); applied after tool/skill exclusion. A blank or non-positive value applies the default.",
34
34
  default: 5000,
35
35
  }),
36
36
  ),
@@ -122,7 +122,14 @@ export function createPromptInspectTool() {
122
122
  ): Promise<any> => {
123
123
  const showTools = params.includeTools ?? true;
124
124
  const showSkills = params.includeSkills ?? true;
125
- const maxLen = params.truncate ?? 5000;
125
+ // Argument validation converts a blank truncate to 0, and the
126
+ // description used to define 0 as "no limit" - so a blank flipped the
127
+ // tool into dumping the whole assembled prompt. A deliberate 0 is
128
+ // indistinguishable from a blank after conversion, so the documented
129
+ // default wins and the old no-limit mode is no longer reachable through
130
+ // this selector (use `match` to read the full prompt).
131
+ const maxLen =
132
+ typeof params.truncate === "number" && params.truncate > 0 ? params.truncate : 5000;
126
133
 
127
134
  if (!ctx) {
128
135
  return {
@@ -202,7 +209,7 @@ export function createPromptInspectTool() {
202
209
  }
203
210
  } else {
204
211
  // Apply truncation only when no match filter is active
205
- if (maxLen > 0 && body.length > maxLen) {
212
+ if (body.length > maxLen) {
206
213
  didTruncate = true;
207
214
  body =
208
215
  body.slice(0, maxLen - 80) +