@bongos/core 1.19.819 → 1.19.821
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/.bongos-core.json +77 -42
- package/.claude/skills/builder-end/SKILL.md +1 -1
- package/clients/bongos-client/index.d.ts +1 -1
- package/docs/adr/0021-per-builder-skill-model-preferences.md +1 -1
- package/docs/adr/0024-multi-agent-system-architecture.md +1 -1
- package/docs/adr/0026-bfg-memory-hygiene-and-cross-builder-learning.md +1 -1
- package/docs/adr/0028-honest-llm-spend-accounting.md +1 -1
- package/docs/adr/0035-builder-onboarding-three-paths.md +1 -1
- package/docs/adr/0055-server-mediated-branch-publish.md +1 -1
- package/docs/adr/0058-automatic-gate-surface-gatekeeper.md +1 -1
- package/docs/adr/0059-single-approval-remove-devbox-approval-gate.md +1 -1
- package/docs/adr/0060-gds-retrieval-layer.md +1 -1
- package/docs/adr/0070-deterministic-session-card-delivery.md +1 -1
- package/docs/adr/0073-builder-needs-signal-and-byok-gemini-key.md +1 -1
- package/docs/adr/0081-tool-agnostic-design-layer.md +2 -2
- package/docs/adr/0086-goal-scoped-work-hierarchy.md +4 -4
- package/docs/adr/0117-api-versioning-and-deprecation-policy.md +1 -1
- package/docs/api/openapi.json +4 -2
- package/docs/copy-inventory.md +23 -18
- package/docs/copy-registry.json +76 -31
- package/docs/module-api-changelog.md +5 -1
- package/docs/recipes/multi-builder-merge.md +2 -2
- package/docs/recipes/search-index-ingestion.md +2 -2
- package/migrations/core_246_session_type.sql +49 -0
- package/modules/hall-ui/public/sessions.css +19 -0
- package/modules/hall-ui/public/sessions.html +16 -1
- package/modules/hall-ui/public/sessions.js +135 -6
- package/modules/sessions/db.js +92 -6
- package/modules/sessions/routes/sessions.js +18 -1
- package/modules/sessions/session-type.js +132 -0
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/scripts/gds/backfill-session-types.js +87 -0
- package/scripts/gds/fitness.js +12 -1
- package/scripts/gds/home-isolation-guard.js +126 -0
- package/scripts/gds/ship-merge.js +5 -1
- package/scripts/gds/ship-regen.js +29 -0
- package/src/module-api.js +1 -1
- package/tests/cli_package.mjs +18 -2
- package/tests/hall_roster_world.mjs +10 -5
- package/tests/home_isolation_guard.mjs +95 -0
- package/tests/session_type.mjs +215 -0
- package/tests/ship_regen_copy_inventory.mjs +69 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
// tests/session_type.mjs — the session-type classifier and its filter
|
|
2
|
+
// (task 1003975, from idea 1001033, goal 1000093).
|
|
3
|
+
//
|
|
4
|
+
// WHAT THIS FILE PINS, in order of what would actually go wrong:
|
|
5
|
+
// (1) the measured shapes. Each fixture is a real session's counters, taken
|
|
6
|
+
// from the 247-row sample the classifier's header records, so a retuning
|
|
7
|
+
// that looks harmless in the abstract has to face the corpus it was
|
|
8
|
+
// derived from.
|
|
9
|
+
// (2) that the ONE-SHOT boundary is the bimodal gap it was measured to be, and
|
|
10
|
+
// that it is computed as prompts (user turns MINUS tool results) — reading
|
|
11
|
+
// user_turns raw would call every subagent an interactive session, which
|
|
12
|
+
// is exactly the confusion the column exists to end.
|
|
13
|
+
// (3) that task_ids is never consulted. 82 of the sample's 179 automated rows
|
|
14
|
+
// carry a task id (a grader worker inherits the task it ran inside), so a
|
|
15
|
+
// classifier that reached for it would label them build sessions.
|
|
16
|
+
// (4) that a write tool wins over everything, and that Bash is NOT one — Bash
|
|
17
|
+
// is 75% of all tool calls in the corpus, so counting it as a write would
|
|
18
|
+
// collapse the vocabulary to a single value.
|
|
19
|
+
// (5) that the route's filter is validated against the classifier's own list,
|
|
20
|
+
// and that the filter reaches the tally as well as the page — a filter on
|
|
21
|
+
// only one of the two is how a table of 57 rows ends up under a headline
|
|
22
|
+
// claiming 4,595.
|
|
23
|
+
//
|
|
24
|
+
// Run: node tests/session_type.mjs
|
|
25
|
+
|
|
26
|
+
import { strict as assert } from 'node:assert';
|
|
27
|
+
import { test } from 'node:test';
|
|
28
|
+
import { createRequire } from 'node:module';
|
|
29
|
+
|
|
30
|
+
process.env.NODE_ENV = 'test';
|
|
31
|
+
const require = createRequire(import.meta.url);
|
|
32
|
+
const st = require('../modules/sessions/session-type.js');
|
|
33
|
+
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
// Fixtures. Every one is a real sampled session reduced to what the classifier
|
|
36
|
+
// reads; the ids in the comments are session_records ids from the 2026-09-17
|
|
37
|
+
// sample so a later reader can go and look at the row itself.
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
|
|
40
|
+
// id 1007108 — a builder-sequence run: 70 turns, 42 tool calls, files written.
|
|
41
|
+
const BUILD = {
|
|
42
|
+
metrics: { assistant_turns: 70, user_turns: 43, tool_result_count: 42, tool_use_count: 42 },
|
|
43
|
+
detail: [{ role: 'assistant', tools: ['Skill'] }, { role: 'assistant', tools: ['Bash', 'Write'] }],
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// id 1007121 — a grader worker: one prompt in, one JSON verdict out, no tools.
|
|
47
|
+
const GRADER = {
|
|
48
|
+
metrics: { assistant_turns: 2, user_turns: 1, tool_result_count: 0, tool_use_count: 0 },
|
|
49
|
+
detail: [{ role: 'user' }, { role: 'assistant', snippet: '{"security_score": 6}' }],
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// id 1007117 — a panel subagent reading the codebase: 12 reads, but every user
|
|
53
|
+
// turn is one of those reads coming back. One prompt started it.
|
|
54
|
+
const PANEL = {
|
|
55
|
+
metrics: { assistant_turns: 23, user_turns: 13, tool_result_count: 12, tool_use_count: 12 },
|
|
56
|
+
detail: Array.from({ length: 12 }, () => ({ role: 'assistant', tools: ['Read'] })),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// id 1007109 — a person steering: 11 user turns of which 8 are tool results, so
|
|
60
|
+
// three real prompts, and nothing was written.
|
|
61
|
+
const EXPLORING = {
|
|
62
|
+
metrics: { assistant_turns: 13, user_turns: 11, tool_result_count: 8, tool_use_count: 8 },
|
|
63
|
+
detail: [{ role: 'assistant', tools: ['Bash'] }],
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// No sampled row had this shape (0 of 247) — a person asking, with no tools at
|
|
67
|
+
// all. It is here because the bucket must work the day it first happens.
|
|
68
|
+
const TALKING = {
|
|
69
|
+
metrics: { assistant_turns: 9, user_turns: 5, tool_result_count: 0, tool_use_count: 0 },
|
|
70
|
+
detail: [{ role: 'user' }, { role: 'assistant' }, { role: 'user' }],
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// ---------------------------------------------------------------------------
|
|
74
|
+
// (1) The measured shapes.
|
|
75
|
+
// ---------------------------------------------------------------------------
|
|
76
|
+
|
|
77
|
+
test('each measured session shape classifies as itself', () => {
|
|
78
|
+
assert.equal(st.classifySession(BUILD), 'build');
|
|
79
|
+
assert.equal(st.classifySession(GRADER), 'automated');
|
|
80
|
+
assert.equal(st.classifySession(PANEL), 'automated');
|
|
81
|
+
assert.equal(st.classifySession(EXPLORING), 'exploration');
|
|
82
|
+
assert.equal(st.classifySession(TALKING), 'conversation');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('every verdict is in the closed set', () => {
|
|
86
|
+
for (const fixture of [BUILD, GRADER, PANEL, EXPLORING, TALKING, {}, { metrics: {} }]) {
|
|
87
|
+
assert.ok(
|
|
88
|
+
st.SESSION_TYPES.includes(st.classifySession(fixture)),
|
|
89
|
+
`classify returned a type outside SESSION_TYPES for ${JSON.stringify(fixture).slice(0, 60)}`
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// ---------------------------------------------------------------------------
|
|
95
|
+
// (2) The one-shot boundary, and that it is PROMPTS and not user turns.
|
|
96
|
+
// ---------------------------------------------------------------------------
|
|
97
|
+
|
|
98
|
+
test('prompts are user turns minus tool results, floored at zero', () => {
|
|
99
|
+
assert.equal(st.humanPrompts({ user_turns: 13, tool_result_count: 12 }), 1);
|
|
100
|
+
assert.equal(st.humanPrompts({ user_turns: 11, tool_result_count: 8 }), 3);
|
|
101
|
+
// A disagreeing digest (an old row, a truncated transcript) must not produce a
|
|
102
|
+
// negative, which would sail under the one-shot boundary as if measured.
|
|
103
|
+
assert.equal(st.humanPrompts({ user_turns: 2, tool_result_count: 40 }), 0);
|
|
104
|
+
assert.equal(st.humanPrompts({}), 0);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('the boundary sits between one prompt and two — the measured bimodal gap', () => {
|
|
108
|
+
assert.equal(st.ONE_SHOT_PROMPT_MAX, 1);
|
|
109
|
+
const at = { metrics: { assistant_turns: 20, user_turns: 11, tool_result_count: 10, tool_use_count: 10 }, detail: [{ role: 'assistant', tools: ['Read'] }] };
|
|
110
|
+
const over = { metrics: { assistant_turns: 20, user_turns: 12, tool_result_count: 10, tool_use_count: 10 }, detail: [{ role: 'assistant', tools: ['Read'] }] };
|
|
111
|
+
assert.equal(st.classifySession(at), 'automated', 'one prompt is an invocation');
|
|
112
|
+
assert.equal(st.classifySession(over), 'exploration', 'two prompts is someone steering');
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test('reading user_turns raw would misread the panel subagent — the whole point', () => {
|
|
116
|
+
// 13 user turns looks like a long conversation; 12 of them are tool results.
|
|
117
|
+
assert.ok(PANEL.metrics.user_turns > 2, 'fixture still has the misleading raw count');
|
|
118
|
+
assert.equal(st.classifySession(PANEL), 'automated');
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// ---------------------------------------------------------------------------
|
|
122
|
+
// (3) task_ids is never consulted.
|
|
123
|
+
// ---------------------------------------------------------------------------
|
|
124
|
+
|
|
125
|
+
test('a task id cannot change the verdict', () => {
|
|
126
|
+
// The grader worker ran inside a ship and inherited its task. 82 of the
|
|
127
|
+
// sample's 179 automated rows look exactly like this.
|
|
128
|
+
const withTask = { ...GRADER, task_ids: [1003975, 1003841] };
|
|
129
|
+
assert.equal(st.classifySession(withTask), 'automated');
|
|
130
|
+
const buildWithout = { ...BUILD, task_ids: [] };
|
|
131
|
+
assert.equal(st.classifySession(buildWithout), 'build');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// ---------------------------------------------------------------------------
|
|
135
|
+
// (4) Write tools win; Bash is not one.
|
|
136
|
+
// ---------------------------------------------------------------------------
|
|
137
|
+
|
|
138
|
+
test('a write tool outranks every other signal', () => {
|
|
139
|
+
// One prompt, one edit: an invocation that nonetheless changed the repo.
|
|
140
|
+
const oneShotEdit = {
|
|
141
|
+
metrics: { assistant_turns: 4, user_turns: 2, tool_result_count: 2, tool_use_count: 2 },
|
|
142
|
+
detail: [{ role: 'assistant', tools: ['Read'] }, { role: 'assistant', tools: ['Edit'] }],
|
|
143
|
+
};
|
|
144
|
+
assert.equal(st.classifySession(oneShotEdit), 'build');
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test('Bash alone is not a build — it reads at least as often as it writes', () => {
|
|
148
|
+
assert.ok(!st.WRITE_TOOLS.has('Bash'));
|
|
149
|
+
const bashOnly = {
|
|
150
|
+
metrics: { assistant_turns: 21, user_turns: 13, tool_result_count: 11, tool_use_count: 11 },
|
|
151
|
+
detail: [{ role: 'assistant', tools: ['Bash'] }],
|
|
152
|
+
};
|
|
153
|
+
assert.equal(st.classifySession(bashOnly), 'exploration');
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test('every editor the harness offers counts as a write', () => {
|
|
157
|
+
for (const tool of ['Edit', 'Write', 'MultiEdit', 'NotebookEdit']) {
|
|
158
|
+
const row = { metrics: { assistant_turns: 2, user_turns: 1, tool_result_count: 1, tool_use_count: 1 }, detail: [{ role: 'assistant', tools: [tool] }] };
|
|
159
|
+
assert.equal(st.classifySession(row), 'build', `${tool} should count as a write`);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test('a malformed detail never throws', () => {
|
|
164
|
+
assert.equal(st.usedWriteTool(null), false);
|
|
165
|
+
assert.equal(st.usedWriteTool('Edit'), false);
|
|
166
|
+
assert.equal(st.usedWriteTool([null, { tools: null }, { tools: [null, 7] }]), false);
|
|
167
|
+
assert.equal(st.usedWriteTool([{ tools: ['Edit'] }]), true);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// ---------------------------------------------------------------------------
|
|
171
|
+
// (5) The vocabulary guard + the shared filter clause.
|
|
172
|
+
// ---------------------------------------------------------------------------
|
|
173
|
+
|
|
174
|
+
test('isSessionType accepts exactly the closed set', () => {
|
|
175
|
+
for (const t of st.SESSION_TYPES) assert.ok(st.isSessionType(t), `${t} should be valid`);
|
|
176
|
+
for (const bad of ['Build', 'build ', 'ops', '', null, undefined, 7, {}]) {
|
|
177
|
+
assert.ok(!st.isSessionType(bad), `${JSON.stringify(bad)} should be rejected`);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test('an empty digest is unknown, not a quiet conversation', () => {
|
|
182
|
+
assert.equal(st.classifySession({}), 'unknown');
|
|
183
|
+
assert.equal(st.classifySession({ detail: [], metrics: {} }), 'unknown');
|
|
184
|
+
assert.equal(st.classifySession(), 'unknown');
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test('the type filter reaches the page query AND the tally, through one clause', async () => {
|
|
188
|
+
// The clause is shared by searchSessions and summarizeSessions precisely so the
|
|
189
|
+
// two cannot drift; this captures the SQL both emit and proves the predicate and
|
|
190
|
+
// its bound value are in each.
|
|
191
|
+
const emitted = [];
|
|
192
|
+
const pool = { query: async (sql, params) => { emitted.push({ sql, params }); return { rows: [{}] }; } };
|
|
193
|
+
const moduleApi = require('../src/module-api.js');
|
|
194
|
+
const realPool = moduleApi.pool;
|
|
195
|
+
Object.defineProperty(moduleApi, 'pool', { value: pool, configurable: true, writable: true });
|
|
196
|
+
delete require.cache[require.resolve('../modules/sessions/db.js')];
|
|
197
|
+
const db = require('../modules/sessions/db.js');
|
|
198
|
+
try {
|
|
199
|
+
await db.searchSessions({ sessionType: 'build' });
|
|
200
|
+
await db.summarizeSessions({ sessionType: 'build' });
|
|
201
|
+
assert.equal(emitted.length, 2);
|
|
202
|
+
for (const { sql, params } of emitted) {
|
|
203
|
+
assert.ok(/sr\.session_type = \$8/.test(sql), 'the type predicate is missing from one of the two queries');
|
|
204
|
+
assert.equal(params[7], 'build', 'the type is not bound as $8');
|
|
205
|
+
}
|
|
206
|
+
// Absent filter binds NULL, which the clause reads as "every kind" — not as a
|
|
207
|
+
// literal that would match no row.
|
|
208
|
+
emitted.length = 0;
|
|
209
|
+
await db.searchSessions({});
|
|
210
|
+
assert.equal(emitted[0].params[7], null);
|
|
211
|
+
} finally {
|
|
212
|
+
Object.defineProperty(moduleApi, 'pool', { value: realPool, configurable: true, writable: true });
|
|
213
|
+
delete require.cache[require.resolve('../modules/sessions/db.js')];
|
|
214
|
+
}
|
|
215
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// tests/ship_regen_copy_inventory.mjs — the ship path keeps the copy registry fresh
|
|
2
|
+
// (task 1003556).
|
|
3
|
+
//
|
|
4
|
+
// WHY THIS EXISTS. docs/copy-registry.json carries a LINE NUMBER per row, so editing
|
|
5
|
+
// any scanned UI file (modules/hall-ui/public, modules/status-ui/public,
|
|
6
|
+
// modules/public-landing/public) shifts them and stales the artifact. Nothing in the
|
|
7
|
+
// ship path regenerated it — grep for copy-inventory across ship.js, ship-regen.js
|
|
8
|
+
// and ship-preflight-steps.js used to return zero hits — and fitness did not gate it,
|
|
9
|
+
// so the first signal a builder got was CI failing on the PR's MERGE ref. That is the
|
|
10
|
+
// hardest place to attribute a failure: the branch is green, and what broke is the
|
|
11
|
+
// combination.
|
|
12
|
+
//
|
|
13
|
+
// Task 1003546 fixed the SERVER-side merge heals for the same artifact; those repair a
|
|
14
|
+
// strand after it happens. This is the prevention, and these tests pin the wiring
|
|
15
|
+
// rather than the behaviour, because the failure mode is "nobody calls it".
|
|
16
|
+
//
|
|
17
|
+
// Run: node tests/ship_regen_copy_inventory.mjs
|
|
18
|
+
|
|
19
|
+
import { test } from 'node:test';
|
|
20
|
+
import assert from 'node:assert/strict';
|
|
21
|
+
import { readFileSync } from 'node:fs';
|
|
22
|
+
import path from 'node:path';
|
|
23
|
+
import { fileURLToPath } from 'node:url';
|
|
24
|
+
import { createRequire } from 'node:module';
|
|
25
|
+
|
|
26
|
+
const require = createRequire(import.meta.url);
|
|
27
|
+
const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
28
|
+
const read = (rel) => readFileSync(path.join(REPO_ROOT, rel), 'utf8');
|
|
29
|
+
|
|
30
|
+
test('ship-regen exports regenerateCopyInventory beside its siblings', () => {
|
|
31
|
+
const regen = require('../scripts/gds/ship-regen.js');
|
|
32
|
+
assert.equal(typeof regen.regenerateCopyInventory, 'function');
|
|
33
|
+
// The siblings it must sit beside — if one of these disappears the convention moved
|
|
34
|
+
// and this file should move with it, rather than silently guarding nothing.
|
|
35
|
+
for (const sib of ['regenerateFileMap', 'regenerateRepoMap', 'regenerateSessionIndex']) {
|
|
36
|
+
assert.equal(typeof regen[sib], 'function', `${sib} is the convention this follows`);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('the merge path CALLS it — the whole bug was that nobody did', () => {
|
|
41
|
+
const src = read('scripts/gds/ship-merge.js');
|
|
42
|
+
assert.match(src, /regenerateCopyInventory\(\)/,
|
|
43
|
+
'ship-merge must invoke it, not merely import it');
|
|
44
|
+
// Called on the same beat as the other generated artifacts, not somewhere that runs
|
|
45
|
+
// only on a branch of the flow.
|
|
46
|
+
const idx = src.indexOf('regenerateCopyInventory()');
|
|
47
|
+
const fileMapIdx = src.indexOf('regenerateFileMap()');
|
|
48
|
+
assert.ok(fileMapIdx > 0 && Math.abs(idx - fileMapIdx) < 600,
|
|
49
|
+
'it should run beside the other regenerators, not in a separate branch of the flow');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('fitness gates the pair, so a local run says so before CI does', () => {
|
|
53
|
+
const src = read('scripts/gds/fitness.js');
|
|
54
|
+
assert.match(src, /copy-inventory\.js.*--check|'--check'\]/s);
|
|
55
|
+
assert.ok(src.includes("'copy-inventory.js'"),
|
|
56
|
+
'the freshness check must run copy-inventory --check');
|
|
57
|
+
assert.match(src, /copy-registry\.json \+ docs\/copy-inventory\.md are STALE/,
|
|
58
|
+
'and name both artifacts plus the fix command in the violation');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('the registry really is line-sensitive — the premise of all of the above', () => {
|
|
62
|
+
// If rows stopped carrying line numbers, none of this wiring would be needed and
|
|
63
|
+
// this file would be guarding a problem that no longer exists.
|
|
64
|
+
const reg = JSON.parse(read('docs/copy-registry.json'));
|
|
65
|
+
const rows = Array.isArray(reg) ? reg : (reg.entries || reg.rows || Object.values(reg).find(Array.isArray));
|
|
66
|
+
assert.ok(Array.isArray(rows) && rows.length > 0, 'the registry must have rows to be stale-able');
|
|
67
|
+
assert.ok(rows.some((r) => r && typeof r === 'object' && 'line' in r),
|
|
68
|
+
'rows carry a `line`, which is why any UI edit stales this artifact');
|
|
69
|
+
});
|