pi-braid 0.43.24 → 0.43.26
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.
- package/AGENTS.md +1 -0
- package/CHANGELOG.md +35 -0
- package/build-info.json +4 -4
- package/dist/extensions/memory/context-manager/handlers/tools/context-compress.js +30 -0
- package/docs/LOCAL_DEV.md +1 -1
- package/package.json +1 -1
- package/src/extensions/memory/context-manager/handlers/tools/context-compress.ts +33 -0
package/AGENTS.md
CHANGED
|
@@ -108,6 +108,7 @@ Event handlers receive `(event, ctx: ExtensionContext)`. Tool execute functions
|
|
|
108
108
|
- Tools added by extensions are auto-enabled on first session, except where the active-set owner says otherwise: `context-management` applies a curated default profile, so a registered tool is only active if the profile (or the operator's saved `/tools` list) names it
|
|
109
109
|
- Prompt-builder overrides the system prompt entirely (no native loading)
|
|
110
110
|
- Decompose large handlers into `handlers/*.ts` sub-modules
|
|
111
|
+
- **New fixtures import `node:test`.** 278 of the 440 test files under `packages/` carry hand-rolled runners, each re-deciding exit codes, failure reporting and whether to await a case; a census of them could not reliably tell a discarded async case from one handled by `.then(fn)`, which is exactly the shape where a failing case is counted green. An existing hand-rolled runner moves to `node:test` only when another change already opens that file, so this is a rule for new work, not a backlog.
|
|
111
112
|
|
|
112
113
|
## Doc Discipline
|
|
113
114
|
|
package/CHANGELOG.md
CHANGED
|
@@ -96,6 +96,41 @@ record; the tag scheme above applies unchanged.
|
|
|
96
96
|
note that a clean disable releases it, because a refusal an operator cannot act on
|
|
97
97
|
is a support ticket.
|
|
98
98
|
|
|
99
|
+
## Core — 0.43.26 (2026-11-05: a new fixture imports node:test, and a worktree resolves what the primary resolves)
|
|
100
|
+
|
|
101
|
+
- **A rule where there was only habit.** 278 of the 440 test files under
|
|
102
|
+
`packages/` carry hand-rolled runners, each re-deciding exit codes, failure
|
|
103
|
+
reporting and whether to await a case. A census of them could not reliably tell
|
|
104
|
+
a discarded async case from one handled through `.then(fn)`, which is the shape
|
|
105
|
+
where a failing case is counted green.
|
|
106
|
+
- **New work only.** An existing hand-rolled runner moves to `node:test` when
|
|
107
|
+
another change already opens that file, so the convention does not turn into a
|
|
108
|
+
278-file backlog nobody finishes.
|
|
109
|
+
- **A prepared worktree resolves what the primary resolves.**
|
|
110
|
+
`packages/core/scripts/prepare-worktree.mjs` links every `node_modules` the primary carries,
|
|
111
|
+
including the package-local installs under `packages/*/node_modules`, then
|
|
112
|
+
proves each link by asking node to resolve a real dependency from inside the
|
|
113
|
+
package directory. A detached worktree carries source only, so a chain that
|
|
114
|
+
spawns a package-local `tsc` failed with `MODULE_NOT_FOUND` for a reason the
|
|
115
|
+
change was not, and three workers in one day read that as a broken branch.
|
|
116
|
+
The fixture's control checks out the same ref with plain `git worktree add` and
|
|
117
|
+
requires resolution to fail there, so a passing run cannot be the
|
|
118
|
+
environment's doing.
|
|
119
|
+
|
|
120
|
+
## Core — 0.43.25 (2026-11-04: the context backstop leaves a countable trace)
|
|
121
|
+
|
|
122
|
+
- **The 0.90W backstop records that it fired.** The site called the drain and
|
|
123
|
+
wrote nothing, so "how often does it fire in real sessions" had no instrument
|
|
124
|
+
and could not be answered at all. Each fire now appends one line to
|
|
125
|
+
`metrics/context-backstop.jsonl` with the token count, the window, the derived
|
|
126
|
+
ratio and the session.
|
|
127
|
+
- **The write cannot break a turn.** A counter that throws inside the turn_end
|
|
128
|
+
pipeline would trade a measurable claim for a torn request, so the append is
|
|
129
|
+
wrapped and an uncounted fire is the failure mode.
|
|
130
|
+
- **The fixture asserts the trace, not the intent.** The existing backstop case
|
|
131
|
+
now requires exactly one line per fire and checks the ratio against the
|
|
132
|
+
recorded tokens; removing the call reddens it.
|
|
133
|
+
|
|
99
134
|
## Core — 0.43.24 (2026-11-04: carries the poller lock's legacy arm)
|
|
100
135
|
|
|
101
136
|
- **No core code changed.** The version moves so the tree's derived development
|
package/build-info.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-braid",
|
|
3
|
-
"version": "0.43.
|
|
4
|
-
"sha": "
|
|
5
|
-
"shaShort": "
|
|
3
|
+
"version": "0.43.26",
|
|
4
|
+
"sha": "41a1a6d79780d94ab878547ee2b620c41882e8e1",
|
|
5
|
+
"shaShort": "41a1a6d7",
|
|
6
6
|
"branch": "detached",
|
|
7
7
|
"dirty": false,
|
|
8
|
-
"packedAt": "2026-11-
|
|
8
|
+
"packedAt": "2026-11-05T17:17:27.329Z"
|
|
9
9
|
}
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
* - "deep_clean" meta-action: tag + archive + compact in one call
|
|
13
13
|
*/
|
|
14
14
|
import { Type } from "typebox";
|
|
15
|
+
import { appendFileSync, mkdirSync } from "node:fs";
|
|
16
|
+
import { join } from "node:path";
|
|
15
17
|
import { getExtensionState, readExtensionState } from "../../../../../lib/state/extension-state.js";
|
|
16
18
|
import { onEvent } from "../../../../../lib/events/event-types.js";
|
|
17
19
|
import { TOOL_EXECUTION_START, TOOL_EXECUTION_END, AGENT_SETTLED, TURN_END, } from "../../../../../lib/core/event-names.js";
|
|
@@ -19,6 +21,7 @@ import { analyzeSession } from "../../analysis.js";
|
|
|
19
21
|
import * as timerMod from "../../../../scheduling/timer/index.js";
|
|
20
22
|
import { getState } from "../../../../enforcement/state.js";
|
|
21
23
|
import { CONTEXT_COMPACT_REFUSE_PERCENT } from "../../../../../lib/detection/context-thresholds.js";
|
|
24
|
+
import { metricsDir } from "../../../../../lib/config/braid-paths.js";
|
|
22
25
|
import { getCmState, isCompactionActive, log, recordNavigationAction } from "../shared.js";
|
|
23
26
|
import { snapBoundaryOutsideToolBatch } from "../tool-batch-boundary.js";
|
|
24
27
|
import { formatTokensK, tokenArms } from "../../../../../lib/detection/context-usage.js";
|
|
@@ -58,6 +61,32 @@ function captureUsage(ctx) {
|
|
|
58
61
|
return null;
|
|
59
62
|
}
|
|
60
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* One line per backstop fire.
|
|
66
|
+
*
|
|
67
|
+
* The backstop fired silently, so "how often does it fire in real sessions" was
|
|
68
|
+
* not answerable from any log: the site only called the drain. A JSON line makes
|
|
69
|
+
* the question countable (wc -l on the file, or any reader over it), and the
|
|
70
|
+
* write is wrapped because a counter that can break a turn is worse than an
|
|
71
|
+
* uncounted fire.
|
|
72
|
+
*/
|
|
73
|
+
function recordBackstopFire(usage) {
|
|
74
|
+
try {
|
|
75
|
+
const dir = metricsDir();
|
|
76
|
+
mkdirSync(dir, { recursive: true });
|
|
77
|
+
appendFileSync(join(dir, "context-backstop.jsonl"), `${JSON.stringify({
|
|
78
|
+
at: new Date().toISOString(),
|
|
79
|
+
event: "backstop-fire",
|
|
80
|
+
tokens: usage.tokens,
|
|
81
|
+
contextWindow: usage.contextWindow,
|
|
82
|
+
ratio: Number((usage.tokens / usage.contextWindow).toFixed(4)),
|
|
83
|
+
session: process.env.PI_SESSION_ID ?? null,
|
|
84
|
+
})}\n`);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
// Uncounted is better than a torn turn.
|
|
88
|
+
}
|
|
89
|
+
}
|
|
61
90
|
// Blank optional selectors.
|
|
62
91
|
//
|
|
63
92
|
// Some clients emit every schema property and send "" for the ones they do
|
|
@@ -550,6 +579,7 @@ export function registerContextCompress(pi) {
|
|
|
550
579
|
const usage = captureUsage(ctx);
|
|
551
580
|
if (!usage || usage.tokens < tokenArms(usage.contextWindow).backstop)
|
|
552
581
|
return;
|
|
582
|
+
recordBackstopFire(usage);
|
|
553
583
|
firePendingCompactionsIfSettled(ctx, st);
|
|
554
584
|
}
|
|
555
585
|
catch {
|
package/docs/LOCAL_DEV.md
CHANGED
|
@@ -138,7 +138,7 @@ before and after a full run. A non-zero delta is the leak this rule prevents.
|
|
|
138
138
|
### New fixtures: use `node:test`
|
|
139
139
|
|
|
140
140
|
A new fixture is written on `node:test`. The runner does not care which style a
|
|
141
|
-
file uses -
|
|
141
|
+
file uses - 106 of the core suite's 341 fixtures already use `node:test` - so the
|
|
142
142
|
reason is the failure the other style produces. A hand-rolled helper that calls
|
|
143
143
|
`fn()` without awaiting it discards the case's promise, so an `async` case runs
|
|
144
144
|
detached and the file can print its green tally before that case settles, with
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-braid",
|
|
3
|
-
"version": "0.43.
|
|
3
|
+
"version": "0.43.26",
|
|
4
4
|
"description": "🥨 Braid - Metacognitive extension suite for pi coding agent: Adds memory, plan tracking, structured cognitive signals and completion checks on top of pi core loop, so long sessions keep their context and stop claiming unfinished work.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { Type } from "typebox";
|
|
16
|
+
import { appendFileSync, mkdirSync } from "node:fs";
|
|
17
|
+
import { join } from "node:path";
|
|
16
18
|
import type { CompactOptions, ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
17
19
|
import { getExtensionState, readExtensionState } from "../../../../../lib/state/extension-state.js";
|
|
18
20
|
import { onEvent } from "../../../../../lib/events/event-types.js";
|
|
@@ -26,6 +28,7 @@ import { analyzeSession } from "../../analysis.js";
|
|
|
26
28
|
import * as timerMod from "../../../../scheduling/timer/index.js";
|
|
27
29
|
import { getState } from "../../../../enforcement/state.js";
|
|
28
30
|
import { CONTEXT_COMPACT_REFUSE_PERCENT } from "../../../../../lib/detection/context-thresholds.js";
|
|
31
|
+
import { metricsDir } from "../../../../../lib/config/braid-paths.js";
|
|
29
32
|
import { getCmState, isCompactionActive, log, recordNavigationAction } from "../shared.js";
|
|
30
33
|
import { snapBoundaryOutsideToolBatch } from "../tool-batch-boundary.js";
|
|
31
34
|
import { formatTokensK, tokenArms } from "../../../../../lib/detection/context-usage.js";
|
|
@@ -68,6 +71,35 @@ function captureUsage(ctx: any): { percent: number; tokens: number; contextWindo
|
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
73
|
|
|
74
|
+
/**
|
|
75
|
+
* One line per backstop fire.
|
|
76
|
+
*
|
|
77
|
+
* The backstop fired silently, so "how often does it fire in real sessions" was
|
|
78
|
+
* not answerable from any log: the site only called the drain. A JSON line makes
|
|
79
|
+
* the question countable (wc -l on the file, or any reader over it), and the
|
|
80
|
+
* write is wrapped because a counter that can break a turn is worse than an
|
|
81
|
+
* uncounted fire.
|
|
82
|
+
*/
|
|
83
|
+
function recordBackstopFire(usage: { tokens: number; contextWindow: number }): void {
|
|
84
|
+
try {
|
|
85
|
+
const dir = metricsDir();
|
|
86
|
+
mkdirSync(dir, { recursive: true });
|
|
87
|
+
appendFileSync(
|
|
88
|
+
join(dir, "context-backstop.jsonl"),
|
|
89
|
+
`${JSON.stringify({
|
|
90
|
+
at: new Date().toISOString(),
|
|
91
|
+
event: "backstop-fire",
|
|
92
|
+
tokens: usage.tokens,
|
|
93
|
+
contextWindow: usage.contextWindow,
|
|
94
|
+
ratio: Number((usage.tokens / usage.contextWindow).toFixed(4)),
|
|
95
|
+
session: process.env.PI_SESSION_ID ?? null,
|
|
96
|
+
})}\n`,
|
|
97
|
+
);
|
|
98
|
+
} catch {
|
|
99
|
+
// Uncounted is better than a torn turn.
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
71
103
|
// Blank optional selectors.
|
|
72
104
|
//
|
|
73
105
|
// Some clients emit every schema property and send "" for the ones they do
|
|
@@ -676,6 +708,7 @@ export function registerContextCompress(pi: ExtensionAPI): void {
|
|
|
676
708
|
if (isCompactionActive(ctx)) return;
|
|
677
709
|
const usage = captureUsage(ctx);
|
|
678
710
|
if (!usage || usage.tokens < tokenArms(usage.contextWindow).backstop) return;
|
|
711
|
+
recordBackstopFire(usage);
|
|
679
712
|
firePendingCompactionsIfSettled(ctx, st);
|
|
680
713
|
} catch {
|
|
681
714
|
// A failed backstop check must not tear the turn_end event pipeline;
|