symforge 11.3.2

SymForge — in-memory code intelligence MCP server for Claude Code, Codex, and Gemini CLI
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
#!/usr/bin/env node
"use strict";

// Produce the Slice 0 CI artifact the traceability contract names `CI-SLICE0`:
// `target/ci/lifecycle-v11/slice-0-oracle-contract.json`.
//
// Slice 0's product is positive controls that MUST fail. That makes "the suite
// is green" the wrong success signal and an unbounded log the wrong evidence, so
// this records one deterministic JSON record per case — the contract's
// BOUND-ARTIFACT: "one deterministic JSON record per case ... no unbounded logs
// or repository bytes".
//
// Fail-closed in the direction that matters: a control which STOPS failing is an
// error here, not a success. Either the defect it names was fixed without its
// owning slice removing the `#[ignore]`, or the control has gone vacuous. Both
// need a human to look, so the exit code is non-zero and the artifact says which
// case changed.
//
// The slice that DOES fix a control's defect reclassifies it here as RESOLVED
// rather than deleting it. A resolved control keeps running — in the default
// suite, without `#[ignore]` — and this producer then asserts it PASSES. So the
// artifact records the RED->GREEN transition, which is the fixing slice's actual
// product, instead of going quiet about a case that used to be evidence; and a
// resolved control that regresses (fails again, or is re-`#[ignore]`d back into
// silence) is caught by the same roster check that catches a lost RED one.

const { spawnSync } = require("node:child_process");
const fs = require("node:fs");
const path = require("node:path");

const repositoryRoot = path.resolve(__dirname, "..");
const ARTIFACT = path.join("target", "ci", "lifecycle-v11", "slice-0-oracle-contract.json");
const CARGO = process.env.SYMFORGE_LIFECYCLE_CARGO_EXECUTABLE || "cargo";
const GIT = process.env.SYMFORGE_LIFECYCLE_GIT_EXECUTABLE || "git";

// Every Slice 0 control, with the exact command that runs it. `expected` is the
// outcome of the SUITE: "red" while its controls still carry `#[ignore]` and must
// fail, "green" once the owning slice fixed the defect and the control moved into
// the default suite (which is why a resolved suite must NOT pass `--ignored` —
// with the attribute gone it would select nothing and exit 0 having run nothing).
const SUITES = [
  {
    target: "tests/project_index_lifecycle_slice0.rs",
    expected: "red",
    args: ["test", "--test", "project_index_lifecycle_slice0", "--", "--ignored", "--test-threads=1"],
  },
  // Lib unit tests print their full module path, and the V11 cut mounts the
  // server modules under `src/internals.rs`, so the paths carry `internals::`.
  {
    target: "src/watcher/mod.rs::tests",
    expected: "green",
    args: [
      "test",
      "--lib",
      "internals::watcher::tests::generation_before_root_split_cannot_authorize_root_a_reindex_into_root_b",
      "--",
      "--exact",
    ],
  },
  {
    target: "src/daemon.rs::tests",
    expected: "green",
    args: [
      "test",
      "--lib",
      "internals::daemon::tests::concurrent_first_open_performs_exactly_one_cold_load",
      "--",
      "--exact",
    ],
  },
  {
    target: "tests/project_index_lifecycle_slice0.rs::failed_reload_retains_the_recovery_observer",
    expected: "green",
    args: [
      "test",
      "--test",
      "project_index_lifecycle_slice0",
      "failed_reload_retains_the_recovery_observer",
      "--",
      "--exact",
      "--test-threads=1",
    ],
  },
  {
    target: "tests/project_index_lifecycle_slice0.rs::observer_replacement_gap_is_latched_as_non_current",
    expected: "green",
    args: [
      "test",
      "--test",
      "project_index_lifecycle_slice0",
      "observer_replacement_gap_is_latched_as_non_current",
      "--",
      "--exact",
      "--test-threads=1",
    ],
  },
  {
    target: "tests/project_index_lifecycle_slice0.rs::old_observer_delivery_after_promotion_is_not_current",
    expected: "green",
    args: [
      "test",
      "--test",
      "project_index_lifecycle_slice0",
      "old_observer_delivery_after_promotion_is_not_current",
      "--",
      "--exact",
      "--test-threads=1",
    ],
  },
  {
    target: "src/live_index/store.rs::tests",
    expected: "green",
    args: [
      "test",
      "--lib",
      "internals::live_index::store::tests::reload_outside_lock_admitted_mutation_survives_swap_or_publish_fails_closed",
      "--",
      "--exact",
    ],
  },
  {
    target: "tests/project_index_lifecycle_slice0.rs::empty_placeholder_publication_refuses_watcher_mutation",
    expected: "green",
    args: [
      "test",
      "--test",
      "project_index_lifecycle_slice0",
      "empty_placeholder_publication_refuses_watcher_mutation",
      "--",
      "--exact",
      "--test-threads=1",
    ],
  },
  {
    target: "tests/project_index_lifecycle_slice0.rs::snapshot_seed_is_not_queryable_before_verification",
    expected: "green",
    args: [
      "test",
      "--test",
      "project_index_lifecycle_slice0",
      "snapshot_seed_is_not_queryable_before_verification",
      "--",
      "--exact",
      "--test-threads=1",
    ],
  },
  {
    target: "tests/project_index_lifecycle_slice0.rs::same_path_root_replacement_is_not_silently_adopted",
    expected: "green",
    args: [
      "test",
      "--test",
      "project_index_lifecycle_slice0",
      "same_path_root_replacement_is_not_silently_adopted",
      "--",
      "--exact",
      "--test-threads=1",
    ],
  },
];

const NEWLINE = String.fromCharCode(10);
const MAX_REASON_BYTES = 512;

// The exact Slice 0 roster. Without it the producer only checks that the cases it
// HAPPENS to parse are still failing, so deleting or renaming a control leaves the
// rest red and the artifact still reports success -- claimed for a roster it never
// measured. Reclassifying a control is a deliberate act belonging to the slice that
// fixes its defect, so that slice must edit these lists too.
//
// Still RED: the defect each names is unfixed, the test carries `#[ignore]`, and it
// MUST fail.
// The Slice 4 activation cut ran every one of these before merge (2026-08-20)
// and observed each still failing at the daemon/watcher seam it drives, so the
// cut did not reclassify them; they are carried post-cut work recorded in
// specs/028-preventive-activation-cut/activation-cut-execution-map.md.
const RED_CASES = [
  "capacity_refused_open_creates_no_slot_and_no_watcher",
  "configured_capacity_bounds_the_process_not_each_load",
  "whole_project_publication_preserves_latest_siblings",
];

// RESOLVED: the named slice fixed the defect, the `#[ignore]` is gone, and the
// control MUST now pass. It stays on the roster and stays run — dropping it would
// delete the regression guard and leave this artifact silent about the transition
// it exists to evidence.
const RESOLVED_CASES = new Map([
  [
    "internals::daemon::tests::concurrent_first_open_performs_exactly_one_cold_load",
    {
      slice: null,
      tasks: [],
      defect: "2.4 project loading is not single-flight",
      fix: "src/daemon.rs::ensure_project_slot_for_session_with joins concurrent first opens on a per-project_id ColdLoadFlight gate",
    },
  ],
  [
    "failed_reload_retains_the_recovery_observer",
    {
      // Track A seam 2. No frozen slice task owns this one: every slice that
      // could have owned it had already shipped by the time the control was
      // written, which is exactly why it sat RED after the cut. Recorded
      // against the campaign rather than attributed to an invented task id.
      slice: null,
      tasks: [],
      defect: "2.10 a failed reload loses the recovery observer",
      fix: "src/daemon.rs::ProjectSlot::reload_with starts a replacement observer before propagating the rebuild error",
    },
  ],
  [
    "internals::watcher::tests::generation_before_root_split_cannot_authorize_root_a_reindex_into_root_b",
    {
      slice: 1,
      tasks: ["T028"],
      defect: "2.8 root and generation authority can split",
      // Not the commit reordering the oracle's prose predicted: the fence takes
      // both values from one `Arc<PublishedGeneration>`, so the generation and
      // the root that publication served cannot disagree.
      fix: "src/watcher/mod.rs::effective_fence_generation reads one published generation",
    },
  ],
  [
    "observer_replacement_gap_is_latched_as_non_current",
    {
      // Track A seam 3a. Deliberately no task id: no frozen Feature 020 task
      // owns this seam, and inventing one would name an owner the roster does
      // not have.
      slice: null,
      tasks: [],
      defect: "2.6 an observer replacement gap is not latched and any later clean publication erases it",
      fix: "src/live_index/store.rs::latch_observer_gap latches WatcherUnavailable when an observer is cancelled, and the reload trunk carries it forward instead of rebuilding freshness without it",
    },
  ],
  [
    "old_observer_delivery_after_promotion_is_not_current",
    {
      slice: null,
      tasks: [],
      defect: "2.8 a predecessor observation delivered after promotion leaves the promoted generation claiming Current",
      // Same latch: the gap is retained rather than rederived, so the promoted
      // generation cannot report Current about a window it never observed.
      fix: "src/live_index/store.rs::latch_observer_gap, retained verbatim by recompute_freshness_locked",
    },
  ],
  [
    "internals::live_index::store::tests::reload_outside_lock_admitted_mutation_survives_swap_or_publish_fails_closed",
    {
      slice: null,
      tasks: [],
      defect: "2.7 / 2.9 observer mutation destroyed by the swap while publication reports success",
      fix: "PR #683 carry-or-fail-closed; src/live_index/store.rs::reload_outside_lock_admitted_mutation_survives_swap_or_publish_fails_closed (ordered outside-lock seam)",
    },
  ],
  [
    "empty_placeholder_publication_refuses_watcher_mutation",
    {
      slice: null,
      tasks: [],
      defect: "2.2 / 2.3 mutable-empty placeholder; watcher as competing loader",
      fix: "PR #690 WRITE-OBSERVED refuse at watcher boundary (read_and_index_observed / maybe_reindex_observed via LiveIndex::refuses_watcher_observed_admission); tests/project_index_lifecycle_slice0.rs::empty_placeholder_publication_refuses_watcher_mutation",
    },
  ],
  [
    "snapshot_seed_is_not_queryable_before_verification",
    {
      slice: 4,
      tasks: [],
      defect: "2.11 snapshot restoration bypasses candidate isolation",
      fix: "src/live_index/query.rs::LiveIndex::get_file refuses while SnapshotVerifyState is Pending or Running on a snapshot restore; tests/project_index_lifecycle_slice0.rs::snapshot_seed_is_not_queryable_before_verification asserts !served while verify is not Completed",
    },
  ],
  [
    "same_path_root_replacement_is_not_silently_adopted",
    {
      slice: null,
      tasks: ["B1"],
      defect: "2.8 same-path physical-root replacement adopted silently; freshness Current after ABA + clean reload",
      fix: "src/index_lifecycle/activation.rs::project_source_authority rebinding fence plus src/live_index/store.rs::reload_for_binding_with_exclusions admission-identity consultation",
    },
  ],
]);

const EXPECTED_CASES = [...RED_CASES, ...RESOLVED_CASES.keys()];

/// The outcome this producer asserts for a case: "green" once its owning slice
/// resolved it, "red" while it is still a positive control.
function expectationFor(caseName) {
  return RESOLVED_CASES.has(caseName) ? "green" : "red";
}

const OBSERVED_FOR_EXPECTED = { red: "failed", green: "passed" };

function git(...args) {
  const result = spawnSync(GIT, args, { cwd: repositoryRoot, encoding: "utf8", shell: false });
  if (result.status !== 0) throw new Error(`git ${args.join(" ")} failed`);
  return result.stdout.trim();
}

/// First assertion line for a case, bounded. Never the whole log.
function reasonFor(output, caseName) {
  const marker = `---- ${caseName} stdout ----`;
  const start = output.indexOf(marker);
  if (start === -1) return null;
  const lines = output.slice(start + marker.length).split("\n");
  for (const line of lines) {
    const text = line.trim();
    if (!text || text.startsWith("thread '") || text.startsWith("note:")) continue;
    if (text.startsWith("----")) break;
    return text.length > MAX_REASON_BYTES ? `${text.slice(0, MAX_REASON_BYTES)}…` : text;
  }
  return null;
}

// A test binary that aborts mid-suite (double panic, OOM, `abort`) still prints
// the results it reached, so parsing alone would yield a silent subset that every
// remaining case "preserves". And the notify-thread leak this slice fixed is
// exactly a binary that never exits, which without a timeout burns the runner's
// whole budget instead of failing with evidence. Both are checked here.
const SUITE_TIMEOUT_MS = 30 * 60 * 1000;

function runSuite(suite) {
  const result = spawnSync(CARGO, suite.args, {
    cwd: repositoryRoot,
    encoding: "utf8",
    shell: false,
    maxBuffer: 64 * 1024 * 1024,
    timeout: SUITE_TIMEOUT_MS,
  });
  const output = `${result.stdout || ""}${result.stderr || ""}`;
  if (result.error && result.error.code === "ETIMEDOUT") {
    throw new Error(`timed out after ${SUITE_TIMEOUT_MS} ms: ${suite.args.join(" ")}`);
  }
  if (result.error) {
    throw new Error(`could not run: ${suite.args.join(" ")}: ${result.error.message}`);
  }
  if (result.signal) {
    throw new Error(`killed by ${result.signal}: ${suite.args.join(" ")}`);
  }
  // A RED suite must exit non-zero. Exit 0 means either nothing ran or its
  // controls stopped failing; the roster check below names which, but the run
  // itself is already not what this artifact assumes.
  if (suite.expected === "red" && result.status === 0) {
    throw new Error(
      `exited 0 with no failing case, so nothing was preserved: ${suite.args.join(" ")}`,
    );
  }
  // A resolved suite exiting non-zero is NOT thrown on: that is a regression in a
  // control this producer is here to report, so it is parsed, recorded with its
  // bounded reason line, and failed by the per-case check. A non-zero exit that
  // parsed no case at all -- a build failure -- still throws below.

  // libtest prints `ignored, {reason}` for `#[ignore = "..."]`, which every Slice 0
  // control uses, so the outcome is NOT always the end of the line. Anchoring there
  // made a silenced control parse as no case at all: re-`#[ignore]`ing a resolved
  // control failed closed (good) with "no cases parsed" (wrong cause — that error
  // means a build failure). The optional suffix keeps the observation honest.
  const cases = [];
  for (const match of output.matchAll(
    /^test ([A-Za-z0-9_:]+) \.\.\. (ok|FAILED|ignored)(?:, [^\n]*)?$/gmu,
  )) {
    const [, caseName, outcome] = match;
    cases.push({
      case: caseName,
      target: suite.target,
      command: `${CARGO} ${suite.args.join(" ")}`,
      expected: expectationFor(caseName),
      observed: outcome === "FAILED" ? "failed" : outcome === "ok" ? "passed" : "ignored",
      reason: outcome === "FAILED" ? reasonFor(output, caseName) : null,
      resolved_by: RESOLVED_CASES.get(caseName) ?? null,
    });
  }
  if (cases.length === 0) {
    throw new Error(`no cases parsed from: ${suite.args.join(" ")}\n${output.slice(-2000)}`);
  }
  return cases;
}

const cases = SUITES.flatMap(runSuite).sort((left, right) => left.case.localeCompare(right.case));
const unexpected = cases.filter(
  (entry) => entry.observed !== OBSERVED_FOR_EXPECTED[entry.expected],
);
const observedNames = cases.map((entry) => entry.case).sort();
const expectedNames = [...EXPECTED_CASES].sort();
const missing = expectedNames.filter((name) => !observedNames.includes(name));
const extra = observedNames.filter((name) => !expectedNames.includes(name));

const artifact = {
  kind: "symforge.lifecycle.v11.slice0_oracle_contract",
  // 2: `expected` is per case and may be "green" for a control its owning slice
  // resolved, which every v1 reader assumed impossible; cases carry `resolved_by`.
  schema_version: 2,
  slice: 0,
  release_commit: git("rev-parse", "--verify", "HEAD"),
  release_tree: git("rev-parse", "--verify", "HEAD^{tree}"),
  case_count: cases.length,
  expected_case_count: EXPECTED_CASES.length,
  red_case_count: RED_CASES.length,
  resolved_case_count: RESOLVED_CASES.size,
  missing_cases: missing,
  unexpected_cases: extra,
  cases,
  status:
    unexpected.length === 0 && missing.length === 0 && extra.length === 0
      ? "expected_outcomes_preserved"
      : "unexpected_outcome",
};

fs.mkdirSync(path.join(repositoryRoot, path.dirname(ARTIFACT)), { recursive: true });
fs.writeFileSync(
  path.join(repositoryRoot, ARTIFACT),
  `${JSON.stringify(artifact, null, 2)}\n`,
  "utf8",
);

for (const name of missing) {
  process.stderr.write(`ERROR SLICE0_ORACLE_MISSING: ${name} was not run` + NEWLINE);
}
for (const name of extra) {
  process.stderr.write(`ERROR SLICE0_ORACLE_EXTRA: ${name} is not in the expected roster` + NEWLINE);
}
if (unexpected.length > 0 || missing.length > 0 || extra.length > 0) {
  for (const entry of unexpected) {
    process.stderr.write(
      `ERROR SLICE0_ORACLE_UNEXPECTED: ${entry.case} observed ${entry.observed}, expected ${entry.expected}\n`,
    );
  }
  process.stderr.write(
    "A Slice 0 positive control that stops failing is either a fix landed without its " +
      "owning slice reclassifying it here, or a control gone vacuous. A resolved control "
      + "that stops passing is a regression of the fix that resolved it, and one observed "
      + "`ignored` has been silenced by a re-added attribute. A control that disappears "
      + "from the roster is a lost positive control. All need review.\n",
  );
  process.exitCode = 1;
} else {
  process.stdout.write(
    `slice 0 oracle contract: ${cases.length} controls preserved `
      + `(${RED_CASES.length} red, ${RESOLVED_CASES.size} resolved-green) -> ${ARTIFACT}\n`,
  );
}