@bongos/core 1.19.821 → 1.19.822

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 CHANGED
@@ -2,22 +2,22 @@
2
2
  "artifact": "bongos-core",
3
3
  "manifest_schema": 1,
4
4
  "generator": "scripts/gds/package-core.js",
5
- "core_version": "1.19.821",
6
- "core_contract": "1.19.821",
7
- "source_commit": "8010be7b18c8402b4992ca02d3ea6486e3864b8d",
5
+ "core_version": "1.19.822",
6
+ "core_contract": "1.19.822",
7
+ "source_commit": "5a9c009cff17c2a500ff23f5d0de66a1b7f00477",
8
8
  "source_ref": "HEAD",
9
- "built_at": "2026-09-17T10:54:28.375Z",
9
+ "built_at": "2026-09-17T11:05:47.254Z",
10
10
  "redaction": {
11
11
  "model": "docs-redacted+functional-verbatim",
12
12
  "docs_redacted": 490,
13
13
  "agent_docs_stubbed": 26,
14
- "functional_verbatim": 2227,
14
+ "functional_verbatim": 2228,
15
15
  "rules": 3,
16
16
  "gate_literals": 3,
17
17
  "gate": "passed"
18
18
  },
19
- "file_count": 2743,
20
- "tree_sha256": "b45cfd41d39a01485663e30b259328725d4eb07530cb520214df9811d2842e0b",
19
+ "file_count": 2744,
20
+ "tree_sha256": "acbc13ab96c308bd0c0aa200c9dd1f6af1013ed6771c70730a797f7a1fb4a697",
21
21
  "files": [
22
22
  {
23
23
  "path": ".claude/skills/ask-for-help/SKILL.md",
@@ -2547,7 +2547,7 @@
2547
2547
  {
2548
2548
  "path": "docs/module-api-changelog.md",
2549
2549
  "mode": "0000644",
2550
- "sha256": "9d562958c91d14116733518e2934b1a78b980adc6a19c652cfe47eb85c3693bf"
2550
+ "sha256": "9182a3b88e6092a231f59db4220628cb8579244c8289350406f07187c959e644"
2551
2551
  },
2552
2552
  {
2553
2553
  "path": "docs/modules-contract.md",
@@ -5612,7 +5612,7 @@
5612
5612
  {
5613
5613
  "path": "modules/lifecycle/dead-deps.js",
5614
5614
  "mode": "0000644",
5615
- "sha256": "c9f7aa89a4b1e9a201189608ff8ebc4910ee6ca19be33ce681f2d32cedb0b39d"
5615
+ "sha256": "4738131a48e85dd7bf0644ddd3686c85d0d1d0da55ee623b1834d048c614b91c"
5616
5616
  },
5617
5617
  {
5618
5618
  "path": "modules/lifecycle/done-when.js",
@@ -7812,12 +7812,12 @@
7812
7812
  {
7813
7813
  "path": "package-lock.json",
7814
7814
  "mode": "0000644",
7815
- "sha256": "bd6442d6f7a4122841efdb7ed6d796e43f9df2bb4a65677d19d586af19cb0650"
7815
+ "sha256": "d13165aac1aea3612a3c5af1b5b14267acdde35f2a8d99482310c7a749f9761c"
7816
7816
  },
7817
7817
  {
7818
7818
  "path": "package.json",
7819
7819
  "mode": "0000644",
7820
- "sha256": "8185455c292222a25c1928dc9ef4959bc09783fb71fc231e89dca09793239e44"
7820
+ "sha256": "0f9f0baab592f70e890e2a39e61dcf21c5170841f97b8c82cb16703c2a959756"
7821
7821
  },
7822
7822
  {
7823
7823
  "path": "public-docs/index.html",
@@ -7947,7 +7947,7 @@
7947
7947
  {
7948
7948
  "path": "scripts/gds/audit-deps.js",
7949
7949
  "mode": "0000644",
7950
- "sha256": "891aadcbea8ef257f68f20f140fa988c45ac06d4caa19802136c372d403db7ba"
7950
+ "sha256": "ff7ccdf15ae2c215d3330e957d6a36adc7d48f5d9bd5042b5d61bb228b878073"
7951
7951
  },
7952
7952
  {
7953
7953
  "path": "scripts/gds/audit-exports.js",
@@ -9722,7 +9722,7 @@
9722
9722
  {
9723
9723
  "path": "src/module-api.js",
9724
9724
  "mode": "0000644",
9725
- "sha256": "363876fc33b090bf88ca7b767b82778feb63ee9bb607c00e4a37a2aae0b5416f"
9725
+ "sha256": "782160b1ae7c1483c92337a589f92d8099a8bbee37005ea744c78bd4fcb5803c"
9726
9726
  },
9727
9727
  {
9728
9728
  "path": "src/module-loader/catalog.js",
@@ -12494,6 +12494,11 @@
12494
12494
  "mode": "0000644",
12495
12495
  "sha256": "a36acb19e59db1f9eb885ab6497a43d1c8ce0ba6198b0f5cc98f33bf08837fdf"
12496
12496
  },
12497
+ {
12498
+ "path": "tests/prose_gated_deps.mjs",
12499
+ "mode": "0000644",
12500
+ "sha256": "5d85d13a0cf1feb3c0aa809841126f4f9e9effe66fc57b5064b612627ce4916f"
12501
+ },
12497
12502
  {
12498
12503
  "path": "tests/provision.mjs",
12499
12504
  "mode": "0000644",
@@ -2116,5 +2116,7 @@ is load-bearing: the script throws rather than guess if it is missing, and
2116
2116
  landed since 1.19.819 with no explicit bump. run 35209838815. (task 1002620)
2117
2117
  1.19.821 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
2118
2118
  landed since 1.19.820 with no explicit bump. run 35212866365. (task 1002620)
2119
+ 1.19.822 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
2120
+ landed since 1.19.821 with no explicit bump. run 35213847140. (task 1002620)
2119
2121
  ---------------------------------------------------------------------------
2120
2122
  ```
@@ -198,7 +198,148 @@ function findStrandedTasks(tasks) {
198
198
  return out;
199
199
  }
200
200
 
201
+ // ---- PROSE-DECLARED GATES (task 1003857) -----------------------------------
202
+ //
203
+ // Everything above reads the STRUCTURED graph — blocked_by edges. A gate written
204
+ // in a task's DESCRIPTION is entirely unpoliced, and they go stale the same way:
205
+ // task 1002839 (ready) names "existing open task 1001380" as a precondition, and
206
+ // 1001380 was abandoned on 2026-08-18, superseded by ADR 0089. A builder opening
207
+ // 1002839 is told to coordinate with a task that does not exist, and told it is open.
208
+ //
209
+ // ADVISORY, NEVER A GATE. A prose match is weaker evidence than an edge: the text
210
+ // may be history ("this replaces task N"), a citation, or simply wrong. It reports
211
+ // candidates for a human to read and must never refuse a claim — that is the
212
+ // difference between this and DEAD_DEP_STATUSES above, and it is deliberate.
213
+ //
214
+ // PRECISION COMES FROM THE VERB, NOT THE ID. Matching "any abandoned id in the
215
+ // body" is the mistake that made the sibling supersession scan unusable (idea
216
+ // 1000807: ~44 hits, nearly all citations). So an id counts only when a GATE PHRASE
217
+ // governs it within a short window — needs / depends on / blocked by / gated on /
218
+ // requires / after / prereq — and the window is small enough that a paragraph
219
+ // mentioning a gate and, separately, an id does not join them up.
220
+ // TWO PHRASINGS, because the live evidence has both — and the second is the one the
221
+ // filing task's own example actually uses.
222
+ //
223
+ // A GATE: 'needs task N', 'blocked by N', 'depends on N'.
224
+ // A LIVENESS ASSERTION: 'existing OPEN task N', 'task N is ready to claim'.
225
+ //
226
+ // Task 1002839 — the live instance the task names — reads "and existing open task
227
+ // 1001380 covers overlapping ground". That is not a dependency; it is a claim that
228
+ // 1001380 is OPEN, and 1001380 was abandoned on 2026-08-18. A gate-only matcher
229
+ // missed it, which I found by measuring rather than by reading the spec: the first
230
+ // version returned it only because a 'needs' in the PREVIOUS clause leaked across a
231
+ // semicolon, and tightening that correctly dropped it.
232
+ //
233
+ // Both shapes send a builder to a task that is not there, which is the harm. Only
234
+ // the liveness one also states something false on its face.
235
+ const GATE_PHRASE_RE = /\b(?:needs?|depends?\s+on|dependent\s+on|blocked\s+by|blocks?|gated\s+on|gates?|requires?|required\s+by|prereq(?:uisite)?s?|precondition|waits?\s+on|waiting\s+on|after)\b/i;
236
+
237
+ // 'open task N', 'existing open task N', 'still-open task N', 'the open task N'.
238
+ // Anchored to the id's immediate left so a paragraph that says 'open' somewhere does
239
+ // not qualify every id in it.
240
+ const LIVENESS_BEFORE_RE = /\b(?:still[-\s]+)?open\s+(?:task\s+)?#?$/i;
241
+ // 'task N is ready to claim', 'task N is still open', 'task N remains open'.
242
+ const LIVENESS_AFTER_RE = /^\s*(?:\([^)]{0,80}\)\s*)?(?:is|remains|stays)\s+(?:still\s+)?(?:open|ready\s+to\s+claim|unclaimed|in\s+flight)\b/i;
243
+
244
+ // How far after a gate phrase an id still counts as governed by it. Sized to span
245
+ // 'needs the existing open task 1001380 to land first', not a whole paragraph.
246
+ const GATE_WINDOW = 80;
247
+
248
+ // A task id in prose. Two forms, and the second is the trap.
249
+ //
250
+ // LIVE form — 6-7 digits: 'existing open task 1001380'.
251
+ // SHORT form — the PRE-OFFSET ref this project used before the import, written as
252
+ // `#528` or 'task 528'. Task 1000528's own gate is written that way,
253
+ // and it is the case that motivated the original row — so a live-id
254
+ // match misses precisely the instance this exists to find.
255
+ //
256
+ // The short form is only recognised with an explicit `task ` / `#` prefix. A bare
257
+ // 3-digit number in prose is a count, a line number or a year far more often than it
258
+ // is a task, and this runs over every description on the board.
259
+ const ID_RE = /(?:\btask\s+|#)(\d{1,5})\b|(?:\btask\s+|#)?(\d{6,7})\b/g;
260
+
261
+ // The id spaces to probe, newest first. Same precedent as diagram-facts.js: the import
262
+ // shifted every id by 1,000,000, so a pre-offset ref resolves by adding the offset.
263
+ const IMPORT_ID_OFFSETS = [0, 1_000_000];
264
+
265
+ // PURE — every id a single textual ref could mean, most likely first. A short ref
266
+ // yields the offset candidate too; a live-width ref is already resolved.
267
+ function idCandidates(raw) {
268
+ const n = Number(raw);
269
+ if (!Number.isInteger(n) || n <= 0) return [];
270
+ // A ref already in the LIVE width is resolved - probing an offset on it would invent
271
+ // a second id that is not what the text says (1001380 + 1e6 = 2001380, a row nobody
272
+ // wrote). The offset probe exists for the SHORT pre-offset form only.
273
+ if (String(n).length >= 6) return [String(n)];
274
+ const out = [];
275
+ for (const off of IMPORT_ID_OFFSETS) {
276
+ const cand = String(n + off);
277
+ // Only offer a candidate that could BE an id: the live space is 6-7 digits.
278
+ if (cand.length >= 6 && cand.length <= 7 && !out.includes(cand)) out.push(cand);
279
+ }
280
+ return out;
281
+ }
282
+
283
+ // Ids that share the integer space but are NOT tasks. Measured, not guessed: the
284
+ // first run of this over the live board returned two hits and one was task 1002844's
285
+ // 'Source: idea 1000454' — an idea citation, whose id happens to look like a task's.
286
+ // Reporting it would have sent a human to look up a task that does not exist, which
287
+ // is the very failure this detector exists to stop.
288
+ const OTHER_ENTITY_RE = /\b(?:idea|blocker|report|learning|claim|builder|goal|version|PR|pull\s+request)\s+#?$/i;
289
+
290
+ // PURE — the ids this text appears to declare a GATE on. Exported so the rule is
291
+ // testable without a DB: the risk here is a matcher that quietly matches nothing (a
292
+ // clean report) or everything (a report nobody reads).
293
+ function proseGatedIds(text) {
294
+ const src = String(text || '');
295
+ const out = new Set();
296
+ for (const m of src.matchAll(ID_RE)) {
297
+ const rawId = m[1] || m[2];
298
+ const before = src.slice(Math.max(0, m.index - GATE_WINDOW), m.index);
299
+ // An id belonging to another entity is not a task gate, whatever governs it.
300
+ if (OTHER_ENTITY_RE.test(before)) continue;
301
+ // The window stops at a SENTENCE BOUNDARY. Also measured: the same false
302
+ // positive had 'needs' in the preceding sentence ('…the first thing that task
303
+ // needs. Source: idea 1000454'), so a fixed-width window let a verb govern across
304
+ // a full stop. A gate and its id belong to one sentence.
305
+ // A liveness assertion binds TIGHTLY to the id on either side, so it needs no
306
+ // window and no sentence rule.
307
+ const after = src.slice(m.index + m[0].length, m.index + m[0].length + 60);
308
+ if (LIVENESS_BEFORE_RE.test(before) || LIVENESS_AFTER_RE.test(after)) { for (const c of idCandidates(rawId)) out.add(c); continue; }
309
+ // A GATE may be a few words back, but the window stops at a SENTENCE BOUNDARY:
310
+ // measured, a fixed-width window let 'needs' govern across a full stop and a
311
+ // semicolon into an unrelated clause.
312
+ const lastStop = Math.max(before.lastIndexOf('. '), before.lastIndexOf('\n'), before.lastIndexOf('; '));
313
+ const governing = lastStop === -1 ? before : before.slice(lastStop + 1);
314
+ // Only the text BEFORE the id, so 'task 1001380 needs review' is not read as a
315
+ // gate ON 1001380 — the verb has to govern the id, not follow it.
316
+ if (GATE_PHRASE_RE.test(governing)) for (const c of idCandidates(rawId)) out.add(c);
317
+ }
318
+ return out;
319
+ }
320
+
321
+ // PURE — live tasks whose PROSE names a dead task as a gate. `tasks` are rows with
322
+ // { id, status, description }; `statusById` answers what an id's status is.
323
+ // Deliberately mirrors findStrandedTasks' shape so audit-deps can print one answer
324
+ // to "what is stranded" rather than two.
325
+ function findProseGatedTasks(tasks, statusById) {
326
+ const out = [];
327
+ for (const t of Array.isArray(tasks) ? tasks : []) {
328
+ if (!t || !LIVE_STATUSES.has(String(t.status))) continue;
329
+ const dead = [];
330
+ for (const id of proseGatedIds(t.description)) {
331
+ if (String(id) === String(t.id)) continue; // a task citing itself is not a gate
332
+ const st = statusById(id);
333
+ if (st && DEAD_DEP_STATUSES.has(String(st))) dead.push({ id: String(id), status: String(st) });
334
+ }
335
+ if (dead.length) out.push({ task_id: t.id, status: t.status, title: t.title, prose_dead_deps: dead.sort((a, b) => Number(a.id) - Number(b.id)) });
336
+ }
337
+ return out;
338
+ }
339
+
201
340
  module.exports = {
202
341
  DEAD_DEP_STATUSES, LIVE_STATUSES,
203
342
  absorbedInto, depRefusalRow, splitDeadDeps, deadDepHint, findStrandedTasks,
343
+ proseGatedIds, findProseGatedTasks, idCandidates, GATE_PHRASE_RE, GATE_WINDOW, OTHER_ENTITY_RE,
344
+ LIVENESS_BEFORE_RE, LIVENESS_AFTER_RE, IMPORT_ID_OFFSETS,
204
345
  };
package/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@bongos/core",
3
- "version": "1.19.821",
3
+ "version": "1.19.822",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@bongos/core",
9
- "version": "1.19.821",
9
+ "version": "1.19.822",
10
10
  "license": "AGPL-3.0-or-later",
11
11
  "dependencies": {
12
12
  "express": "^4.21.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bongos/core",
3
- "version": "1.19.821",
3
+ "version": "1.19.822",
4
4
  "description": "Cloud Bongos — the AI-first build platform core (GDS + platform surfaces + module system), installed as a versioned dependency (ADR 0108).",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "main": "src/platform-server.js",
@@ -17,14 +17,15 @@
17
17
  // gate's notion of "overlap".
18
18
  //
19
19
  // node scripts/gds/audit-deps.js [--version GDS-V3] [--min high|medium|low] [--json]
20
- // node scripts/gds/audit-deps.js --stranded [--json] # the INVERSE: dead edges (task 1003153)
20
+ // node scripts/gds/audit-deps.js --stranded [--json] # the INVERSE: dead edges (task 1003153),
21
+ // # plus prose-declared gates naming a dead task (task 1003857, advisory)
21
22
 
22
23
  const { touchesOverlap } = require('../../src/bongos/path-match.js');
23
24
  const { cliClient } = require('./cli-lib');
24
25
  const { resolveDefaultVersion } = require('./version-select.js');
25
26
  // task 1003153 — the DEAD-edge detector core, shared with the claim refusal so
26
27
  // "abandoned dependency" means one thing across the CLI, the route and this audit.
27
- const { findStrandedTasks } = require('../../modules/lifecycle/dead-deps.js');
28
+ const { findStrandedTasks, findProseGatedTasks } = require('../../modules/lifecycle/dead-deps.js');
28
29
  // task 1003752 — the route's page bound + the first-page offset rule, declared once.
29
30
  const { TASK_LIST_MAX_LIMIT, buildTaskPageQuery } = require('../../modules/lifecycle/task-list-limits.js');
30
31
 
@@ -129,6 +130,16 @@ async function reportStranded({ asJson }) {
129
130
  process.exit(1);
130
131
  }
131
132
  const stranded = findStrandedTasks(all);
133
+ // task 1003857: the same question asked of PROSE. The structured graph above
134
+ // reads blocked_by edges; a gate written in a description is unpoliced, and stales
135
+ // identically — task 1002839 told a builder to coordinate with "existing open task
136
+ // 1001380", abandoned since 2026-08-18. Reported HERE rather than in a second tool
137
+ // so there is one answer to "what is stranded".
138
+ const statusById = (() => {
139
+ const byId = new Map(all.map((t) => [String(t.id), String(t.status)]));
140
+ return (id) => byId.get(String(id)) || null;
141
+ })();
142
+ const proseGated = findProseGatedTasks(all, statusById);
132
143
 
133
144
  // Context worth stating even at zero: abandoned tasks that still CARRY
134
145
  // dependents are the latent trap. They report clean only because every
@@ -139,7 +150,10 @@ async function reportStranded({ asJson }) {
139
150
  }
140
151
 
141
152
  if (asJson) {
142
- console.log(JSON.stringify({ stranded, abandoned_deps_with_dependents: [...gatingAbandoned] }, null, 2));
153
+ console.log(JSON.stringify({ stranded, prose_gated: proseGated, abandoned_deps_with_dependents: [...gatingAbandoned] }, null, 2));
154
+ // ADVISORY: a prose match never changes the exit code. It is weaker evidence than
155
+ // an edge — the text may be history, a citation, or simply wrong — so it reports
156
+ // candidates for a human and must not gate a sweep or a CI leg.
143
157
  return stranded.length ? 1 : 0;
144
158
  }
145
159
  console.log(`audit-deps --stranded: ${all.length} task(s) scanned — ${stranded.length} LIVE task(s) stranded by an abandoned dependency\n`);
@@ -149,6 +163,14 @@ async function reportStranded({ asJson }) {
149
163
  console.log(` fix: drop the edge (DELETE /dependencies {"from_kind":"task","from_id":${s.task_id},"to_kind":"task","to_id":${s.dead_deps[0].id}})`);
150
164
  console.log(` or restore the dep (POST /tasks/${s.dead_deps[0].id}/promote)\n`);
151
165
  }
166
+ if (proseGated.length) {
167
+ console.log(`Prose-declared gates naming a dead task: ${proseGated.length} (ADVISORY — a human reads these; they never gate a claim)\n`);
168
+ for (const p of proseGated) {
169
+ console.log(`[PROSE] #${p.task_id} [${p.status}] ${(p.title || '').slice(0, 70)}`);
170
+ for (const d of p.prose_dead_deps) console.log(` body names → #${d.id} [${d.status}]`);
171
+ console.log(' fix: correct the sentence (PATCH /tasks/' + p.task_id + ' {"description":…}), or promote the named task if the gate is real\n');
172
+ }
173
+ }
152
174
  if (!stranded.length) {
153
175
  console.log('Nothing stranded — no live task is gated by an abandoned dependency.');
154
176
  console.log(`Latent exposure: ${gatingAbandoned.size} abandoned task(s) still carry dependents; they read clean only`);
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.821'; // CI auto-patch carrier (ADR 0161); changelog: docs/module-api-changelog.md
74
+ const CORE_VERSION = '1.19.822'; // 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');
@@ -0,0 +1,139 @@
1
+ // tests/prose_gated_deps.mjs — a gate written in a task's DESCRIPTION goes stale the
2
+ // same way an edge does, and nothing was watching (task 1003857).
3
+ //
4
+ // The structured detector (task 1003153) reads blocked_by edges and never touches a
5
+ // description. Task 1002839 sat at `ready` telling a builder to coordinate with
6
+ // "existing open task 1001380" — abandoned since 2026-08-18, superseded by ADR 0089.
7
+ //
8
+ // EVERY REGEX HERE WAS SIZED BY MEASUREMENT, not by reading the spec, and the cases
9
+ // below are the measurements. The first cut over the live board (3,647 tasks) returned
10
+ // two hits and BOTH taught something: one was an `idea` id wearing a task-shaped
11
+ // number, and the true positive only matched because a verb leaked across a semicolon.
12
+ // Tightening that correctly dropped the true positive too — which is how the liveness
13
+ // phrasing was found, because the real sentence is not a dependency at all.
14
+
15
+ import { test } from 'node:test';
16
+ import assert from 'node:assert/strict';
17
+ import { createRequire } from 'node:module';
18
+
19
+ const require = createRequire(import.meta.url);
20
+ const { proseGatedIds, findProseGatedTasks, idCandidates, LIVE_STATUSES } = require('../modules/lifecycle/dead-deps.js');
21
+
22
+ const ids = (t) => [...proseGatedIds(t)];
23
+
24
+ test('the LIVE sentence from task 1002839 is caught', () => {
25
+ // Verbatim. This is a liveness assertion, not a dependency — "existing open task N".
26
+ assert.deepEqual(
27
+ ids('this is a gate-review HARD FLOOR surface under ADR 0043 and needs owner approval even for an Archon; and existing open task 1001380 covers overlapping ground with stale touches[]'),
28
+ ['1001380'],
29
+ );
30
+ });
31
+
32
+ test('a liveness assertion AFTER the id is caught too', () => {
33
+ assert.deepEqual(ids('task 1001380 (Unify the grader: one multimodal engine) is ready to claim'), ['1001380']);
34
+ assert.deepEqual(ids('task 1001380 remains open'), ['1001380']);
35
+ });
36
+
37
+ test('an ordinary dependency phrasing is caught', () => {
38
+ assert.deepEqual(ids('needs task 1001380 to land first'), ['1001380']);
39
+ assert.deepEqual(ids('depends on #1001380'), ['1001380']);
40
+ assert.deepEqual(ids('blocked by 1001380'), ['1001380']);
41
+ });
42
+
43
+ test('an ANOTHER-ENTITY id is not a task gate', () => {
44
+ // Measured: 'Source: idea 1000454' was one of two hits on the first live run.
45
+ // Reporting it sends a human to look up a task that does not exist — the exact
46
+ // failure this detector exists to prevent.
47
+ assert.deepEqual(ids('the first thing that task needs. Source: idea 1000454'), []);
48
+ assert.deepEqual(ids('needs idea 1000454'), []);
49
+ assert.deepEqual(ids('blocked by blocker 1000082'), []);
50
+ assert.deepEqual(ids('after PR 1000454 lands'), []);
51
+ });
52
+
53
+ test('a gate verb does NOT reach across a sentence or clause boundary', () => {
54
+ // Measured: a fixed-width window let 'needs' govern an id in the next clause.
55
+ assert.deepEqual(ids('this needs owner approval; see 1001380 for history'), []);
56
+ assert.deepEqual(ids('this needs approval. Background in 1001380.'), []);
57
+ });
58
+
59
+ test('history and citation are not gates', () => {
60
+ assert.deepEqual(ids('this supersedes task 1001380'), []);
61
+ assert.deepEqual(ids('task 1001380 needs review'), [], 'the verb must govern the id, not follow it');
62
+ assert.deepEqual(ids('open questions remain; see 1001380'), []);
63
+ });
64
+
65
+ test('a bare number that is not a task id is ignored', () => {
66
+ assert.deepEqual(ids('needs the 2026 rollout and 4784 commits'), []);
67
+ });
68
+
69
+ // ---- OFFSET-AWARENESS (task 1003857) ---------------------------------------
70
+ //
71
+ // THE TRAP THE TASK NAMES, and which I walked straight into by reading only the first
72
+ // part of the description. Task 1000528's own gate is written as a bare PRE-OFFSET
73
+ // short-form ref (`#513`, `task 506`), not the live id — so a live-id-only matcher
74
+ // misses the very case that motivated the original row. The import shifted every id by
75
+ // 1,000,000; diagram-facts.js's IMPORT_ID_OFFSETS is the existing precedent for probing
76
+ // both spaces.
77
+
78
+ test('a SHORT pre-offset ref resolves to its live id', () => {
79
+ assert.deepEqual(ids('needs task 528 to land first'), ['1000528']);
80
+ assert.deepEqual(ids('blocked by #528'), ['1000528']);
81
+ });
82
+
83
+ test('a LIVE-width ref is NOT offset a second time', () => {
84
+ // 1001380 + 1e6 = 2001380, a row nobody ever wrote. Probing an already-resolved id
85
+ // invents a second candidate that the text does not say.
86
+ assert.deepEqual(ids('and existing open task 1001380 covers overlapping ground'), ['1001380']);
87
+ assert.deepEqual(idCandidates('1001380'), ['1001380']);
88
+ assert.deepEqual(idCandidates('528'), ['1000528']);
89
+ });
90
+
91
+ test('a short ref needs an explicit task/# prefix — a bare small number is not an id', () => {
92
+ // This runs over every description on the board, where a 3-digit number is a count, a
93
+ // line number or a year far more often than it is a task.
94
+ assert.deepEqual(ids('needs 3 more reviews'), []);
95
+ assert.deepEqual(ids('needs 528 lines changed'), []);
96
+ assert.deepEqual(ids('needs task 528'), ['1000528'], 'the prefix is what makes it a ref');
97
+ });
98
+
99
+ test('the offset probe still respects the gate/liveness rules', () => {
100
+ assert.deepEqual(ids('this supersedes task 528'), [], 'history is not a gate, at either width');
101
+ assert.deepEqual(ids('needs idea 454'), [], 'another entity is not a task, at either width');
102
+ assert.deepEqual(ids('existing open task 528 covers this'), ['1000528'], 'liveness works at short width too');
103
+ });
104
+
105
+ test('findProseGatedTasks reports only LIVE rows gated on a DEAD one', () => {
106
+ const statusById = (id) => ({ 1001380: 'abandoned', 1001381: 'shipped' })[id] || null;
107
+ const rows = [
108
+ { id: '1', status: 'ready', title: 'a', description: 'needs task 1001380' },
109
+ { id: '2', status: 'ready', title: 'b', description: 'needs task 1001381' }, // dep alive
110
+ { id: '3', status: 'shipped', title: 'c', description: 'needs task 1001380' }, // row not live
111
+ ];
112
+ const out = findProseGatedTasks(rows, statusById);
113
+ assert.equal(out.length, 1);
114
+ assert.equal(out[0].task_id, '1');
115
+ assert.deepEqual(out[0].prose_dead_deps, [{ id: '1001380', status: 'abandoned' }]);
116
+ });
117
+
118
+ test('a task citing ITSELF is not gated on itself', () => {
119
+ const out = findProseGatedTasks(
120
+ [{ id: '1001380', status: 'ready', title: 'x', description: 'needs task 1001380' }],
121
+ () => 'abandoned',
122
+ );
123
+ assert.deepEqual(out, []);
124
+ });
125
+
126
+ test('an unknown id is not reported — absence of a row is not death', () => {
127
+ const out = findProseGatedTasks(
128
+ [{ id: '1', status: 'ready', title: 'x', description: 'needs task 1009999' }],
129
+ () => null,
130
+ );
131
+ assert.deepEqual(out, [], 'a task the caller cannot see may simply be outside the page it fetched');
132
+ });
133
+
134
+ test('LIVE_STATUSES is the shared notion, not a second copy', () => {
135
+ // If this detector grew its own status set, the two halves of --stranded would
136
+ // disagree about what "live" means and nobody would notice.
137
+ assert.ok(LIVE_STATUSES.has('ready') && LIVE_STATUSES.has('backlog'));
138
+ assert.ok(!LIVE_STATUSES.has('shipped') && !LIVE_STATUSES.has('abandoned'));
139
+ });