@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,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// scripts/gds/backfill-session-types.js — classify the sessions that predate the
|
|
5
|
+
// classifier (task 1003975, from idea 1001033).
|
|
6
|
+
//
|
|
7
|
+
// WHAT THIS IS, and what it is NOT. It writes ONE column, `session_records.session_type`,
|
|
8
|
+
// and only where that column is NULL. It moves no money, books no reward, touches
|
|
9
|
+
// no `task_ids` and creates no attribution. That separation is deliberate and it
|
|
10
|
+
// is the lesson this module already paid for once: the attribution sweep had to be
|
|
11
|
+
// windowed because it ran on the same tick as a payout and would have minted a mass
|
|
12
|
+
// retroactive payment nobody authorised (see the warning in modules/sessions/CLAUDE.md).
|
|
13
|
+
// A sweep that both labels and pays is the wrong shape whatever its intent, so this
|
|
14
|
+
// one cannot pay even in principle — db.setSessionType writes that column alone.
|
|
15
|
+
//
|
|
16
|
+
// WHY IT IS NEEDED. The upload path classifies every session from now on, but the
|
|
17
|
+
// corpus is ~4,600 rows old and none of them carry a verdict. Without this pass the
|
|
18
|
+
// ledger's new filter would only ever see today's sessions, which is exactly the
|
|
19
|
+
// half of the corpus nobody needs help reading.
|
|
20
|
+
//
|
|
21
|
+
// SAFETY. DRY-RUN BY DEFAULT: with no flags it classifies in memory, prints the
|
|
22
|
+
// distribution it WOULD write, and writes nothing. `--apply` performs the UPDATEs.
|
|
23
|
+
// Idempotent by construction: the verdict is a pure function of the row's own
|
|
24
|
+
// stored digest, so a re-run lands on the same answer, and a row that already has
|
|
25
|
+
// a type is never revisited (the query selects `WHERE session_type IS NULL`).
|
|
26
|
+
// `--limit N` bounds one pass so the first apply can be small and checked.
|
|
27
|
+
//
|
|
28
|
+
// Run: node scripts/gds/backfill-session-types.js [--limit N]
|
|
29
|
+
// node scripts/gds/backfill-session-types.js --apply
|
|
30
|
+
|
|
31
|
+
const { classifySession, SESSION_TYPES } = require('../../modules/sessions/session-type');
|
|
32
|
+
const db = require('../../modules/sessions/db');
|
|
33
|
+
const { arg, hasFlag } = require('./cli-lib');
|
|
34
|
+
|
|
35
|
+
const BATCH = 500;
|
|
36
|
+
|
|
37
|
+
async function main() {
|
|
38
|
+
const apply = hasFlag('--apply');
|
|
39
|
+
const limitArg = Number(arg('--limit'));
|
|
40
|
+
const cap = Number.isFinite(limitArg) && limitArg > 0 ? Math.trunc(limitArg) : Infinity;
|
|
41
|
+
|
|
42
|
+
const tally = Object.fromEntries(SESSION_TYPES.map((t) => [t, 0]));
|
|
43
|
+
let scanned = 0;
|
|
44
|
+
let written = 0;
|
|
45
|
+
|
|
46
|
+
// Paged rather than one big SELECT: `detail` is a jsonb per row and the corpus
|
|
47
|
+
// is the largest table this module owns, so pulling it whole would hold the
|
|
48
|
+
// entire transcript corpus in memory at once for no gain.
|
|
49
|
+
for (;;) {
|
|
50
|
+
const room = Math.min(BATCH, cap - scanned);
|
|
51
|
+
if (room <= 0) break;
|
|
52
|
+
const rows = await db.unclassifiedSessions(room);
|
|
53
|
+
if (rows.length === 0) break;
|
|
54
|
+
for (const row of rows) {
|
|
55
|
+
const type = classifySession({ detail: row.detail, metrics: row.metrics });
|
|
56
|
+
tally[type] = (tally[type] || 0) + 1;
|
|
57
|
+
scanned++;
|
|
58
|
+
if (apply) written += await db.setSessionType(row.id, type);
|
|
59
|
+
}
|
|
60
|
+
// A dry run never writes, so the same unclassified page comes back forever.
|
|
61
|
+
// One page is enough to show the shape; say so rather than looping.
|
|
62
|
+
if (!apply) break;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
console.log(`\nsession-type backfill — ${apply ? 'APPLIED' : 'DRY RUN (no writes)'}`);
|
|
66
|
+
console.log(` rows classified ${scanned}`);
|
|
67
|
+
if (apply) console.log(` rows written ${written}`);
|
|
68
|
+
console.log(` distribution:`);
|
|
69
|
+
for (const t of SESSION_TYPES) {
|
|
70
|
+
const n = tally[t] || 0;
|
|
71
|
+
const pct = scanned ? ` (${Math.round((n / scanned) * 100)}%)` : '';
|
|
72
|
+
console.log(` ${t.padEnd(14)} ${String(n).padStart(6)}${pct}`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (apply) {
|
|
76
|
+
console.log(`\n corpus now:`);
|
|
77
|
+
for (const r of await db.sessionTypeCounts()) {
|
|
78
|
+
console.log(` ${String(r.type).padEnd(14)} ${String(r.n).padStart(6)}`);
|
|
79
|
+
}
|
|
80
|
+
} else if (scanned > 0) {
|
|
81
|
+
console.log(`\n dry run reads one page of ${BATCH}; re-run with --apply to write and walk the whole corpus.`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
main()
|
|
86
|
+
.then(() => process.exit(0))
|
|
87
|
+
.catch((err) => { console.error(err); process.exit(1); });
|
package/scripts/gds/fitness.js
CHANGED
|
@@ -200,9 +200,19 @@ function checkGeneratedArtifactsFresh() {
|
|
|
200
200
|
} catch {
|
|
201
201
|
violations.push('docs/api/openapi.json + docs/api-reference.md + docs/routes-permissions.md are STALE (or the spec is not valid OpenAPI 3.1) — run `node scripts/gds/gen-api-docs.js` and commit (task 1918).');
|
|
202
202
|
}
|
|
203
|
+
try {
|
|
204
|
+
// task 1003556: the copy registry's rows carry LINE NUMBERS, so editing any scanned
|
|
205
|
+
// UI file stales it. It was covered only by ship-check's OPTIONAL step, which a
|
|
206
|
+
// builder has to remember to run — so the first signal was CI failing on the PR's
|
|
207
|
+
// MERGE ref, where the shift is hardest to attribute. Gated here so a local fitness
|
|
208
|
+
// run says so first.
|
|
209
|
+
execFileSync(process.execPath, [path.join(__dirname, 'copy-inventory.js'), '--check'], { cwd: REPO_ROOT, stdio: 'pipe' });
|
|
210
|
+
} catch {
|
|
211
|
+
violations.push('docs/copy-registry.json + docs/copy-inventory.md are STALE — every row carries a line number, so editing any scanned UI file shifts them. Run `node scripts/gds/copy-inventory.js` and commit (task 1003556).');
|
|
212
|
+
}
|
|
203
213
|
// NB the role packs' responsibility blocks are generated too, but their freshness
|
|
204
214
|
// is asserted by role-pack-guard.js — one check owns "the packs are correct".
|
|
205
|
-
return { name: 'generated artifacts fresh', ok: violations.length === 0, hardFail: violations.length > 0, violations, warnings: [], note: 'Tracked generated content matches source: nested CLAUDE.md symbol blocks (code) + the CLAUDE.md §13 snippet (sessions) via --check-block, plus the CLAUDE.md §2 interaction-posture block (the knob defaults), docs/file-map.md skills/scheduled-tasks sections
|
|
215
|
+
return { name: 'generated artifacts fresh', ok: violations.length === 0, hardFail: violations.length > 0, violations, warnings: [], note: 'Tracked generated content matches source: nested CLAUDE.md symbol blocks (code) + the CLAUDE.md §13 snippet (sessions) via --check-block, plus the CLAUDE.md §2 interaction-posture block (the knob defaults), docs/file-map.md skills/scheduled-tasks sections, docs/api/openapi.json + api-reference.md (API) and docs/copy-registry.json + copy-inventory.md (the reader-facing copy, task 1003556). The gitignored docs/repo-map.md + docs/session-log-index.md are deploy-regenerated (ADR 0110), not gated here.' };
|
|
206
216
|
}
|
|
207
217
|
|
|
208
218
|
// ---- deterministic cron routine boundary (System 4 / ADR 0078) -------------
|
|
@@ -1223,6 +1233,7 @@ const CHECKS = [
|
|
|
1223
1233
|
// crashes later, so a start-up refusal would trade an outage risk for a cosmetic
|
|
1224
1234
|
// one (ADR 0289). Rationale + the seam→consumer table live in that file.
|
|
1225
1235
|
require('./seam-wiring-guard.js').checkSeamWiring,
|
|
1236
|
+
require('./home-isolation-guard.js').checkHomeIsolation, // Check 34 — task 1003763: a test that sets HOME for a child without USERPROFILE isolates NOTHING on win32, so it silently stops testing what its comment says. Three tasks fixed this one site at a time. Rationale in that file.
|
|
1226
1237
|
require('./adr-namespace.js').checkAdrNumbering, require('./exec-path-guard.js').checkExecPathsStatic, // Check 32 — task 1003371 / B50: what the server EXECUTES, out of whose tree — the blind spot all three 2026-08-29 CRITICALs shared. Rationale + reviewed exemptions live in that file. Sharing Check 31's line (the 19c/19d + 23/24 precedent above): fitness.js is AT the 1,500 ratchet and a new check cannot afford a line until task 1003825 buys it back.
|
|
1227
1238
|
];
|
|
1228
1239
|
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// scripts/gds/home-isolation-guard.js — setting HOME for a child process isolates
|
|
4
|
+
// nothing on Windows (task 1003763).
|
|
5
|
+
//
|
|
6
|
+
// THE DEFECT, three times now. os.homedir() reads USERPROFILE on win32 and never
|
|
7
|
+
// consults HOME, so `env: { ...process.env, HOME: tmp }` leaves the child looking at
|
|
8
|
+
// the DEVELOPER'S REAL home — and therefore their real CLI session.
|
|
9
|
+
//
|
|
10
|
+
// tests/cli_sessions.mjs (task 1003760) — DESTROYED the developer's live session.
|
|
11
|
+
// tests/cli_surface.mjs (task 1003941) — guidance printers took the authenticated
|
|
12
|
+
// branch, so the test failed for a false
|
|
13
|
+
// reason on any signed-in Windows box.
|
|
14
|
+
// tests/cli_package.mjs (task 1003763) — an unauthenticated-path assertion could
|
|
15
|
+
// pass because the machine was signed in.
|
|
16
|
+
//
|
|
17
|
+
// The last two are the dangerous shape: a test that isolates nothing does not
|
|
18
|
+
// announce itself, it just quietly stops testing what its comment says it tests.
|
|
19
|
+
//
|
|
20
|
+
// WHY A GUARD AND NOT THREE FIXES. Three sites, three separate tasks, each found by
|
|
21
|
+
// accident. tests/memory_pull.mjs, tests/redteam_patrol.mjs and
|
|
22
|
+
// tests/setup_device_flow_fallback.mjs already do it correctly, so the convention
|
|
23
|
+
// exists and is simply easy to miss — which is the definition of something CI should
|
|
24
|
+
// hold rather than a reviewer.
|
|
25
|
+
|
|
26
|
+
const fs = require('node:fs');
|
|
27
|
+
const path = require('node:path');
|
|
28
|
+
|
|
29
|
+
const REPO_ROOT = path.resolve(__dirname, '..', '..');
|
|
30
|
+
const TESTS_DIR = path.join(REPO_ROOT, 'tests');
|
|
31
|
+
|
|
32
|
+
// WHAT COUNTS AS A SPAWN ENV. Only a literal that SPREADS process.env and assigns
|
|
33
|
+
// HOME — that is the shape every real defect had. Two narrowings, both learned by
|
|
34
|
+
// getting this wrong on the first run against the tree:
|
|
35
|
+
//
|
|
36
|
+
// - COMMENTS ARE STRIPPED. All three fixed files now explain the bug by QUOTING
|
|
37
|
+
// the broken line, so a raw text scan reports the very files that fixed it.
|
|
38
|
+
// - A HELPER'S CALL SITE IS NOT A SPAWN ENV. tests/setup_smoke.mjs passes
|
|
39
|
+
// `{ HOME: fakeHome }` to its own runSetup(), which adds USERPROFILE itself.
|
|
40
|
+
// Requiring `...process.env` in the same literal distinguishes 'building a
|
|
41
|
+
// child's environment' from 'passing an option to a function', and flags the
|
|
42
|
+
// helper rather than each of its callers — which is where the fix belongs.
|
|
43
|
+
const HOME_ASSIGN_RE = /(^|[{,\s])HOME\s*:/;
|
|
44
|
+
const USERPROFILE_RE = /(^|[{,\s])USERPROFILE\s*:/;
|
|
45
|
+
const PROCESS_ENV_RE = /\.\.\.process\.env/;
|
|
46
|
+
|
|
47
|
+
// Strip line and block comments so prose ABOUT the bug is not read as the bug.
|
|
48
|
+
// Errs toward keeping text (a guard should fail loud, not quiet): only the two
|
|
49
|
+
// unambiguous comment forms are removed.
|
|
50
|
+
function stripComments(src) {
|
|
51
|
+
return String(src || '')
|
|
52
|
+
.replace(/\/\*[\s\S]*?\*\//g, '')
|
|
53
|
+
.replace(/(^|[^:])\/\/.*$/gm, '$1');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Files where HOME is the SUBJECT rather than an isolation mechanism, named in task
|
|
57
|
+
// 1003763. An allowlist entry is a claim that the file means something else by HOME,
|
|
58
|
+
// so each one says which.
|
|
59
|
+
const ALLOW = new Map([
|
|
60
|
+
['scrubber_corpus.mjs', "HOME:'/root' is literal corpus DATA — a string the scrubber is asked to redact, not an env handed to a child"],
|
|
61
|
+
['lib_sh_resolution.mjs', 'exercises POSIX shell HOME resolution; HOME is the thing under test, and a win32 variable would change the subject'],
|
|
62
|
+
['home_isolation_guard.mjs', "this guard's OWN tests carry the broken shape as fixture strings — it must not report its own corpus, the same way category-advisory-guard.js had to stop matching its own filename"],
|
|
63
|
+
]);
|
|
64
|
+
|
|
65
|
+
// PURE — the lines that build a child env with HOME and no USERPROFILE. Exported so
|
|
66
|
+
// the matching is testable without the tree: a scanner whose pattern silently stops
|
|
67
|
+
// matching reports a clean repo, which is the failure mode this whole file is about.
|
|
68
|
+
function offendingLines(src) {
|
|
69
|
+
const lines = stripComments(src).split('\n');
|
|
70
|
+
const out = [];
|
|
71
|
+
for (let i = 0; i < lines.length; i++) {
|
|
72
|
+
if (!HOME_ASSIGN_RE.test(lines[i])) continue;
|
|
73
|
+
// A literal can wrap: read a small window either side for its companions.
|
|
74
|
+
const window = lines.slice(Math.max(0, i - 4), i + 5).join('\n');
|
|
75
|
+
if (!PROCESS_ENV_RE.test(window)) continue; // an option object, not a child env
|
|
76
|
+
if (USERPROFILE_RE.test(window)) continue; // already isolated properly
|
|
77
|
+
out.push({ line: i + 1, text: lines[i].trim() });
|
|
78
|
+
}
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
function checkHomeIsolation() {
|
|
82
|
+
const name = 'a child env that sets HOME also sets USERPROFILE (task 1003763)';
|
|
83
|
+
let names = [];
|
|
84
|
+
try {
|
|
85
|
+
names = fs.readdirSync(TESTS_DIR).filter((f) => f.endsWith('.mjs'));
|
|
86
|
+
} catch (e) {
|
|
87
|
+
return { name, ok: true, hardFail: false, violations: [], warnings: [`tests/ unreadable: ${e.message}`], note: 'skipped.' };
|
|
88
|
+
}
|
|
89
|
+
// The scan must not pass by finding nothing.
|
|
90
|
+
if (names.length === 0) {
|
|
91
|
+
return {
|
|
92
|
+
name, ok: false, hardFail: true,
|
|
93
|
+
violations: ['no tests/*.mjs found at all — that is a broken scan, not a clean one'],
|
|
94
|
+
warnings: [], note: 'the scan produced an empty file set.',
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const violations = [];
|
|
99
|
+
let scanned = 0;
|
|
100
|
+
let sitesSeen = 0;
|
|
101
|
+
for (const n of names) {
|
|
102
|
+
const src = fs.readFileSync(path.join(TESTS_DIR, n), 'utf8');
|
|
103
|
+
scanned += 1;
|
|
104
|
+
const hits = offendingLines(src);
|
|
105
|
+
if (HOME_ASSIGN_RE.test(stripComments(src)) && PROCESS_ENV_RE.test(stripComments(src))) sitesSeen += 1;
|
|
106
|
+
if (ALLOW.has(n)) continue;
|
|
107
|
+
for (const h of hits) {
|
|
108
|
+
violations.push(`tests/${n}:${h.line} sets HOME for a child without USERPROFILE — \`${h.text.slice(0, 90)}\`. `
|
|
109
|
+
+ 'On Windows os.homedir() reads USERPROFILE and ignores HOME, so this isolates NOTHING: the child sees the '
|
|
110
|
+
+ 'developer\'s real home and real session, and an unauthenticated-path assertion can pass because the machine '
|
|
111
|
+
+ 'happens to be signed in. Set USERPROFILE (and HOMEDRIVE/HOMEPATH) to the same directory.');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
name,
|
|
117
|
+
ok: violations.length === 0,
|
|
118
|
+
hardFail: violations.length > 0,
|
|
119
|
+
violations,
|
|
120
|
+
warnings: [],
|
|
121
|
+
note: `${scanned} test file(s) scanned, ${sitesSeen} of them build a child env with HOME; ${ALLOW.size} allowlisted where HOME is the subject rather than the isolation. `
|
|
122
|
+
+ 'Three separate tasks (1003760, 1003941, 1003763) fixed this one site at a time before it was worth a check.',
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
module.exports = { checkHomeIsolation, offendingLines, stripComments, ALLOW, HOME_ASSIGN_RE, USERPROFILE_RE, PROCESS_ENV_RE };
|
|
@@ -27,7 +27,7 @@ const {
|
|
|
27
27
|
} = require('./ship-land.js');
|
|
28
28
|
const { runSmoke } = require('./ship-grade.js');
|
|
29
29
|
const { dbOnlyIgnoredNotice } = require('./ship-honesty.js');
|
|
30
|
-
const { currentBranch, mainWorktreeBusy, regenerateApiClient, regenerateApiDocs, regenerateDiagrams, regenerateFileMap, regenerateRepoMap, regenerateSessionIndex } = require('./ship-regen.js');
|
|
30
|
+
const { currentBranch, mainWorktreeBusy, regenerateApiClient, regenerateApiDocs, regenerateCopyInventory, regenerateDiagrams, regenerateFileMap, regenerateRepoMap, regenerateSessionIndex } = require('./ship-regen.js');
|
|
31
31
|
const { REPO_ROOT } = require('./ship-state.js');
|
|
32
32
|
|
|
33
33
|
// zeroCommitVerdict — dbOnly is deliberately consulted ONLY at zero commits
|
|
@@ -119,6 +119,10 @@ async function mergeLocally(taskId, valueSummary, { dbOnly = false } = {}) {
|
|
|
119
119
|
regenerateSessionIndex();
|
|
120
120
|
// Refresh the generated file-map sections (skills + scheduled-tasks) on the same beat (ADR 0066 / task 1276).
|
|
121
121
|
regenerateFileMap();
|
|
122
|
+
// Refresh the copy registry + inventory on the same beat (task 1003556). Its rows
|
|
123
|
+
// carry line numbers, so ANY edit to a scanned UI file staled it — and nothing in
|
|
124
|
+
// the ship path regenerated it, so the PR was born stale and CI said so.
|
|
125
|
+
regenerateCopyInventory();
|
|
122
126
|
// Refresh the generated OpenAPI spec + API reference from the shipped route tree (task 1918).
|
|
123
127
|
regenerateApiDocs();
|
|
124
128
|
// ...then the typed client FROM that spec (+ the devbox vendored copy) on the same beat (task 2051).
|
|
@@ -235,6 +235,34 @@ function regenerateFileMap() {
|
|
|
235
235
|
return 'committed-nofatal';
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
+
// docs/copy-registry.json + docs/copy-inventory.md — the reader-facing copy the UI
|
|
239
|
+
// actually renders (task 1003556).
|
|
240
|
+
//
|
|
241
|
+
// WHY IT HAS TO RUN HERE. Every row in the registry carries a `line`, so editing ANY
|
|
242
|
+
// scanned UI file shifts line numbers and makes tests/copy_inventory.mjs red — on the
|
|
243
|
+
// PR's MERGE ref, not on the branch, which is the worst place to find out. Nothing in
|
|
244
|
+
// the ship path regenerated it (grep for copy-inventory across ship.js, ship-regen.js
|
|
245
|
+
// and ship-preflight-steps.js used to return zero hits) and fitness did not cover the
|
|
246
|
+
// pair either, so the builder got no local signal at all and learned from CI.
|
|
247
|
+
//
|
|
248
|
+
// Task 1003546 fixed the SERVER-side merge heals for the same artifact. Those repair a
|
|
249
|
+
// strand after it happens; this is the prevention, so the PR is not born stale.
|
|
250
|
+
function regenerateCopyInventory() {
|
|
251
|
+
console.log(' regenerating the copy registry + inventory from the shipped tree...');
|
|
252
|
+
shellOk(`"${process.execPath}" ${JSON.stringify(path.join(__dirname, 'copy-inventory.js'))}`);
|
|
253
|
+
const dirty = gitOk('git status --porcelain docs/copy-registry.json docs/copy-inventory.md');
|
|
254
|
+
if (!dirty) {
|
|
255
|
+
console.log(' copy registry already current — nothing to commit');
|
|
256
|
+
return 'current';
|
|
257
|
+
}
|
|
258
|
+
shellOk('git add docs/copy-registry.json docs/copy-inventory.md');
|
|
259
|
+
if (shellOk('git commit -m "chore(copy): auto-regenerate the copy registry + inventory (task 1003556)"')) {
|
|
260
|
+
console.log(' committed auto-regenerated copy registry');
|
|
261
|
+
return 'committed';
|
|
262
|
+
}
|
|
263
|
+
return 'committed-nofatal';
|
|
264
|
+
}
|
|
265
|
+
|
|
238
266
|
// ---------- merge serialization lock (#462 C4; extended in #269 C6) ----------
|
|
239
267
|
//
|
|
240
268
|
// autoMerge() mutates the SHARED main worktree (REPO_ROOT). Two concurrent
|
|
@@ -313,6 +341,7 @@ module.exports = {
|
|
|
313
341
|
regenerateApiClient,
|
|
314
342
|
regenerateApiDocs,
|
|
315
343
|
regenerateDiagrams,
|
|
344
|
+
regenerateCopyInventory,
|
|
316
345
|
regenerateFileMap,
|
|
317
346
|
regenerateRepoMap,
|
|
318
347
|
regenerateSessionIndex,
|
package/src/module-api.js
CHANGED
|
@@ -71,7 +71,7 @@ const { responsibilityFor, ROLE_RESPONSIBILITIES } = require('./role-responsibil
|
|
|
71
71
|
// there. scripts/gds/bump-version.js still rewrites the literal below; it appends
|
|
72
72
|
// the entry to that file. Look for a version's history there, not here.
|
|
73
73
|
// ---------------------------------------------------------------------------
|
|
74
|
-
const CORE_VERSION = '1.19.
|
|
74
|
+
const CORE_VERSION = '1.19.821'; // CI auto-patch carrier (ADR 0161); changelog: docs/module-api-changelog.md
|
|
75
75
|
|
|
76
76
|
// A namespaced logger so a module's log lines are attributable + consistent.
|
|
77
77
|
// Usage: const log = api.logger('dev-box'); log.info('mounted');
|
package/tests/cli_package.mjs
CHANGED
|
@@ -21,6 +21,22 @@ import { spawnSync } from 'node:child_process';
|
|
|
21
21
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
22
22
|
|
|
23
23
|
const REPO_ROOT = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
24
|
+
|
|
25
|
+
// HOME ALONE IS NOT ISOLATION ON WINDOWS (task 1003763).
|
|
26
|
+
//
|
|
27
|
+
// os.homedir() reads USERPROFILE on win32 and never consults HOME, so
|
|
28
|
+
// `env: { ...process.env, HOME: home }` isolated nothing there: the installed CLI
|
|
29
|
+
// saw the DEVELOPER'S REAL session file. That is precisely the false green the
|
|
30
|
+
// comment below guards against — an unauthenticated-path assertion passing because
|
|
31
|
+
// the machine happens to be signed in.
|
|
32
|
+
//
|
|
33
|
+
// HOMEDRIVE/HOMEPATH are os.homedir()'s second win32 source, so all four go. Named
|
|
34
|
+
// rather than inlined twice: this is the third site in the repo to need it (after
|
|
35
|
+
// tests/cli_sessions.mjs in task 1003760 and tests/cli_surface.mjs in task 1003941),
|
|
36
|
+
// and every one of them got it half-right first.
|
|
37
|
+
function homelessEnv(home, extra = {}) {
|
|
38
|
+
return { ...process.env, HOME: home, USERPROFILE: home, HOMEDRIVE: '', HOMEPATH: home, ...extra };
|
|
39
|
+
}
|
|
24
40
|
const BUILDER = path.join(REPO_ROOT, 'scripts', 'gds', 'build-cli-package.js');
|
|
25
41
|
// Running npm from a test (task 1003529). On Windows `npm` is a .cmd shim: bare
|
|
26
42
|
// 'npm' is ENOENT and 'npm.cmd' is EINVAL under Node 24's CVE-2024-27980 mitigation,
|
|
@@ -152,7 +168,7 @@ test('the packed tarball installs and every verb runs with no repo present', (t)
|
|
|
152
168
|
// file on this machine cannot make a verb look healthier than it is.
|
|
153
169
|
fs.writeFileSync(path.join(site, 'package.json'), JSON.stringify({ name: 'probe', private: true }));
|
|
154
170
|
const installed = npm(['install', '--no-audit', '--no-fund', '--silent', path.join(site, tarball)], {
|
|
155
|
-
cwd: site, encoding: 'utf8', env:
|
|
171
|
+
cwd: site, encoding: 'utf8', env: homelessEnv(home),
|
|
156
172
|
});
|
|
157
173
|
assert.equal(installed.status, 0, `npm install failed:\n${installed.stderr}`);
|
|
158
174
|
|
|
@@ -166,7 +182,7 @@ test('the packed tarball installs and every verb runs with no repo present', (t)
|
|
|
166
182
|
|
|
167
183
|
const runVerb = (args) => spawnSync(process.execPath, [bongos, ...args], {
|
|
168
184
|
cwd: site, encoding: 'utf8', input: '',
|
|
169
|
-
env:
|
|
185
|
+
env: homelessEnv(home, { CLOUDBONGOS_API_BASE: 'http://127.0.0.1:45999', NO_COLOR: '1' }),
|
|
170
186
|
});
|
|
171
187
|
|
|
172
188
|
// help and version must work with nothing configured at all.
|
|
@@ -271,11 +271,16 @@ test('sessions: every id on a row is a door, the earned figure is shown, the tot
|
|
|
271
271
|
assert.match(html, /<div class="stat-row" id="stats-body"><\/div>/);
|
|
272
272
|
const ths = (html.match(/<th[ >]/g) || []).length;
|
|
273
273
|
// task 1002516: a tenth column, "Plain speech" — the transcript accessibility
|
|
274
|
-
// dimension the criterion asks to surface on the dashboard (ADR 0291).
|
|
275
|
-
//
|
|
276
|
-
//
|
|
277
|
-
|
|
278
|
-
|
|
274
|
+
// dimension the criterion asks to surface on the dashboard (ADR 0291).
|
|
275
|
+
// task 1003975: an eleventh, "Kind" — the session's derived shape, so the 54%
|
|
276
|
+
// of rows with no task chip are readable at all. The per-cell contracts (a
|
|
277
|
+
// not-scored session is a dash, never a zero; an unclassified one is a dash,
|
|
278
|
+
// never 'Unclear') live in tests/hall_sessions_ledger.mjs and
|
|
279
|
+
// tests/session_type.mjs; this pin is the column count AND that the empty row
|
|
280
|
+
// still spans them — a header added without widening the colspan leaves the
|
|
281
|
+
// empty state short by a column, which no screenshot pass would catch.
|
|
282
|
+
assert.equal(ths, 11, 'eleven columns: session, builder, kind, tasks, earned, turns, tokens, tool errors, duration, plain speech, recorded');
|
|
283
|
+
assert.match(src, new RegExp(`colspan="${ths}"`), 'the empty row spans them all');
|
|
279
284
|
const fam = html.indexOf('/builders/oversight.css');
|
|
280
285
|
assert.ok(fam > 0 && html.indexOf('/builders/sessions.css') > fam, 'sessions.html links the family sheet before its own');
|
|
281
286
|
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// tests/home_isolation_guard.mjs — setting HOME for a child isolates nothing on
|
|
2
|
+
// Windows (task 1003763).
|
|
3
|
+
//
|
|
4
|
+
// os.homedir() reads USERPROFILE on win32 and never consults HOME, so
|
|
5
|
+
// `env: { ...process.env, HOME: tmp }` leaves the child looking at the developer's
|
|
6
|
+
// real home — and their real CLI session. Three tasks fixed this one site at a time:
|
|
7
|
+
// 1003760 (cli_sessions, which DESTROYED a live session), 1003941 (cli_surface) and
|
|
8
|
+
// this one (cli_package). The last two are the dangerous shape — a test that isolates
|
|
9
|
+
// nothing does not announce itself, it quietly stops testing what its comment claims.
|
|
10
|
+
//
|
|
11
|
+
// Run: node tests/home_isolation_guard.mjs
|
|
12
|
+
|
|
13
|
+
import { test } from 'node:test';
|
|
14
|
+
import assert from 'node:assert/strict';
|
|
15
|
+
import { readFileSync } from 'node:fs';
|
|
16
|
+
import path from 'node:path';
|
|
17
|
+
import { fileURLToPath } from 'node:url';
|
|
18
|
+
import { createRequire } from 'node:module';
|
|
19
|
+
|
|
20
|
+
const require = createRequire(import.meta.url);
|
|
21
|
+
const { checkHomeIsolation, offendingLines, stripComments, ALLOW } =
|
|
22
|
+
require('../scripts/gds/home-isolation-guard.js');
|
|
23
|
+
|
|
24
|
+
const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
25
|
+
|
|
26
|
+
test('the live tree is clean, and the scan is not empty', () => {
|
|
27
|
+
const r = checkHomeIsolation();
|
|
28
|
+
assert.deepEqual(r.violations, [], r.violations.join('\n'));
|
|
29
|
+
// A guard that scans nothing passes for free. The note carries the counts so a
|
|
30
|
+
// silently-broken scan is visible rather than reassuring.
|
|
31
|
+
const scanned = Number(/^(\d+) test file/.exec(r.note)?.[1] ?? 0);
|
|
32
|
+
const sites = Number(/(\d+) of them build a child env/.exec(r.note)?.[1] ?? 0);
|
|
33
|
+
assert.ok(scanned > 100, `expected the whole tests/ tree, scanned ${scanned}`);
|
|
34
|
+
assert.ok(sites > 0, 'no file builds a child env with HOME — the pattern has drifted and this guard is inert');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('the original broken shape IS caught', () => {
|
|
38
|
+
const src = 'const r = spawnSync(node, [x], { env: { ...process.env, HOME: home } });';
|
|
39
|
+
assert.equal(offendingLines(src).length, 1);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('the fixed shape is not', () => {
|
|
43
|
+
const src = 'const r = spawnSync(node, [x], { env: { ...process.env, HOME: home, USERPROFILE: home } });';
|
|
44
|
+
assert.deepEqual(offendingLines(src), []);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('a HELPER CALL SITE is not a child env', () => {
|
|
48
|
+
// tests/setup_smoke.mjs passes { HOME: fakeHome } to its own runSetup(), which adds
|
|
49
|
+
// USERPROFILE itself. Flagging the callers would point at the wrong line and, worse,
|
|
50
|
+
// train someone to "fix" three call sites instead of the one helper.
|
|
51
|
+
assert.deepEqual(offendingLines("runSetup(['--dry-run'], { HOME: fakeHome });"), []);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('a COMMENT quoting the bug is not the bug', () => {
|
|
55
|
+
// Every file that fixed this now explains it by quoting the broken line. A raw text
|
|
56
|
+
// scan therefore reports exactly the files that already fixed it — which is how the
|
|
57
|
+
// first run of this guard produced three false positives.
|
|
58
|
+
assert.deepEqual(offendingLines('// env: { ...process.env, HOME: home } isolated nothing'), []);
|
|
59
|
+
assert.deepEqual(offendingLines('/* env: { ...process.env, HOME: home } */'), []);
|
|
60
|
+
assert.ok(!stripComments('// { ...process.env, HOME: x }').includes('HOME'));
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('a multi-line literal is still read', () => {
|
|
64
|
+
const src = [
|
|
65
|
+
'const r = spawnSync(node, [x], {',
|
|
66
|
+
' env: {',
|
|
67
|
+
' ...process.env,',
|
|
68
|
+
' HOME: home,',
|
|
69
|
+
' },',
|
|
70
|
+
'});',
|
|
71
|
+
].join('\n');
|
|
72
|
+
assert.equal(offendingLines(src).length, 1, 'the literal wraps — a single-line matcher misses the real shape');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('every allowlisted file exists and still means HOME differently', () => {
|
|
76
|
+
// An allowlist entry is a claim. If the file is gone, the claim is stale and the
|
|
77
|
+
// entry is a hole nobody is watching.
|
|
78
|
+
for (const [name, why] of ALLOW) {
|
|
79
|
+
const p = path.join(REPO_ROOT, 'tests', name);
|
|
80
|
+
let src;
|
|
81
|
+
try { src = readFileSync(p, 'utf8'); } catch {
|
|
82
|
+
assert.fail(`allowlisted tests/${name} no longer exists — remove the entry rather than leaving an unwatched hole`);
|
|
83
|
+
}
|
|
84
|
+
assert.ok(why && why.length > 20, `tests/${name} needs a reason, not just an exemption`);
|
|
85
|
+
assert.match(src, /HOME/, `tests/${name} no longer mentions HOME, so its exemption is dead`);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('the two sites this task fixed are actually fixed', () => {
|
|
90
|
+
const src = readFileSync(path.join(REPO_ROOT, 'tests', 'cli_package.mjs'), 'utf8');
|
|
91
|
+
assert.deepEqual(offendingLines(src), []);
|
|
92
|
+
assert.match(src, /USERPROFILE/, 'cli_package must set USERPROFILE alongside HOME');
|
|
93
|
+
const surface = readFileSync(path.join(REPO_ROOT, 'tests', 'cli_surface.mjs'), 'utf8');
|
|
94
|
+
assert.deepEqual(offendingLines(surface), []);
|
|
95
|
+
});
|