@inerrata-corporation/errata 2.0.22-dev.4135 → 2.0.22-dev.4148

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/errata.mjs CHANGED
@@ -18205,6 +18205,603 @@ var init_sqlite_adapter = __esm({
18205
18205
  }
18206
18206
  });
18207
18207
 
18208
+ // ../../packages/local-shared/src/tag-grammar.ts
18209
+ function tagGrammarCopy() {
18210
+ const copy = [];
18211
+ for (const ref of ["its-handle", "its-id", "h", "id"]) {
18212
+ for (const build of Object.values(TAG_EXAMPLES)) copy.push(build(ref));
18213
+ }
18214
+ for (const v of TAG_VERBS) {
18215
+ copy.push(v.hint);
18216
+ if (v.taughtBy) copy.push(v.taughtBy);
18217
+ for (const q of v.qualifiers ?? []) copy.push(q.note);
18218
+ for (const l of v.lowering) {
18219
+ if (l.note) copy.push(l.note);
18220
+ if (l.knownViolation) copy.push(l.knownViolation.finding);
18221
+ }
18222
+ }
18223
+ for (const f of TAG_FENCES) copy.push(f.hint);
18224
+ return copy;
18225
+ }
18226
+ function normalizeTemplateBody(body2) {
18227
+ return body2.replace(/…|\.{3}/g, " ").replace(/\s+/g, " ").trim().replace(/^[\s,;:—–-]+|[\s,;:.—–-]+$/g, "").toLowerCase();
18228
+ }
18229
+ function deriveTagTemplates(copy) {
18230
+ const bodies = /* @__PURE__ */ new Set();
18231
+ const handles = new Set([...TAG_PLACEHOLDER_HANDLES].map((h) => h.toLowerCase()));
18232
+ for (const text of copy) {
18233
+ for (const m of text.matchAll(BRACKET_TOKEN)) {
18234
+ const token = m[1].trim().toLowerCase();
18235
+ if (!/^[!?]/.test(token) && !REAL_HANDLE_SHAPE.test(token)) handles.add(token);
18236
+ }
18237
+ }
18238
+ for (const text of copy) {
18239
+ for (const m of text.matchAll(TEMPLATE_VERB_GROUP)) {
18240
+ const body2 = normalizeTemplateBody(m[2]);
18241
+ bodies.add(body2);
18242
+ const unthreaded = normalizeTemplateBody(body2.replace(/^#[a-z][\w-]*/i, ""));
18243
+ bodies.add(unthreaded);
18244
+ const rest2 = normalizeTemplateBody(unthreaded.replace(BRACKET_TOKEN, (t, h) => handles.has(h.trim().toLowerCase()) ? " " : t).replace(/,/g, " "));
18245
+ bodies.add(rest2);
18246
+ }
18247
+ }
18248
+ bodies.delete("");
18249
+ return { bodies, handles };
18250
+ }
18251
+ function isTemplateSegment(verb, text, templates) {
18252
+ const t = normalizeTemplateBody(text);
18253
+ if (t === "" || templates.bodies.has(t)) return true;
18254
+ const unthreaded = normalizeTemplateBody(t.replace(/^#[a-z][\w-]*/i, ""));
18255
+ if (unthreaded === "" || templates.bodies.has(unthreaded)) return true;
18256
+ let real = false;
18257
+ let standIn = false;
18258
+ const rest2 = unthreaded.replace(BRACKET_TOKEN, (token, inner) => {
18259
+ const h = inner.trim().toLowerCase();
18260
+ if (/^[!?]/.test(h)) return token;
18261
+ if (templates.handles.has(h) || /…|\.{3}/.test(h) || !REAL_HANDLE_SHAPE.test(h)) standIn = true;
18262
+ else real = true;
18263
+ return " ";
18264
+ });
18265
+ if (standIn || real) return true;
18266
+ const words = normalizeTemplateBody(rest2.replace(ANY_VERB_WORD, " ").replace(/,/g, " "));
18267
+ if (words === "" || templates.bodies.has(words)) return true;
18268
+ const spec = verb ? TAG_VERB_BY_NAME.get(verb) : void 0;
18269
+ if (!spec || spec.handleRequired) return true;
18270
+ return words.length < (spec.minText ?? 2);
18271
+ }
18272
+ function isTemplateTagBody(verb, body2, templates = TAG_TEMPLATES) {
18273
+ const whole = normalizeTemplateBody(body2);
18274
+ if (whole === "" || templates.bodies.has(whole)) return true;
18275
+ const segments = body2.split(JOINED_VERB);
18276
+ return segments.every((seg, i2) => {
18277
+ const lead2 = i2 === 0 ? null : LEADING_VERB.exec(seg);
18278
+ return isTemplateSegment(lead2 ? lead2[1].toLowerCase() : verb, lead2 ? seg.slice(lead2[0].length) : seg, templates);
18279
+ });
18280
+ }
18281
+ function quotesOnlyTemplateTags(span, templates = TAG_TEMPLATES) {
18282
+ let found = false;
18283
+ for (const m of span.matchAll(QUOTED_TAG_OPENER)) {
18284
+ found = true;
18285
+ if (m.index > 0 && /[\w$.\])]/.test(span[m.index - 1])) continue;
18286
+ const bodyStart = m.index + m[0].length;
18287
+ let depth = 1;
18288
+ let close = -1;
18289
+ for (let i2 = bodyStart; i2 < span.length; i2++) {
18290
+ if (span[i2] === "(") depth++;
18291
+ else if (span[i2] === ")" && --depth === 0) {
18292
+ close = i2;
18293
+ break;
18294
+ }
18295
+ }
18296
+ if (close < 0) continue;
18297
+ if (!isTemplateTagBody(m[1]?.toLowerCase() ?? null, span.slice(bodyStart, close), templates)) return false;
18298
+ }
18299
+ return found;
18300
+ }
18301
+ var TAG_CANONICAL_ID_PREFIXES, TAG_HANDLE_SOURCE, TAG_THREAD_SOURCE, TAG_PLACEHOLDER_HANDLES, TAG_EXAMPLES, P, S, RC, CITE_LOWERING, INSTANCE_LOWERING, TRIAGE_TO_RC, TAG_VERBS, TAG_FENCES, TAG_VERB_BY_NAME, TAG_PAREN_VERBS, TAG_GRAMMAR_OPENERS, TAG_QUOTED_PAREN_SOURCE, TAG_QUOTED_RE, TAG_QUOTED_PAREN_RE, TEMPLATE_VERB_GROUP, BRACKET_TOKEN, REAL_HANDLE_SHAPE, TAG_TEMPLATES, VERB_WORDS_SOURCE, JOINED_VERB, LEADING_VERB, ANY_VERB_WORD, QUOTED_TAG_OPENER, TAG_VERDICT_TOKENS;
18302
+ var init_tag_grammar = __esm({
18303
+ "../../packages/local-shared/src/tag-grammar.ts"() {
18304
+ "use strict";
18305
+ TAG_CANONICAL_ID_PREFIXES = ["pat", "sol", "drc", "dcause", "dfix", "dprob", "dvuln", "prob", "claim", "err"];
18306
+ TAG_HANDLE_SOURCE = String.raw`\[([a-z0-9][\w-]{0,80})\]|((?:${TAG_CANONICAL_ID_PREFIXES.join("|")})_[0-9a-f]{6,})`;
18307
+ TAG_THREAD_SOURCE = String.raw`#([a-z][\w-]{0,63})`;
18308
+ TAG_PLACEHOLDER_HANDLES = /* @__PURE__ */ new Set([
18309
+ "handle",
18310
+ "its-handle",
18311
+ "another",
18312
+ "a-third",
18313
+ "h",
18314
+ "h1",
18315
+ "h2",
18316
+ "id",
18317
+ "its-id",
18318
+ "a",
18319
+ "b",
18320
+ "\u2026",
18321
+ "..."
18322
+ ]);
18323
+ TAG_EXAMPLES = {
18324
+ prior: (ref) => `([${ref}])`,
18325
+ problem: () => `[!one line on what's wrong]`,
18326
+ vulnerability: () => `[!vuln: who can do what; observed basis @ path:line]`,
18327
+ suspectedVulnerability: () => `[?vuln: consequence; missing check]`,
18328
+ vulnerabilityThread: () => `[!#v vuln: finding here]`,
18329
+ fix: (ref) => `(fix:[${ref}])`,
18330
+ // CONSTRAINT — the native capture path for a DIFFUSE problem (a constraint/tension/
18331
+ // conflict that shaped a decision). Free text, attaches to the decision sentence the
18332
+ // agent is already writing. Full rationale in the constraint note below + prior-tags.ts.
18333
+ constraint: () => `(constraint: the limitation that forced it)`,
18334
+ // TRIAGE — routes the problem/symptom in scope to its cause. `(cause:[handle])`
18335
+ // links to a cited RootCause/Solution node; `(cause: free text)` mints a RootCause
18336
+ // from the text. Harvested in prior-tags.ts → engine.ts (see the triage note below).
18337
+ triage: (ref) => `(cause:[${ref}])`,
18338
+ // Unlike a bare cause citation, this handle names the Problem being explained.
18339
+ triageExplain: (ref) => `(cause:[${ref}] the mechanism)`,
18340
+ // The MINT form — free-text cause that mints a RootCause. Prime-time surfacing
18341
+ // (recallForFile) pastes this next to an open Problem that has no cause yet, so the
18342
+ // diagnostic moment is cued when the agent is looking at the problem. Kept here so
18343
+ // the grammar can't drift from parseInlineTags' `(cause: …)` acceptance.
18344
+ triageMint: () => `(cause: why it happens)`,
18345
+ // THREAD forms — the witness-declared symptom↔cause/fix binding. A `#id` on the
18346
+ // flag names the diagnosis thread; the same `#id` on a later verb binds to it
18347
+ // explicitly (across sentences AND turns), replacing proximity guessing. Adjacent
18348
+ // tags never need one — the id is for diagnoses that unfold over distance.
18349
+ problemThread: () => `[!#slug one line on what's wrong]`,
18350
+ causeThread: () => `(cause:#slug the mechanism)`,
18351
+ fixThread: (thread = "slug") => `(fix:#${thread} what you changed)`,
18352
+ // ATTEMPT arc — what's being tried and what didn't work. A failed attempt is a
18353
+ // witnessed NEGATIVE result: it saves the next agent the same dead end.
18354
+ tried: () => `(tried: the approach you're attempting)`,
18355
+ failed: () => `(failed: what didn't work and the dead end it rules out)`,
18356
+ // `(failed:[h] …)` on a shown SOLUTION — the refute-by-failure form the context render teaches.
18357
+ failedCite: (ref) => `(failed:[${ref}] what came back)`,
18358
+ // LINK verbs (AC epic) — bind the problem in scope to CANONICAL priors and
18359
+ // abstractions. Multi-target by design: single links are weak; ~3 links to 3
18360
+ // DIFFERENT relevant priors is the target shape (see linkBullet).
18361
+ instance: (ref) => `(instance:[${ref}],[another],[a-third])`,
18362
+ pattern: () => `(pattern: name the general shape)`,
18363
+ // DOMAIN — the abstract area a problem is about; the concept layer an
18364
+ // anchor-less problem clusters on. Mints/resolves a Domain by name.
18365
+ domain: () => `(domain: The Area)`,
18366
+ // PACKAGE/COMPONENT — agent-named public anchors (OM-agent-anchors): the
18367
+ // package a problem is ABOUT (even when not a dependency) and the
18368
+ // framework/product-level unit it concerns. Public spine anchors → the
18369
+ // knowledge can cross to the collective.
18370
+ package: () => `(package: the-package-name)`,
18371
+ component: () => `(component: The Component)`,
18372
+ aids: (ref) => `(aids:[${ref}])`,
18373
+ // SOLUTION-STRUCTURE (SS-structure) — taught in the link bullet; Solution→Solution.
18374
+ buildsOn: (ref) => `(builds-on:[${ref}])`,
18375
+ supersedes: (ref) => `(supersedes:[${ref}])`,
18376
+ alternative: (ref) => `(alternative:[${ref}])`,
18377
+ // VERDICT (VS-verdict-tags) — a judgment on a SHOWN prior, distinct from leaning on it.
18378
+ // `confirm` rides the corroborate channel (it held); `refute` the contradict channel
18379
+ // (it's wrong / didn't hold) and REQUIRES a reason. This is the inline producer the
18380
+ // evidence channels lacked — refute sat dead (contradictionPressure 0) until now, while
18381
+ // lean-on corroboration lived, because only corroboration had an inline path. Grammar
18382
+ // single-sourced with parseInlineTags' CONFIRM_PREFIX/REFUTE_PREFIX.
18383
+ confirm: (ref) => `(confirm:[${ref}])`,
18384
+ refute: (ref) => `(refute:[${ref}] one line why)`,
18385
+ // RETRACT — "not a real problem": the errata-resolved block with a disposition
18386
+ // (parseDesignResolutions, turn.ts). No inline form exists; the block is the grammar.
18387
+ retract: (id) => ["```errata-resolved", `id: ${id}`, "disposition: false_positive", "reason: why it was never a real problem", "```"].join("\n")
18388
+ };
18389
+ P = "Problem";
18390
+ S = "Solution";
18391
+ RC = "RootCause";
18392
+ CITE_LOWERING = [
18393
+ { target: RC, writes: [{ from: P, edge: "CAUSED_BY", to: RC }] },
18394
+ { target: S, writes: [{ from: P, edge: "SOLVED_BY", to: S }] },
18395
+ { target: "Pattern", writes: [{ from: P, edge: "INSTANCE_OF", to: "Pattern" }, { from: "Pattern", edge: "ANCHORED_AT", to: "File" }], note: "cite-anchor promotion after 2 sessions", decision: "d", knownViolation: { edge: "ANCHORED_AT", finding: "motif cite-anchor promotion writes a refused ANCHORED_AT" } },
18396
+ { target: "Package", writes: [{ from: P, edge: "DEPENDS_ON", to: "Package" }] },
18397
+ { target: "Language", writes: [{ from: P, edge: "OCCURS_IN", to: "Language" }] },
18398
+ { target: "Tool", writes: [{ from: P, edge: "CONCERNS", to: "Tool" }] },
18399
+ { target: "Component", writes: [{ from: P, edge: "CONCERNS", to: "Component" }] },
18400
+ { target: P, writes: [{ from: P, edge: "RELATES_TO", to: P }, { from: P, edge: "ANCHORED_AT", to: "File" }], note: "corroboration witness + cite-anchor promotion" },
18401
+ { target: "AntiPattern", writes: [{ from: P, edge: "RELATES_TO", to: "AntiPattern" }, { from: "AntiPattern", edge: "ANCHORED_AT", to: "File" }], decision: "e", knownViolation: { edge: "ANCHORED_AT", finding: "motif cite-anchor promotion writes a refused ANCHORED_AT" } },
18402
+ { target: "Technique", writes: [{ from: P, edge: "RELATES_TO", to: "Technique" }, { from: "Technique", edge: "ANCHORED_AT", to: "File" }], decision: "e", knownViolation: { edge: "ANCHORED_AT", finding: "motif cite-anchor promotion writes a refused ANCHORED_AT" } },
18403
+ { target: "Weakness", writes: [{ from: P, edge: "RELATES_TO", to: "Weakness" }], decision: "e" },
18404
+ { target: "Domain", writes: [{ from: P, edge: "RELATES_TO", to: "Domain" }], decision: "e" },
18405
+ { target: "Claim", writes: [{ from: P, edge: "RELATES_TO", to: "Claim" }, { from: "Claim", edge: "ANCHORED_AT", to: "File" }] }
18406
+ ];
18407
+ INSTANCE_LOWERING = [
18408
+ { target: "Pattern", writes: [{ from: P, edge: "INSTANCE_OF", to: "Pattern" }] },
18409
+ { target: P, writes: [{ from: P, edge: "RELATES_TO", to: P }] },
18410
+ { target: S, writes: [{ from: P, edge: "SOLVED_BY", to: S }], note: "an instance cite on a Solution claims the problem is solved by it", decision: "a" },
18411
+ { target: RC, writes: [{ from: P, edge: "CAUSED_BY", to: RC }] },
18412
+ { target: "AntiPattern", writes: [{ from: P, edge: "RELATES_TO", to: "AntiPattern" }], decision: "e" },
18413
+ { target: "Technique", writes: [{ from: P, edge: "RELATES_TO", to: "Technique" }], decision: "e" },
18414
+ { target: "Weakness", writes: [{ from: P, edge: "RELATES_TO", to: "Weakness" }], decision: "e" },
18415
+ { target: "Domain", writes: [{ from: P, edge: "RELATES_TO", to: "Domain" }], decision: "e" },
18416
+ { target: "Package", writes: [{ from: P, edge: "DEPENDS_ON", to: "Package" }] },
18417
+ { target: "Component", writes: [{ from: P, edge: "CONCERNS", to: "Component" }] }
18418
+ ];
18419
+ TRIAGE_TO_RC = [
18420
+ { from: P, edge: "TRIAGED_BY", to: "Triage" },
18421
+ { from: "Triage", edge: "INDICATES", to: RC },
18422
+ { from: P, edge: "CAUSED_BY", to: RC }
18423
+ ];
18424
+ TAG_VERBS = [
18425
+ {
18426
+ verb: "cite",
18427
+ form: "citation",
18428
+ opener: "(",
18429
+ kinds: ["prior"],
18430
+ args: "handles",
18431
+ thread: false,
18432
+ handleRequired: true,
18433
+ lowering: CITE_LOWERING,
18434
+ examples: ["prior"],
18435
+ hint: "cite a shown prior you leaned on: ([its-handle]) \u2014 handles only, no prose inside the parens",
18436
+ taught: "taught"
18437
+ },
18438
+ {
18439
+ verb: "!",
18440
+ form: "flag",
18441
+ opener: "[!",
18442
+ kinds: ["problem", "triage", "vulnerability", "fix", "prior"],
18443
+ args: "flag-body",
18444
+ thread: true,
18445
+ minText: 8,
18446
+ qualifiers: [
18447
+ { name: "vuln", taught: true, note: "[!vuln: \u2026] \u2192 Vulnerability (asserted)" },
18448
+ { name: "fixed", taught: false, note: "[!fixed: X] \u2192 read as a self-found fix" },
18449
+ { name: "resolved", taught: false, note: "[!resolved: X] \u2192 read as a self-found fix" }
18450
+ ],
18451
+ lowering: [
18452
+ { target: P, writes: [], note: "mints a Problem; `@ path[:line]` anchors it (ANCHORED_AT to code)" },
18453
+ { target: RC, writes: [...TRIAGE_TO_RC, { from: RC, edge: "CAUSED_BY", to: RC }], note: "`<-` segments: first \u2192 triage route, later \u2192 RootCause chain" },
18454
+ { target: "Vulnerability", writes: [], note: "[!vuln: \u2026]; `<-` causes stay on the finding (vulnerabilityCauses)" }
18455
+ ],
18456
+ examples: ["problem", "problemThread", "vulnerability", "vulnerabilityThread"],
18457
+ hint: "flag a problem on one line: [!what's wrong @ path:42]; fold causes with <- ; a fix goes in (fix: \u2026), not [!fixed: \u2026]",
18458
+ taught: "taught"
18459
+ },
18460
+ {
18461
+ verb: "?",
18462
+ form: "flag",
18463
+ opener: "[?",
18464
+ kinds: ["todo", "vulnerability"],
18465
+ args: "flag-body",
18466
+ thread: true,
18467
+ minText: 8,
18468
+ qualifiers: [{ name: "vuln", taught: true, note: "[?vuln: \u2026] \u2192 Vulnerability (suspected)" }],
18469
+ lowering: [{ target: P, writes: [], note: "mints a todo Problem; a fix can close it today", decision: "g" }],
18470
+ examples: ["suspectedVulnerability"],
18471
+ hint: "[?\u2026] marks an open question / todo; [?vuln: consequence; missing check] a suspected vulnerability",
18472
+ taught: "untaught",
18473
+ taughtBy: "only the [?vuln:] form is taught; the bare [?todo] form is not",
18474
+ decisions: ["g"]
18475
+ },
18476
+ {
18477
+ verb: "fix",
18478
+ form: "verb",
18479
+ opener: "(fix:",
18480
+ kinds: ["fix"],
18481
+ args: "handles-text",
18482
+ thread: true,
18483
+ minText: 12,
18484
+ lowering: [
18485
+ { target: P, writes: [{ from: P, edge: "SOLVED_BY", to: S }], note: "closes the Problem; a note \u226512 chars mints the Solution" },
18486
+ { target: "Vulnerability", writes: [{ from: "Vulnerability", edge: "SOLVED_BY", to: S }] },
18487
+ { target: RC, writes: [], note: "dropped: 'fix tag went nowhere' (not a Problem); no tag writes FIXED_BY", decision: "f" }
18488
+ ],
18489
+ examples: ["fix", "fixThread"],
18490
+ hint: "one fix per tag: (fix:[its-handle]) or (fix:#thread what you changed) \u2014 put the cause in its own (cause: \u2026)",
18491
+ taught: "taught",
18492
+ decisions: ["f"]
18493
+ },
18494
+ {
18495
+ verb: "cause",
18496
+ form: "verb",
18497
+ opener: "(cause:",
18498
+ kinds: ["triage"],
18499
+ args: "handles-text",
18500
+ thread: true,
18501
+ minText: 8,
18502
+ lowering: [
18503
+ { target: RC, writes: TRIAGE_TO_RC },
18504
+ { target: P, writes: [{ from: P, edge: "TRIAGED_BY", to: "Triage" }, { from: "Triage", edge: "INDICATES", to: RC }, { from: P, edge: "CAUSED_BY", to: RC }], note: "(cause:[problem] mechanism) \u2014 the cited Problem is the symptom; the mechanism mints the RootCause" },
18505
+ { target: S, writes: [{ from: P, edge: "TRIAGED_BY", to: "Triage" }, { from: "Triage", edge: "INDICATES", to: S }], decision: "b", knownViolation: { edge: "INDICATES", finding: "(cause:[solution]) writes a refused INDICATES \u2192 Solution" } }
18506
+ ],
18507
+ examples: ["triage", "triageExplain", "triageMint", "causeThread"],
18508
+ hint: "(cause: the mechanism you'd change) or (cause:[root-cause-handle]); bind a distant symptom with (cause:#thread \u2026)",
18509
+ taught: "taught",
18510
+ decisions: ["b"]
18511
+ },
18512
+ {
18513
+ verb: "constraint",
18514
+ form: "verb",
18515
+ opener: "(constraint:",
18516
+ kinds: ["constraint"],
18517
+ args: "text",
18518
+ thread: false,
18519
+ minText: 8,
18520
+ textRequired: true,
18521
+ lowering: [{ target: P, writes: [], note: "mints a constraint-kind Problem" }],
18522
+ examples: ["constraint"],
18523
+ hint: "(constraint: the limitation that forced the decision)",
18524
+ taught: "taught"
18525
+ },
18526
+ {
18527
+ verb: "tried",
18528
+ form: "verb",
18529
+ opener: "(tried:",
18530
+ kinds: ["attempt"],
18531
+ args: "text",
18532
+ thread: true,
18533
+ minText: 8,
18534
+ textRequired: true,
18535
+ lowering: [{ target: P, writes: [], note: "journals an attempt on the bound problem" }],
18536
+ examples: ["tried"],
18537
+ hint: "(tried: the approach) \u2014 bind with (tried:#thread \u2026)",
18538
+ taught: "taught"
18539
+ },
18540
+ {
18541
+ verb: "failed",
18542
+ form: "verb",
18543
+ opener: "(failed:",
18544
+ kinds: ["failure"],
18545
+ args: "handles-text",
18546
+ thread: true,
18547
+ minText: 8,
18548
+ textRequired: true,
18549
+ lowering: [
18550
+ { target: P, writes: [], note: "journals a failed attempt on the bound problem" },
18551
+ { target: S, writes: [], note: "(failed:[h]) refutes the cited prior (contradictionPressure); skips the label gate today", decision: "j" }
18552
+ ],
18553
+ examples: ["failed", "failedCite"],
18554
+ hint: "(failed: what didn't work); (failed:[solution] what came back) refutes a shown fix",
18555
+ taught: "taught",
18556
+ decisions: ["j"]
18557
+ },
18558
+ {
18559
+ verb: "instance",
18560
+ form: "verb",
18561
+ opener: "(instance:",
18562
+ kinds: ["instance"],
18563
+ args: "handles",
18564
+ thread: false,
18565
+ handleRequired: true,
18566
+ lowering: INSTANCE_LOWERING,
18567
+ examples: ["instance"],
18568
+ hint: "(instance:[h1],[h2],[h3]) \u2014 ~3 DIFFERENT shown priors this problem instantiates; handles only",
18569
+ taught: "taught",
18570
+ decisions: ["a", "e"]
18571
+ },
18572
+ {
18573
+ verb: "pattern",
18574
+ form: "verb",
18575
+ opener: "(pattern:",
18576
+ kinds: ["pattern"],
18577
+ args: "handle-or-text",
18578
+ thread: false,
18579
+ minText: 3,
18580
+ lowering: [{ target: "Pattern", writes: [{ from: P, edge: "INSTANCE_OF", to: "Pattern" }], note: "a handle must be a Pattern; free text resolves-or-mints one" }],
18581
+ examples: ["pattern"],
18582
+ hint: "(pattern: name the general shape) or (pattern:[shown-pattern])",
18583
+ taught: "taught"
18584
+ },
18585
+ {
18586
+ verb: "domain",
18587
+ form: "verb",
18588
+ opener: "(domain:",
18589
+ kinds: ["domain"],
18590
+ args: "text",
18591
+ thread: false,
18592
+ minText: 2,
18593
+ textRequired: true,
18594
+ lowering: [{ target: "Domain", writes: [{ from: P, edge: "PERTAIN_TO", to: "Domain" }], note: '(domain:#t X) mints a Domain named "#t X" today', decision: "k" }],
18595
+ examples: ["domain"],
18596
+ hint: "(domain: The Area) \u2014 Title Case, no thread",
18597
+ taught: "taught",
18598
+ decisions: ["k"]
18599
+ },
18600
+ {
18601
+ verb: "package",
18602
+ form: "verb",
18603
+ opener: "(package:",
18604
+ kinds: ["package"],
18605
+ args: "text",
18606
+ thread: false,
18607
+ minText: 2,
18608
+ textRequired: true,
18609
+ lowering: [{ target: "Package", writes: [{ from: P, edge: "DEPENDS_ON", to: "Package" }], note: "means 'concerns', written as DEPENDS_ON", decision: "c" }],
18610
+ examples: ["package"],
18611
+ hint: "(package: the-package-name) \u2014 the public package it's about",
18612
+ taught: "taught",
18613
+ decisions: ["c"]
18614
+ },
18615
+ {
18616
+ verb: "component",
18617
+ form: "verb",
18618
+ opener: "(component:",
18619
+ kinds: ["component"],
18620
+ args: "text",
18621
+ thread: false,
18622
+ minText: 2,
18623
+ textRequired: true,
18624
+ lowering: [{ target: "Component", writes: [{ from: P, edge: "CONCERNS", to: "Component" }] }],
18625
+ examples: ["component"],
18626
+ hint: "(component: The Component) \u2014 the framework/product unit",
18627
+ taught: "taught"
18628
+ },
18629
+ {
18630
+ verb: "aids",
18631
+ form: "verb",
18632
+ opener: "(aids:",
18633
+ kinds: ["transfer"],
18634
+ args: "handles",
18635
+ thread: true,
18636
+ handleRequired: true,
18637
+ lowering: [{ target: P, writes: [{ from: S, edge: "MAY_RESOLVE", to: P }], note: "source = the Solution in scope; non-Problem targets are skipped" }],
18638
+ examples: ["aids"],
18639
+ hint: "(aids:[problem-handle],\u2026) \u2014 other shown problems your fix might also resolve",
18640
+ taught: "taught"
18641
+ },
18642
+ {
18643
+ verb: "builds-on",
18644
+ form: "verb",
18645
+ opener: "(builds-on:",
18646
+ kinds: ["builds-on"],
18647
+ args: "handles",
18648
+ thread: true,
18649
+ handleRequired: true,
18650
+ lowering: [{ target: S, writes: [{ from: S, edge: "BUILDS_ON", to: S }] }],
18651
+ examples: ["buildsOn"],
18652
+ hint: "(builds-on:[shown-solution]) \u2014 your fix layers on it",
18653
+ taught: "taught",
18654
+ taughtBy: "linkBullet instruction text"
18655
+ },
18656
+ {
18657
+ verb: "supersedes",
18658
+ form: "verb",
18659
+ opener: "(supersedes:",
18660
+ kinds: ["supersedes"],
18661
+ args: "handles",
18662
+ thread: true,
18663
+ handleRequired: true,
18664
+ lowering: [{ target: S, writes: [{ from: S, edge: "SUPERSEDES", to: S }] }],
18665
+ examples: ["supersedes"],
18666
+ hint: "(supersedes:[shown-solution]) \u2014 your fix replaces it",
18667
+ taught: "taught",
18668
+ taughtBy: "linkBullet instruction text"
18669
+ },
18670
+ {
18671
+ verb: "alternative",
18672
+ form: "verb",
18673
+ opener: "(alternative:",
18674
+ kinds: ["alternative"],
18675
+ args: "handles",
18676
+ thread: true,
18677
+ handleRequired: true,
18678
+ lowering: [{ target: S, writes: [{ from: S, edge: "ALTERNATIVE_TO", to: S }] }],
18679
+ examples: ["alternative"],
18680
+ hint: "(alternative:[shown-solution]) \u2014 a different valid approach",
18681
+ taught: "taught",
18682
+ taughtBy: "linkBullet instruction text"
18683
+ },
18684
+ {
18685
+ verb: "confirm",
18686
+ form: "verb",
18687
+ opener: "(confirm:",
18688
+ kinds: ["confirm"],
18689
+ args: "handles",
18690
+ thread: false,
18691
+ handleRequired: true,
18692
+ lowering: [{ target: S, writes: [], note: "corroboration witness (corroborationCount), no edge" }],
18693
+ examples: ["confirm"],
18694
+ hint: "(confirm:[shown-prior]) \u2014 it held",
18695
+ taught: "taught",
18696
+ taughtBy: "verdictBullet + context render",
18697
+ decisions: ["j"]
18698
+ },
18699
+ {
18700
+ verb: "refute",
18701
+ form: "verb",
18702
+ opener: "(refute:",
18703
+ kinds: ["refute"],
18704
+ args: "handles-text",
18705
+ thread: false,
18706
+ minText: 4,
18707
+ handleRequired: true,
18708
+ textRequired: true,
18709
+ lowering: [{ target: S, writes: [], note: "contradiction witness (contradictionPressure), no edge; reason stays local" }],
18710
+ examples: ["refute"],
18711
+ hint: "(refute:[shown-prior] one line why) \u2014 the reason is required",
18712
+ taught: "taught",
18713
+ taughtBy: "verdictBullet + context render",
18714
+ decisions: ["j"]
18715
+ }
18716
+ ];
18717
+ TAG_FENCES = [
18718
+ {
18719
+ fence: "errata-problem",
18720
+ fields: ["problem", "cause", "fix", "anchor", "kind"],
18721
+ required: [["problem"]],
18722
+ taught: "untaught",
18723
+ parser: "apps/daemon/src/turn.ts parseDesignFlags",
18724
+ decisions: ["h"],
18725
+ hint: "use an inline [!\u2026] flag instead (errata-problem cause ids never meet inline ids)"
18726
+ },
18727
+ {
18728
+ fence: "errata-resolved",
18729
+ fields: ["id", "problem", "fix", "disposition", "reason"],
18730
+ required: [["id", "problem"]],
18731
+ taught: "taught",
18732
+ taughtBy: "retract form only (TAG_EXAMPLE.retract); the fix form is untaught",
18733
+ parser: "apps/daemon/src/turn.ts parseDesignResolutions",
18734
+ hint: "```errata-resolved with id: and disposition: false_positive | invalid, reason: \u2026"
18735
+ },
18736
+ {
18737
+ fence: "errata-triage",
18738
+ fields: ["presenting", "cause", "test", "fix", "drift", "route"],
18739
+ required: [["presenting", "route"], ["cause", "test"]],
18740
+ taught: "taught",
18741
+ taughtBy: "MCP errata_triage tool copy",
18742
+ parser: "packages/local-graph/src/triage.ts parseTriageFences",
18743
+ hint: "```errata-triage with presenting: and cause: (or route: + test: to answer one)"
18744
+ },
18745
+ {
18746
+ fence: "errata-abstraction",
18747
+ fields: ["candidate", "principle", "covers"],
18748
+ required: [["candidate"], ["principle"], ["covers"]],
18749
+ taught: "taught",
18750
+ taughtBy: "MCP errata_pending_abstractions tool copy",
18751
+ parser: "packages/local-graph/src/abstraction.ts parseAbstractionFences",
18752
+ hint: "```errata-abstraction with candidate:, principle:, covers: (all required)"
18753
+ },
18754
+ {
18755
+ fence: "errata-intent",
18756
+ fields: ["intent"],
18757
+ required: [["intent"]],
18758
+ taught: "taught",
18759
+ parser: "packages/local-graph/src/intent.ts parseIntentFences",
18760
+ hint: "```errata-intent with intent: what you're about to do"
18761
+ },
18762
+ {
18763
+ fence: "errata-share",
18764
+ fields: ["priors"],
18765
+ required: [["priors"]],
18766
+ taught: "taught",
18767
+ taughtBy: "subagent hand-off copy",
18768
+ parser: "packages/local-graph/src/intent.ts parseShareFence",
18769
+ hint: "```errata-share with priors: all | [h1], [h2]"
18770
+ }
18771
+ ];
18772
+ TAG_VERB_BY_NAME = new Map(
18773
+ TAG_VERBS.filter((v) => v.form === "verb").map((v) => [v.verb, v])
18774
+ );
18775
+ TAG_PAREN_VERBS = [...TAG_VERB_BY_NAME.keys()].sort((a, b) => b.length - a.length);
18776
+ TAG_GRAMMAR_OPENERS = [
18777
+ ...new Set(TAG_VERBS.filter((v) => v.form !== "citation").map((v) => v.opener))
18778
+ ];
18779
+ TAG_QUOTED_PAREN_SOURCE = String.raw`\(\s*(?:${TAG_PAREN_VERBS.map((v) => v.replace(/-/g, "\\-")).join("|")})\s*:|\(\[`;
18780
+ TAG_QUOTED_RE = new RegExp(String.raw`\[[!?]|` + TAG_QUOTED_PAREN_SOURCE, "i");
18781
+ TAG_QUOTED_PAREN_RE = new RegExp(TAG_QUOTED_PAREN_SOURCE, "i");
18782
+ TEMPLATE_VERB_GROUP = new RegExp(
18783
+ String.raw`\(\s*(${TAG_PAREN_VERBS.map((v) => v.replace(/-/g, "\\-")).join("|")})\s*:((?:[^()\n]|\([^()\n]*\))*)\)`,
18784
+ "gi"
18785
+ );
18786
+ BRACKET_TOKEN = /\[([^\]\n]{1,80})\]/g;
18787
+ REAL_HANDLE_SHAPE = new RegExp(
18788
+ String.raw`^(?:[a-z0-9]+(?:-[a-z0-9]+)*-(?=[0-9a-f]{0,3}\d)[0-9a-f]{4}|(?:${TAG_CANONICAL_ID_PREFIXES.join("|")})_[0-9a-f]{6,})$`,
18789
+ "i"
18790
+ );
18791
+ TAG_TEMPLATES = deriveTagTemplates(tagGrammarCopy());
18792
+ VERB_WORDS_SOURCE = TAG_PAREN_VERBS.map((v) => v.replace(/-/g, "\\-")).join("|");
18793
+ JOINED_VERB = new RegExp(String.raw`[,;]\s*(?=(?:${VERB_WORDS_SOURCE})\s*:)`, "i");
18794
+ LEADING_VERB = new RegExp(String.raw`^\s*(${VERB_WORDS_SOURCE})\s*:`, "i");
18795
+ ANY_VERB_WORD = new RegExp(String.raw`\b(?:${VERB_WORDS_SOURCE})\s*:`, "gi");
18796
+ QUOTED_TAG_OPENER = new RegExp(String.raw`\(\s*(?:(${VERB_WORDS_SOURCE})\s*:|(?=\[))`, "gi");
18797
+ TAG_VERDICT_TOKENS = {
18798
+ confirm: (id) => TAG_EXAMPLES.confirm(id),
18799
+ refute: (id) => TAG_EXAMPLES.refute(id),
18800
+ failed: (id) => TAG_EXAMPLES.failedCite(id)
18801
+ };
18802
+ }
18803
+ });
18804
+
18208
18805
  // ../../packages/local-shared/src/index.ts
18209
18806
  var init_src2 = __esm({
18210
18807
  "../../packages/local-shared/src/index.ts"() {
@@ -18218,6 +18815,7 @@ var init_src2 = __esm({
18218
18815
  init_review();
18219
18816
  init_anchorable();
18220
18817
  init_sqlite_adapter();
18818
+ init_tag_grammar();
18221
18819
  }
18222
18820
  });
18223
18821
 
@@ -26743,7 +27341,7 @@ function renderSnapshot(s) {
26743
27341
  lines.push(` - previously resolved as: ${g.closed.description.slice(0, 120)} \u2014 \`${g.closed.id}\``);
26744
27342
  if (g.solution) {
26745
27343
  lines.push(
26746
- ` - the fix on record: ${g.solution.description.slice(0, 120)} \u2014 \`${g.solution.id}\` \xB7 fix still holds \u2192 (confirm:[${g.solution.id}]) \xB7 hitting it again \u2192 flag it (a second independent witness reopens the close)`
27344
+ ` - the fix on record: ${g.solution.description.slice(0, 120)} \u2014 \`${g.solution.id}\` \xB7 fix still holds \u2192 ${TAG_VERDICT_TOKENS.confirm(g.solution.id)} \xB7 hitting it again \u2192 flag it (a second independent witness reopens the close)`
26747
27345
  );
26748
27346
  } else {
26749
27347
  lines.push(
@@ -26840,7 +27438,7 @@ function renderSnapshot(s) {
26840
27438
  ` - still open \u2014 did this work settle it? fixed \u2192 (fix:[${h.id}]) \xB7 not a real problem \u2192 an \`errata-resolved\` block with \`id: ` + h.id + "`, `disposition: false_positive`, `reason: \u2026` \xB7 still open \u2192 say nothing"
26841
27439
  );
26842
27440
  } else if (h.verdict === "foreign") {
26843
- lines.push(` - open in another membrane \u2014 not yours to close: (confirm:[${h.id}]) it held \xB7 (refute:[${h.id}] one line why)`);
27441
+ lines.push(` - open in another membrane \u2014 not yours to close: ${TAG_VERDICT_TOKENS.confirm(h.id)} it held \xB7 ${TAG_VERDICT_TOKENS.refute(h.id)}`);
26844
27442
  }
26845
27443
  }
26846
27444
  }
@@ -26911,7 +27509,7 @@ function renderSnapshot(s) {
26911
27509
  lines.push(` - \u2713 ${p.description}`);
26912
27510
  for (const s2 of w.priors.solutionsByProblem[p.id] ?? []) {
26913
27511
  lines.push(
26914
- ` - fixed by: ${s2.description} \u2014 if that fix did NOT hold, refute it: \`(failed:[${s2.id}] what came back)\``
27512
+ ` - fixed by: ${s2.description} \u2014 if that fix did NOT hold, refute it: \`${TAG_VERDICT_TOKENS.failed(s2.id)}\``
26915
27513
  );
26916
27514
  }
26917
27515
  }
@@ -33885,7 +34483,7 @@ function linkBullet(ref) {
33885
34483
  ` \xB7 ${TAG_EXAMPLE.package()} \u2014 the PUBLIC package it's about, dependency or not`,
33886
34484
  ` \xB7 ${TAG_EXAMPLE.component()} \u2014 the framework/product unit`,
33887
34485
  ` \xB7 (aids:[${ref}],\u2026) \u2014 other problems your fix might also resolve (hypothesis)`,
33888
- ` \xB7 your fix vs a shown solution: (builds-on:[${ref}]) \xB7 (supersedes:[${ref}]) \xB7 (alternative:[h]) \u2014 pick one`
34486
+ ` \xB7 your fix vs a shown solution: ${TAG_EXAMPLE.buildsOn(ref)} \xB7 ${TAG_EXAMPLE.supersedes(ref)} \xB7 ${TAG_EXAMPLE.alternative("h")} \u2014 pick one`
33889
34487
  ].join("\n");
33890
34488
  }
33891
34489
  function verdictBullet(ref) {
@@ -33916,75 +34514,13 @@ function buildAgentInstruction(opts = {}) {
33916
34514
  tail
33917
34515
  ].join("\n");
33918
34516
  }
33919
- var TAG_EXAMPLE, TAG_OPENERS, GLOSS;
34517
+ var TAG_EXAMPLE, TAG_OPENERS, GLOSS, ALL_SIGNALS, TAG_TEMPLATES2;
33920
34518
  var init_agent_signals = __esm({
33921
34519
  "src/agent-signals.ts"() {
33922
34520
  "use strict";
33923
- TAG_EXAMPLE = {
33924
- prior: (ref) => `([${ref}])`,
33925
- problem: () => `[!one line on what's wrong]`,
33926
- vulnerability: () => `[!vuln: who can do what; observed basis @ path:line]`,
33927
- suspectedVulnerability: () => `[?vuln: consequence; missing check]`,
33928
- vulnerabilityThread: () => `[!#v vuln: finding here]`,
33929
- fix: (ref) => `(fix:[${ref}])`,
33930
- // CONSTRAINT — the native capture path for a DIFFUSE problem (a constraint/tension/
33931
- // conflict that shaped a decision). Free text, attaches to the decision sentence the
33932
- // agent is already writing. Full rationale in the constraint note below + prior-tags.ts.
33933
- constraint: () => `(constraint: the limitation that forced it)`,
33934
- // TRIAGE — routes the problem/symptom in scope to its cause. `(cause:[handle])`
33935
- // links to a cited RootCause/Solution node; `(cause: free text)` mints a RootCause
33936
- // from the text. Harvested in prior-tags.ts → engine.ts (see the triage note below).
33937
- triage: (ref) => `(cause:[${ref}])`,
33938
- // Unlike a bare cause citation, this handle names the Problem being explained.
33939
- triageExplain: (ref) => `(cause:[${ref}] the mechanism)`,
33940
- // The MINT form — free-text cause that mints a RootCause. Prime-time surfacing
33941
- // (recallForFile) pastes this next to an open Problem that has no cause yet, so the
33942
- // diagnostic moment is cued when the agent is looking at the problem. Kept here so
33943
- // the grammar can't drift from parseInlineTags' `(cause: …)` acceptance.
33944
- triageMint: () => `(cause: why it happens)`,
33945
- // THREAD forms — the witness-declared symptom↔cause/fix binding. A `#id` on the
33946
- // flag names the diagnosis thread; the same `#id` on a later verb binds to it
33947
- // explicitly (across sentences AND turns), replacing proximity guessing. Adjacent
33948
- // tags never need one — the id is for diagnoses that unfold over distance.
33949
- problemThread: () => `[!#slug one line on what's wrong]`,
33950
- causeThread: () => `(cause:#slug the mechanism)`,
33951
- fixThread: (thread = "slug") => `(fix:#${thread} what you changed)`,
33952
- // ATTEMPT arc — what's being tried and what didn't work. A failed attempt is a
33953
- // witnessed NEGATIVE result: it saves the next agent the same dead end.
33954
- tried: () => `(tried: the approach you're attempting)`,
33955
- failed: () => `(failed: what didn't work and the dead end it rules out)`,
33956
- // LINK verbs (AC epic) — bind the problem in scope to CANONICAL priors and
33957
- // abstractions. Multi-target by design: single links are weak; ~3 links to 3
33958
- // DIFFERENT relevant priors is the target shape (see linkBullet).
33959
- instance: (ref) => `(instance:[${ref}],[another],[a-third])`,
33960
- pattern: () => `(pattern: name the general shape)`,
33961
- // DOMAIN — the abstract area a problem is about; the concept layer an
33962
- // anchor-less problem clusters on. Mints/resolves a Domain by name.
33963
- domain: () => `(domain: The Area)`,
33964
- // PACKAGE/COMPONENT — agent-named public anchors (OM-agent-anchors): the
33965
- // package a problem is ABOUT (even when not a dependency) and the
33966
- // framework/product-level unit it concerns. Public spine anchors → the
33967
- // knowledge can cross to the collective.
33968
- package: () => `(package: the-package-name)`,
33969
- component: () => `(component: The Component)`,
33970
- aids: (ref) => `(aids:[${ref}])`,
33971
- // VERDICT (VS-verdict-tags) — a judgment on a SHOWN prior, distinct from leaning on it.
33972
- // `confirm` rides the corroborate channel (it held); `refute` the contradict channel
33973
- // (it's wrong / didn't hold) and REQUIRES a reason. This is the inline producer the
33974
- // evidence channels lacked — refute sat dead (contradictionPressure 0) until now, while
33975
- // lean-on corroboration lived, because only corroboration had an inline path. Grammar
33976
- // single-sourced with parseInlineTags' CONFIRM_PREFIX/REFUTE_PREFIX.
33977
- confirm: (ref) => `(confirm:[${ref}])`,
33978
- refute: (ref) => `(refute:[${ref}] one line why)`,
33979
- // RETRACT — "not a real problem": the errata-resolved block with a disposition
33980
- // (parseDesignResolutions, turn.ts). No inline form exists; the block is the grammar.
33981
- retract: (id) => ["```errata-resolved", `id: ${id}`, "disposition: false_positive", "reason: why it was never a real problem", "```"].join("\n")
33982
- };
33983
- TAG_OPENERS = [
33984
- ...new Set(
33985
- Object.values(TAG_EXAMPLE).map((example) => /^(\([a-z][\w-]*:|\[[!?])/i.exec(example("x"))?.[1]?.toLowerCase()).filter((opener) => opener !== void 0)
33986
- )
33987
- ];
34521
+ init_src2();
34522
+ TAG_EXAMPLE = TAG_EXAMPLES;
34523
+ TAG_OPENERS = TAG_GRAMMAR_OPENERS;
33988
34524
  GLOSS = {
33989
34525
  prior: "a shown prior helped, or you work in a primed language/package",
33990
34526
  // "even in code you just wrote" names the implementation phase explicitly. Field
@@ -34021,6 +34557,12 @@ var init_agent_signals = __esm({
34021
34557
  link: "the problem you flagged is an instance of priors/abstractions you can name \u2014 (instance:[h1],[h2],\u2026) / (pattern: \u2026) / (aids:[h]); rendered whole via linkBullet",
34022
34558
  verdict: "you can judge a prior we SHOWED you \u2014 confirm it if it held, refute it (with why) if it didn't; rendered whole via verdictBullet"
34023
34559
  };
34560
+ ALL_SIGNALS = ["prior", "problem", "vulnerability", "domain", "fix", "constraint", "triage", "attempt", "link", "verdict"];
34561
+ TAG_TEMPLATES2 = deriveTagTemplates([
34562
+ ...tagGrammarCopy(),
34563
+ ...["its-handle", "its-id"].map((referent) => buildAgentInstruction({ signals: ALL_SIGNALS, referent })),
34564
+ buildFileRecallInstruction()
34565
+ ]);
34024
34566
  }
34025
34567
  });
34026
34568
 
@@ -79560,26 +80102,14 @@ init_src5();
79560
80102
  import { readFileSync as readFileSync18, writeFileSync as writeFileSync14 } from "node:fs";
79561
80103
  var NEG = /n['']t|\b(?:not|never|no|none|neither|nor|unrelated|irrelevant|would|might|could|if)\b/i;
79562
80104
  var CITE_GROUP_RE = /\(((?:[^()\n]|\([^()\n]*\)){1,200})\)/g;
79563
- var HANDLE_RE2 = /\[([a-z0-9][\w-]{0,80})\]|((?:pat|sol|drc|dcause|dfix|dprob|dvuln|prob|claim|err)_[0-9a-f]{6,})/gi;
79564
- var PLACEHOLDER_HANDLES = /* @__PURE__ */ new Set([
79565
- "handle",
79566
- "its-handle",
79567
- "another",
79568
- "a-third",
79569
- "h",
79570
- "h1",
79571
- "h2",
79572
- "id",
79573
- "its-id",
79574
- "a",
79575
- "b"
79576
- ]);
80105
+ var HANDLE_RE2 = new RegExp(TAG_HANDLE_SOURCE, "gi");
80106
+ var PLACEHOLDER_HANDLES = TAG_PLACEHOLDER_HANDLES;
79577
80107
  var isPlaceholderHandle = (h) => PLACEHOLDER_HANDLES.has(h.toLowerCase());
79578
80108
  var FLAG_BODY_HANDLE_RE = /^(?:[a-z0-9]+(?:-[a-z0-9]+){2,}-(?=[0-9a-f]{0,3}\d)[0-9a-f]{4}|(?:pat|sol|drc|dcause|dfix|dprob|dvuln|prob|claim|err)_[0-9a-f]{6,})$/i;
79579
80109
  var FIX_PREFIX = /^\s*fix:(?:#([a-z][\w-]{0,63}))?\s*/i;
79580
- var CONSTRAINT_RE = /\(\s*constraint:\s*([^()\n]{8,}?)\s*\)/gi;
79581
80110
  var CAUSE_PREFIX = /^\s*cause:(?:#([a-z][\w-]{0,63}))?\s*/i;
79582
80111
  var NEST2_UNIT = String.raw`(?:[^()\n]|\((?:[^()\n]|\([^()\n]*\))*\))`;
80112
+ var CONSTRAINT_RE = new RegExp(String.raw`\(\s*constraint:\s*(${NEST2_UNIT}{8,}?)\s*\)`, "gi");
79583
80113
  var FIX_LONG_RE = new RegExp(String.raw`\(\s*fix:(?:#([a-z][\w-]{0,63}))?\s*(${NEST2_UNIT}{12,}?)\s*\)`, "gi");
79584
80114
  var CAUSE_LONG_RE = new RegExp(String.raw`\(\s*cause:(?:#([a-z][\w-]{0,63}))?\s*(${NEST2_UNIT}{8,}?)\s*\)`, "gi");
79585
80115
  var CONFIRM_LONG_RE = new RegExp(String.raw`\(\s*confirm:\s*(${NEST2_UNIT}{4,}?)\s*\)`, "gi");
@@ -79595,7 +80125,7 @@ var BRACKETED_TOKEN_RE = /\[[^\]\n]{1,120}\]/;
79595
80125
  var CONFIRM_PREFIX = /^\s*confirm:\s*/i;
79596
80126
  var REFUTE_PREFIX = /^\s*refute:\s*/i;
79597
80127
  var REFUTE_REASON_MIN = 4;
79598
- var PATTERN_RE = /\(\s*pattern:\s*([^()\n]{3,}?)\s*\)/gi;
80128
+ var PATTERN_RE = new RegExp(String.raw`\(\s*pattern:\s*(${NEST2_UNIT}{3,}?)\s*\)`, "gi");
79599
80129
  var DOMAIN_RE = /\(\s*domain:\s*([^()\n]{2,}?)\s*\)/gi;
79600
80130
  var PACKAGE_RE = /\(\s*package:\s*([^()\n]{2,}?)\s*\)/gi;
79601
80131
  var COMPONENT_RE = /\(\s*component:\s*([^()\n]{2,}?)\s*\)/gi;
@@ -79688,6 +80218,10 @@ function deriveFixRationale(sentence, startIdx, endIdx) {
79688
80218
  if (before.length >= FIX_RATIONALE_MIN) return before;
79689
80219
  return fixRationaleAfter(sentence, endIdx);
79690
80220
  }
80221
+ var TAG_GROUP_OPENER_RE = new RegExp(
80222
+ TAG_OPENERS.filter((o) => o.startsWith("(")).map((o) => String.raw`\(\s*${o.slice(1, -1).replace(/-/g, "\\-")}\s*:`).join("|"),
80223
+ "gi"
80224
+ );
79691
80225
  var LEADING_OPENER_RE = new RegExp(String.raw`^(?:${RESIDUAL_OPENER_RE.source})(?:#[a-z][\w-]{0,63})?\s*`, "i");
79692
80226
  var WRAPPER_PAIRS = [["(", ")"], ["[", "]"]];
79693
80227
  var LEADING_HANDLES_RE = /^(?:\[[a-z0-9][\w-]{0,80}\]\s*,?\s*)+/i;
@@ -79826,19 +80360,41 @@ function addTagDispositions(a, b) {
79826
80360
  function parseInlineTags(text) {
79827
80361
  return parseInlineTagsWithDispositions(text).tags;
79828
80362
  }
80363
+ function tagGroupSpans(line) {
80364
+ const spans = [];
80365
+ let after = 0;
80366
+ for (const m of line.matchAll(TAG_GROUP_OPENER_RE)) {
80367
+ const start2 = m.index;
80368
+ if (start2 < after) continue;
80369
+ let depth = 0;
80370
+ const limit = Math.min(line.length, start2 + 4e3);
80371
+ for (let i2 = start2; i2 < limit; i2++) {
80372
+ if (line[i2] === "(") depth++;
80373
+ else if (line[i2] === ")" && --depth === 0) {
80374
+ spans.push({ start: start2, end: i2 + 1 });
80375
+ after = i2 + 1;
80376
+ break;
80377
+ }
80378
+ }
80379
+ }
80380
+ return spans;
80381
+ }
79829
80382
  function* captureSentences(text) {
79830
80383
  for (const line of text.split(/\n+/)) {
79831
80384
  if (line.length > 2e4) {
79832
80385
  yield line;
79833
80386
  continue;
79834
80387
  }
79835
- const flags2 = [...flagScanView(line).matchAll(new RegExp(FLAG_RE.source, FLAG_RE.flags))].map((m) => ({ start: m.index, end: m.index + m[0].length }));
80388
+ const flags2 = [
80389
+ ...[...flagScanView(line).matchAll(new RegExp(FLAG_RE.source, FLAG_RE.flags))].map((m) => ({ start: m.index, end: m.index + m[0].length })),
80390
+ ...tagGroupSpans(line)
80391
+ ].sort((a, b) => a.start - b.start);
79836
80392
  let flag = 0;
79837
80393
  let start2 = 0;
79838
80394
  for (const boundary of line.matchAll(/(?<=[.!?])\s+(?!\(fix:)/g)) {
79839
80395
  const index = boundary.index;
79840
80396
  while (flags2[flag] && flags2[flag].end <= index) flag++;
79841
- if (flags2[flag] && flags2[flag].start < index) continue;
80397
+ if (flags2.slice(flag).some((f) => f.start < index && index < f.end)) continue;
79842
80398
  yield line.slice(start2, index);
79843
80399
  start2 = index + boundary[0].length;
79844
80400
  }
@@ -79857,22 +80413,28 @@ function parseInlineTagsWithDispositions(text) {
79857
80413
  continue;
79858
80414
  }
79859
80415
  const seqStart = out2.length;
79860
- const sentence = raw2.replace(/`[^`]*`/g, (m) => {
79861
- if (!/\[[!?]|\((?:fix|cause|constraint|tried|failed|confirm|refute):|\(\[/.test(m)) return m;
79862
- if (!/\((?:fix|cause|constraint|tried|failed|confirm|refute):|\(\[/.test(m)) {
80416
+ const original = raw2;
80417
+ const flagView = flagScanView(raw2);
80418
+ const flagSpans = [...flagView.matchAll(new RegExp(FLAG_RE.source, FLAG_RE.flags))].map((m) => [m.index, m.index + m[0].length]);
80419
+ const sentence = raw2.replace(/`[^`]*`/g, (m, at) => {
80420
+ if (!TAG_QUOTED_RE.test(m)) return m;
80421
+ if (!TAG_QUOTED_PAREN_RE.test(m)) {
79863
80422
  dispositions.codeSpanNeutralized++;
79864
80423
  return m;
79865
80424
  }
80425
+ const inFlag = flagSpans.some(([a2, b]) => a2 < at && at < b);
80426
+ if (!inFlag && !/\[[!?]/.test(m) && !quotesOnlyTemplateTags(m, TAG_TEMPLATES2)) return m;
79866
80427
  dispositions.codeSpanNeutralized++;
79867
- return " ";
80428
+ return m.replace(/[()[\]]/g, " ");
79868
80429
  });
79869
- const sfield = sentence.replace(/\s+/g, " ").trim().slice(0, 160);
80430
+ const sfield = raw2.replace(/\s+/g, " ").trim().slice(0, 160);
79870
80431
  const citeMatched = /* @__PURE__ */ new Set();
79871
- const flagSpans = [...flagScanView(sentence).matchAll(new RegExp(FLAG_RE.source, FLAG_RE.flags))].map((m) => [m.index, m.index + m[0].length]);
80432
+ const codeOnly = [...sentence.matchAll(/`[^`]*`/g)].filter((m) => !TAG_QUOTED_PAREN_RE.test(m[0])).map((m) => [m.index, m.index + m[0].length]);
79872
80433
  CITE_GROUP_RE.lastIndex = 0;
79873
80434
  let g;
79874
80435
  while ((g = CITE_GROUP_RE.exec(sentence)) !== null) {
79875
80436
  citeMatched.add(g.index);
80437
+ if (codeOnly.some(([a2, b]) => a2 < g.index && g.index < b)) continue;
79876
80438
  let content = g[1];
79877
80439
  if (/^\s*pattern:/i.test(content)) continue;
79878
80440
  if (/^\s*failed:/i.test(content)) continue;
@@ -79957,6 +80519,7 @@ function parseInlineTagsWithDispositions(text) {
79957
80519
  let h;
79958
80520
  let emittedHandle = false;
79959
80521
  while ((h = HANDLE_RE2.exec(content)) !== null) {
80522
+ if (content[h.index + h[0].length] === "(") continue;
79960
80523
  const handle2 = h[1] ?? h[2];
79961
80524
  if (handle2 && isPlaceholderHandle(handle2)) {
79962
80525
  dispositions.placeholderEcho++;
@@ -80062,10 +80625,9 @@ function parseInlineTagsWithDispositions(text) {
80062
80625
  }
80063
80626
  }
80064
80627
  FLAG_RE.lastIndex = 0;
80065
- const flagView = flagScanView(sentence);
80066
80628
  let f;
80067
80629
  while ((f = FLAG_RE.exec(flagView)) !== null) {
80068
- f[3] = sentence.slice(...f.indices[3]);
80630
+ f[3] = original.slice(...f.indices[3]);
80069
80631
  const flagThread = f[2];
80070
80632
  const raw3 = f[3].trim();
80071
80633
  if (/^vuln\b/i.test(raw3)) {
@@ -85224,7 +85786,7 @@ function createWatchBreaker(deps) {
85224
85786
  }
85225
85787
 
85226
85788
  // src/engine.ts
85227
- var DAEMON_VERSION = true ? "2.0.22-dev.4135" : "2.0.0-alpha.0";
85789
+ var DAEMON_VERSION = true ? "2.0.22-dev.4148" : "2.0.0-alpha.0";
85228
85790
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
85229
85791
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
85230
85792
  var GIT_OP_MUTE_MS = 4e3;