Public: anyone can read this; the crew can change it.
Sentinel: shared:01m23vygyffx5hg2f5vm8r74sr:13ovxm2u7m is past its budget: trevato/forge: "every instruction names a script or a tool that exists" failed on 7 pulls in the last hour — the lane's… #13188
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13172-sentinel-shared-01m23vygyffx5hg2f5vm8r74 → main 5 commits fork 1 thread · 1 unresolved
2 files
changed +45
−14
test/deadends.test.ts +17 −7
| @@ -48,6 +48,7 @@ import { | ||
| 48 | 48 | type World, |
| 49 | 49 | } from "./support/deadends.ts"; |
| 50 | 50 | import { runJob, type DeadendsDone, type DeadendsJob } from "./support/deadends-worker.ts"; |
| 51 | import { toolMentions } from "./support/deadends-words.ts"; | |
| 51 | 52 | |
| 52 | 53 | quietLogs(); |
| 53 | 54 | |
| @@ -87,11 +88,13 @@ const keyOfProblem = (p: Problem): string => | ||
| 87 | 88 | * removed the day it is fixed: the test says so when it no longer happens. |
| 88 | 89 | */ |
| 89 | 90 | const KNOWN: ReadonlySet<string> = new Set<string>([ |
| 90 | // Product decision: a signed-in person who opens /signin is shown the form and its doors (sign-up, "start your own forge"), which are no use to them. | |
| 91 | // Product decision: a signed-in person who opens /signin is shown the form and its doors | |
| 92 | // (sign-up, "start your own forge"), which are no use to them. | |
| 91 | 93 | "wall /signin -> /signup (sign-in wall via /signup for a signed-in viewer)", |
| 92 | 94 | "wall /signin -> /signup (403 for a signed-in viewer)", |
| 93 | 95 | "anchor /signin -> /#yours", |
| 94 | // Product decision: the emailed recovery link is the only way back, and carries no return address; the form that asks for it cannot either. | |
| 96 | // Product decision: the emailed recovery link is the only way back, and carries no return | |
| 97 | // address; the form that asks for it cannot either. | |
| 95 | 98 | 'return-address /recover form "form" -> /recover drops the return address', |
| 96 | 99 | "return-address /recover form /recover drops the return address", |
| 97 | 100 | ]); |
| @@ -103,7 +106,8 @@ const noted = (key: string, where: string) => { | ||
| 103 | 106 | |
| 104 | 107 | function judgeCrawl(seed: number, findings: readonly Finding[]): void { |
| 105 | 108 | for (const f of findings) { |
| 106 | // An entry the viewer is not meant to open (a private repository, a page for another role) is not a link. | |
| 109 | // An entry the viewer is not meant to open (a private repository, a page for another role) is | |
| 110 | // not a link. | |
| 107 | 111 | if (f.from === "(entry)") continue; |
| 108 | 112 | noted( |
| 109 | 113 | keyOfFinding(f), |
| @@ -231,12 +235,12 @@ test("the findings are the known ones, and every known one still happens", async | ||
| 231 | 235 | if (!LONG) expect([...KNOWN].filter((k) => !seen.has(k))).toEqual([]); |
| 232 | 236 | }, 300_000); |
| 233 | 237 | |
| 234 | /** Instruction strings that name a thing that is not there, as found; each is a sentence to fix or a false reading to teach the scan. */ | |
| 238 | /** | |
| 239 | * Instruction strings that name a thing that is not there, as found; each is a sentence to fix or a | |
| 240 | * false reading to teach the scan. | |
| 241 | */ | |
| 235 | 242 | // Named by file, not line: an edit above them elsewhere in the file must not turn this red. |
| 236 | 243 | const KNOWN_WORDS: readonly string[] = [ |
| 237 | // The scan reads "the MCP tool spawn" and "the one tool open without a token" as a tool called "the" and "one". | |
| 238 | "tool the at src/core/roles.ts", | |
| 239 | "tool one at src/http/mcp.ts", | |
| 240 | 244 | // Dead: a preview's sample app runs a file its repository does not hold. |
| 241 | 245 | "script src/server.ts at src/spawn/preview-seed.ts", |
| 242 | 246 | ]; |
| @@ -247,3 +251,9 @@ test("every instruction names a script or a tool that exists", () => { | ||
| 247 | 251 | .map((r) => `${r.kind} ${r.target} at ${r.at}`); |
| 248 | 252 | expect(dead.filter((d) => !KNOWN_WORDS.includes(d.replace(/:\d+$/, "")))).toEqual([]); |
| 249 | 253 | }); |
| 254 | ||
| 255 | test("a sentence that says 'this tool' names no tool at all", () => { | |
| 256 | expect(toolMentions("use this tool to open it")).toEqual([]); | |
| 257 | expect(toolMentions("the one tool open without a token")).toEqual([]); | |
| 258 | expect(toolMentions("call the `report` tool")).toEqual(["report"]); | |
| 259 | }); |
test/support/deadends-words.ts +28 −7
| @@ -40,7 +40,10 @@ function walk(dir: string, out: string[] = []): string[] { | ||
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** Words that make a sentence an instruction to a person or an agent. */ |
| 43 | /** The quoted and template segments of one line, found by a scan (a regex over a long line backtracks for minutes). */ | |
| 43 | /** | |
| 44 | * The quoted and template segments of one line, found by a scan (a regex over a long line | |
| 45 | * backtracks for minutes). | |
| 46 | */ | |
| 44 | 47 | function literals(line: string): string[] { |
| 45 | 48 | if (line.length > 700) return []; |
| 46 | 49 | const out: string[] = []; |
| @@ -75,14 +78,35 @@ function routeExists(path: string): boolean { | ||
| 75 | 78 | ) |
| 76 | 79 | return true; |
| 77 | 80 | } |
| 78 | // A path under a literal folder the forge serves from disk (`/assets/`, `/docs/`, `/.well-known/`) or a repo path that names a user's own repository. | |
| 81 | // A path under a literal folder the forge serves from disk (`/assets/`, `/docs/`, | |
| 82 | // `/.well-known/`) or a repo path that names a user's own repository. | |
| 79 | 83 | return false; |
| 80 | 84 | } |
| 81 | 85 | |
| 82 | 86 | const HEADS = new Set([...pageRouter.literalHeads(), ...apiRouter.literalHeads(), "forges", "settings", "admin"]); |
| 83 | 87 | const KNOWN_PREFIX = /^\/(?:assets|\.well-known|docs|git|mcp|_plat|-)\b/; |
| 84 | 88 | |
| 85 | /** Scan every source file under `src/` for instruction-shaped strings and resolve what they name. */ | |
| 89 | /** | |
| 90 | * Words a sentence puts before "tool" that are not a tool's name ("use this tool", "the one | |
| 91 | * tool"). | |
| 92 | */ | |
| 93 | const NOT_A_TOOL = new Set(["this", "that", "the", "one", "any", "each", "every", "its", "your", "same", "other", "new", "mcp", "which", "whose"]); | |
| 94 | ||
| 95 | /** | |
| 96 | * The tool names one sentence points at: "the `report` tool", "use start tool"; never "use this | |
| 97 | * tool". | |
| 98 | */ | |
| 99 | export function toolMentions(text: string): string[] { | |
| 100 | const out: string[] = []; | |
| 101 | for (const m of text.matchAll(/\b(?:the |use |call |with )`?([a-z][a-z_]{2,30})`? (?:tool|MCP tool)\b/g)) { | |
| 102 | if (!NOT_A_TOOL.has(m[1]!)) out.push(m[1]!); | |
| 103 | } | |
| 104 | return out; | |
| 105 | } | |
| 106 | ||
| 107 | /** | |
| 108 | * Scan every source file under `src/` for instruction-shaped strings and resolve what they name. | |
| 109 | */ | |
| 86 | 110 | export function instructions(): Instruction[] { |
| 87 | 111 | const out: Instruction[] = []; |
| 88 | 112 | for (const file of walk(join(ROOT, "src"))) { |
| @@ -120,10 +144,7 @@ export function instructions(): Instruction[] { | ||
| 120 | 144 | status: existsSync(join(ROOT, target)) ? "ok" : "dead", |
| 121 | 145 | }); |
| 122 | 146 | } |
| 123 | for (const m of text.matchAll( | |
| 124 | /\b(?:the |use |call |with )`?([a-z][a-z_]{2,30})`? (?:tool|MCP tool)\b/g, | |
| 125 | )) { | |
| 126 | const target = m[1]!; | |
| 147 | for (const target of toolMentions(text)) { | |
| 127 | 148 | out.push({ |
| 128 | 149 | at, |
| 129 | 150 | text: text.slice(0, 120), |
new above
offline
Dead now: toolMentions filters "the" and "one", so these two entries ("tool the at src/core/roles.ts", "tool one at src/http/mcp.ts") can never match. Delete them and the comment above them. Keep only the entry for the dead sample app. Also add a toolMentions assertion for "the one tool" so the removal is covered.