sneakoscope 5.3.0 → 5.5.0

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.
Files changed (51) hide show
  1. package/README.md +4 -0
  2. package/crates/sks-core/Cargo.lock +1 -1
  3. package/crates/sks-core/Cargo.toml +1 -1
  4. package/crates/sks-core/src/main.rs +1 -1
  5. package/dist/bin/sks.js +1 -1
  6. package/dist/config/skills-manifest.json +58 -58
  7. package/dist/core/agents/agent-orchestrator.js +14 -2
  8. package/dist/core/agents/agent-proof-evidence.js +16 -0
  9. package/dist/core/bench.js +24 -2
  10. package/dist/core/codex-app/sks-menubar.js +68 -7
  11. package/dist/core/commands/agent-command.js +35 -1
  12. package/dist/core/commands/basic-cli.js +59 -0
  13. package/dist/core/commands/command-utils.js +14 -4
  14. package/dist/core/commands/goal-command.js +3 -0
  15. package/dist/core/commands/image-ux-review-command.js +4 -1
  16. package/dist/core/commands/mad-sks-command.js +10 -1
  17. package/dist/core/commands/naruto-command.js +12 -7
  18. package/dist/core/commands/ppt-command.js +40 -1
  19. package/dist/core/commands/qa-loop-command.js +4 -1
  20. package/dist/core/commands/release-command.js +3 -3
  21. package/dist/core/commands/research-command.js +4 -0
  22. package/dist/core/commands/route-success-helpers.js +2 -0
  23. package/dist/core/commands/run-command.js +22 -5
  24. package/dist/core/commands/seo-command.js +31 -4
  25. package/dist/core/db-safety.js +8 -1
  26. package/dist/core/feature-fixture-executor.js +262 -0
  27. package/dist/core/feature-fixtures.js +95 -52
  28. package/dist/core/fsx.js +1 -1
  29. package/dist/core/loops/loop-decomposer.js +4 -3
  30. package/dist/core/loops/loop-planner.js +7 -3
  31. package/dist/core/loops/loop-worker-runtime.js +6 -0
  32. package/dist/core/pipeline-internals/runtime-gates.js +39 -3
  33. package/dist/core/proof/selftest-proof-fixtures.js +8 -0
  34. package/dist/core/providers/glm/naruto/glm-naruto-requirement-coverage.js +18 -1
  35. package/dist/core/providers/glm/naruto/glm-naruto-requirement-ledger.js +28 -12
  36. package/dist/core/questions.js +12 -10
  37. package/dist/core/release/release-gate-node.js +2 -0
  38. package/dist/core/routes.js +11 -0
  39. package/dist/core/stop-gate/stop-gate-check.js +4 -0
  40. package/dist/core/stop-gate/stop-gate-writer.js +4 -0
  41. package/dist/core/trust-kernel/trust-report.js +10 -1
  42. package/dist/core/version.js +1 -1
  43. package/dist/core/work-order-ledger.js +60 -0
  44. package/dist/scripts/gate-policy-audit-check.js +2 -2
  45. package/dist/scripts/packlist-performance-check.js +7 -1
  46. package/dist/scripts/release-dag-full-coverage-check.js +1 -1
  47. package/dist/scripts/release-gate-existence-audit.js +1 -1
  48. package/dist/scripts/release-gate-planner.js +1 -1
  49. package/dist/scripts/release-metadata-1-19-check.js +1 -1
  50. package/package.json +5 -1
  51. package/schemas/release/release-gate-node.schema.json +1 -0
@@ -215,11 +215,22 @@ export async function installSksMenuBar(opts = {}) {
215
215
  else {
216
216
  if (!target.used_previous_script && await readText(paths.action_script_path, '') !== actionScript) {
217
217
  await writeTextAtomic(paths.action_script_path, actionScript);
218
- await fs.chmod(paths.action_script_path, 0o755);
219
218
  actions.push(`wrote ${paths.action_script_path}`);
220
219
  }
221
- else if (!target.used_previous_script) {
222
- await fs.chmod(paths.action_script_path, 0o755).catch(() => undefined);
220
+ }
221
+ // The Swift app executes the action script DIRECTLY (Process.executableURL points at the
222
+ // script itself), so a lost executable bit breaks every menu action even when the script
223
+ // content is current. Re-assert the bit on every install run — including the up-to-date
224
+ // fast path, which previously never touched permissions and therefore could never repair
225
+ // a 0644 script — and surface chmod failures instead of swallowing them.
226
+ if (await exists(paths.action_script_path)) {
227
+ const previouslyExecutable = await fs.access(paths.action_script_path, fs.constants.X_OK).then(() => true).catch(() => false);
228
+ const chmodError = await fs.chmod(paths.action_script_path, 0o755).then(() => null).catch((err) => (err?.message ? String(err.message) : String(err)));
229
+ if (chmodError) {
230
+ warnings.push(`action_script_chmod_failed:${chmodError}`);
231
+ }
232
+ else if (!previouslyExecutable) {
233
+ actions.push('restored action script executable bit');
223
234
  }
224
235
  }
225
236
  if (!stampMatches && !binaryStable) {
@@ -429,10 +440,24 @@ async function resolveCodexBundleId(input) {
429
440
  }
430
441
  return null;
431
442
  }
432
- async function smokeSksMenuBarAction(actionScriptPath) {
443
+ export async function smokeSksMenuBarAction(actionScriptPath) {
433
444
  if (!(await exists(actionScriptPath)))
434
- return { ok: false, code: null, output: null, versionDetected: false };
435
- const result = await runProcess('/bin/zsh', [actionScriptPath, 'version'], {
445
+ return { ok: false, code: null, output: null, versionDetected: false, executable: false };
446
+ // The Swift app runs the script directly (which requires the executable bit), so the smoke
447
+ // check must invoke it the same way. Running it via `/bin/zsh <script>` — as this check used
448
+ // to — succeeds even when +x is missing, which let doctor/status report a healthy action
449
+ // target while the menu bar itself was showing "action script broken".
450
+ const executable = await fs.access(actionScriptPath, fs.constants.X_OK).then(() => true).catch(() => false);
451
+ if (!executable) {
452
+ return {
453
+ ok: false,
454
+ code: null,
455
+ output: 'action script is not executable (missing +x); the menu bar app cannot run it',
456
+ versionDetected: false,
457
+ executable: false
458
+ };
459
+ }
460
+ const result = await runProcess(actionScriptPath, ['version'], {
436
461
  timeoutMs: 5_000,
437
462
  maxOutputBytes: 16 * 1024
438
463
  }).catch((err) => ({ code: 1, stdout: '', stderr: err?.message || String(err) }));
@@ -442,7 +467,8 @@ async function smokeSksMenuBarAction(actionScriptPath) {
442
467
  ok: result.code === 0 && versionDetected,
443
468
  code: result.code,
444
469
  output: output ? output.slice(0, 700) : null,
445
- versionDetected
470
+ versionDetected,
471
+ executable: true
446
472
  };
447
473
  }
448
474
  async function isCodexAppRunningByBundleId(bundleId, env = process.env) {
@@ -485,6 +511,8 @@ export async function inspectSksMenuBarStatus(opts = {}) {
485
511
  blockers.push('menubar_app_missing');
486
512
  if (installed && launchd.checked && !launchd.ok)
487
513
  blockers.push('launchd_not_running');
514
+ if (installed && !actionSmoke.executable)
515
+ blockers.push('action_script_not_executable');
488
516
  if (installed && !actionSmoke.ok)
489
517
  blockers.push('action_script_smoke_failed');
490
518
  if (installed && signature.checked && !signature.ok)
@@ -509,6 +537,7 @@ export async function inspectSksMenuBarStatus(opts = {}) {
509
537
  smoke_code: actionSmoke.code,
510
538
  smoke_output: actionSmoke.output,
511
539
  version_detected: actionSmoke.versionDetected,
540
+ executable: actionSmoke.executable,
512
541
  ok: actionSmoke.ok
513
542
  },
514
543
  codex_sync: codexSync,
@@ -770,6 +799,9 @@ export function swiftMenuSource(input) {
770
799
 
771
800
  func setIconVisible(_ visible: Bool) {
772
801
  statusItem.isVisible = visible
802
+ if visible {
803
+ reassertControlCenterVisibility()
804
+ }
773
805
  }
774
806
 
775
807
  func isCodexRunning() -> Bool {
@@ -784,6 +816,9 @@ export function swiftMenuSource(input) {
784
816
 
785
817
  func setIconVisible(_ visible: Bool) {
786
818
  statusItem.isVisible = visible
819
+ if visible {
820
+ reassertControlCenterVisibility()
821
+ }
787
822
  }
788
823
 
789
824
  func isCodexRunning() -> Bool {
@@ -799,6 +834,32 @@ let menubarConfigPath = ${swiftString(input.configPath)}
799
834
  let lastActionLogPath = ${swiftString(input.lastActionLogPath)}
800
835
  let codexBundleId: String? = ${input.codexBundleId ? swiftString(input.codexBundleId) : 'nil'}
801
836
  let packageVersion = ${swiftString(input.packageVersion)}
837
+ let menuBarLabel = ${swiftString(SKS_MENUBAR_LABEL)}
838
+ let controlCenterDomain = ${swiftString(CONTROL_CENTER_DOMAIN)}
839
+
840
+ /// macOS persists status-item visibility hints per-label in Control Center's
841
+ /// defaults domain (see installSksMenuBar's seedMenuBarPreferredPosition).
842
+ /// Toggling NSStatusItem.isVisible back to true inside a resident process is
843
+ /// not always sufficient to make Control Center re-render a previously
844
+ /// hidden item, so re-show must reassert the same Control Center defaults
845
+ /// the installer seeds, or the icon can stay invisible after a Codex
846
+ /// quit/relaunch cycle even though isVisible is technically true again.
847
+ func reassertControlCenterVisibility() {
848
+ let defaultsBin = "/usr/bin/defaults"
849
+ guard FileManager.default.isExecutableFile(atPath: defaultsBin) else { return }
850
+ let writes: [[String]] = [
851
+ ["write", controlCenterDomain, "NSStatusItem Visible \\(menuBarLabel)", "-bool", "true"],
852
+ ["write", controlCenterDomain, "NSStatusItem VisibleCC \\(menuBarLabel)", "-bool", "true"]
853
+ ]
854
+ for args in writes {
855
+ let process = Process()
856
+ process.executableURL = URL(fileURLWithPath: defaultsBin)
857
+ process.arguments = args
858
+ process.standardOutput = FileHandle.nullDevice
859
+ process.standardError = FileHandle.nullDevice
860
+ try? process.run()
861
+ }
862
+ }
802
863
 
803
864
  func shellQuote(_ value: String) -> String {
804
865
  return "'" + value.replacingOccurrences(of: "'", with: "'\\\\''") + "'"
@@ -1,5 +1,5 @@
1
1
  import path from 'node:path';
2
- import { findLatestMission, loadMission } from '../mission.js';
2
+ import { findLatestMission, loadMission, missionDir } from '../mission.js';
3
3
  import { readJson, readText, sksRoot, writeJsonAtomic } from '../fsx.js';
4
4
  import { runNativeAgentOrchestrator } from '../agents/agent-orchestrator.js';
5
5
  import { parseAgentCommandArgs } from '../agents/agent-command-surface.js';
@@ -23,6 +23,9 @@ export async function agentCommand(commandOrArgs = 'agent', maybeArgs = []) {
23
23
  }
24
24
  async function agentRun(parsed) {
25
25
  const result = await runNativeAgentOrchestrator({ ...parsed, routeCommand: 'sks agent run', routeBlackboxKind: 'actual_agent_command' });
26
+ if (normalizeRouteName(parsed.route) === 'release-review' && result.mission_id) {
27
+ await writeReleaseReviewNativeAgentPlan(parsed, result);
28
+ }
26
29
  return emit(parsed, result, () => {
27
30
  console.log('Native agent mission: ' + result.mission_id);
28
31
  console.log('Backend: ' + result.backend);
@@ -30,6 +33,37 @@ async function agentRun(parsed) {
30
33
  console.log('Proof: ' + result.proof.status);
31
34
  });
32
35
  }
36
+ function normalizeRouteName(route = '') {
37
+ return String(route || '').replace(/^\$/, '').trim().toLowerCase();
38
+ }
39
+ /**
40
+ * $Release-Review runs through the generic native agent orchestrator (sks agent run
41
+ * --route "$Release-Review"), which does not itself know it is a release-review run.
42
+ * Write the route-specific release-review-native-agent-plan.json summary artifact here
43
+ * so `route-release-review`'s fixture contract (plan file + agent proof evidence +
44
+ * agent effort policy) is genuinely satisfied by this command rather than only partially.
45
+ */
46
+ async function writeReleaseReviewNativeAgentPlan(parsed, result) {
47
+ const root = await sksRoot();
48
+ const dir = missionDir(root, result.mission_id);
49
+ const plan = {
50
+ schema: 'sks.release-review-native-agent-plan.v1',
51
+ ok: Boolean(result.ok),
52
+ mission_id: result.mission_id,
53
+ route: '$Release-Review',
54
+ route_command: 'sks agent run',
55
+ backend: result.backend,
56
+ prompt: parsed.prompt,
57
+ roster: {
58
+ agent_count: result.roster?.agent_count ?? parsed.agents ?? null,
59
+ concurrency: result.roster?.concurrency ?? parsed.concurrency ?? null
60
+ },
61
+ proof_status: result.proof?.status || null,
62
+ agent_proof_evidence: 'agents/agent-proof-evidence.json',
63
+ agent_effort_policy: 'agents/agent-effort-policy.json'
64
+ };
65
+ await writeJsonAtomic(path.join(dir, 'release-review-native-agent-plan.json'), plan);
66
+ }
33
67
  async function agentPlan(parsed) {
34
68
  const root = await sksRoot();
35
69
  const roster = buildAgentRoster({ agents: parsed.agents, concurrency: parsed.concurrency, prompt: parsed.prompt, readonly: parsed.readonly });
@@ -8,6 +8,7 @@ import { PACKAGE_VERSION, ensureDir, exists, nowIso, projectRoot, readJson, sksR
8
8
  import { COMMAND_CATALOG, DOLLAR_COMMAND_ALIASES, DOLLAR_COMMANDS, USAGE_TOPICS, routePrompt, routeReasoning, reasoningInstruction } from '../routes.js';
9
9
  import { initProject, normalizeInstallScope, sksCommandPrefix } from '../init.js';
10
10
  import { buildFeatureRegistry, validateFeatureRegistry } from '../feature-registry.js';
11
+ import { runFeatureFixture } from '../feature-fixture-executor.js';
11
12
  import { hooksExplainReport } from '../../cli/feature-commands.js';
12
13
  import { writeSelftestRouteProof } from '../proof/selftest-proof-fixtures.js';
13
14
  import { createMission } from '../mission.js';
@@ -279,6 +280,8 @@ export async function postinstallCommand(args = []) {
279
280
  return postinstall({ bootstrap: bootstrapCommand, args });
280
281
  }
281
282
  export async function selftestCommand(args = []) {
283
+ if (flag(args, '--real'))
284
+ return selftestRealCommand(args);
282
285
  process.env.CI = 'true';
283
286
  const root = await projectRoot();
284
287
  const tmp = tmpdir('sks-selftest-');
@@ -307,6 +310,62 @@ export async function selftestCommand(args = []) {
307
310
  return printJson(result);
308
311
  console.log('SKS selftest passed');
309
312
  }
313
+ /**
314
+ * `sks selftest --real`: actually spawns every feature fixture whose kind is
315
+ * 'execute' or 'execute_and_validate_artifacts', derives real pass/fail status
316
+ * from the process exit code (and, for execute_and_validate_artifacts, from
317
+ * whether the declared expected_artifacts actually exist and match their
318
+ * declared schema), and writes a JSON report that explicitly lists fixtures
319
+ * skipped because they are mock/wiring_only kind rather than silently omitting
320
+ * them. This is additive: plain `sks selftest --mock` behavior is unchanged.
321
+ */
322
+ export async function selftestRealCommand(args = []) {
323
+ process.env.CI = 'true';
324
+ const root = await projectRoot();
325
+ const registry = await buildFeatureRegistry({ root });
326
+ const executableKinds = new Set(['execute', 'execute_and_validate_artifacts']);
327
+ const results = [];
328
+ const skippedWiringOnly = [];
329
+ for (const feature of registry.features || []) {
330
+ const fx = feature.fixture || {};
331
+ if (executableKinds.has(fx.kind)) {
332
+ const run = await runFeatureFixture(feature, { root });
333
+ results.push(run);
334
+ }
335
+ else if (fx.kind === 'mock' || fx.kind === 'wiring_only' || fx.quality === 'wiring_only') {
336
+ skippedWiringOnly.push({ id: feature.id, kind: fx.kind, reason: fx.reason || 'mock_or_wiring_only_kind_not_executed' });
337
+ }
338
+ }
339
+ const failures = results.filter((row) => !row.ok);
340
+ const ok = failures.length === 0;
341
+ const report = {
342
+ schema: 'sks.selftest-real.v1',
343
+ ok,
344
+ version: PACKAGE_VERSION,
345
+ generated_at: nowIso(),
346
+ root,
347
+ checked: results.length,
348
+ passed: results.filter((row) => row.ok).length,
349
+ failed: failures.length,
350
+ results,
351
+ skipped_wiring_only: skippedWiringOnly,
352
+ skipped_wiring_only_count: skippedWiringOnly.length,
353
+ blockers: failures.flatMap((row) => row.blockers || [])
354
+ };
355
+ const reportPath = path.join(root, '.sneakoscope', 'reports', 'selftest-real-report.json');
356
+ await writeJsonAtomic(reportPath, report);
357
+ const output = { ...report, report_file: path.relative(root, reportPath) };
358
+ if (flag(args, '--json'))
359
+ return printJson(output);
360
+ console.log(`SKS selftest --real: ${ok ? 'passed' : 'blocked'} (checked=${results.length}, skipped_wiring_only=${skippedWiringOnly.length})`);
361
+ console.log(`Report: ${path.relative(root, reportPath)}`);
362
+ if (!ok) {
363
+ for (const blocker of report.blockers)
364
+ console.log(`- ${blocker}`);
365
+ process.exitCode = 1;
366
+ }
367
+ return output;
368
+ }
310
369
  export async function reasoningCommand(args = []) {
311
370
  const prompt = args.filter((arg) => !String(arg).startsWith('--')).join(' ').trim();
312
371
  const route = routePrompt(prompt || '$SKS');
@@ -1,8 +1,17 @@
1
1
  import { findLatestMission, listSessionStates } from '../mission.js';
2
2
  import { DOLLAR_SKILL_NAMES, RECOMMENDED_SKILLS } from '../routes.js';
3
3
  export const flag = (args = [], name) => args.includes(name);
4
- export function promptOf(args = []) {
5
- return args.filter((x) => !String(x).startsWith('--')).join(' ').trim();
4
+ // Blindly dropping every "--"-prefixed argv token (the previous behavior of
5
+ // promptOf/positionalArgs) silently deletes any part of an unquoted work-order
6
+ // prompt that happens to contain a flag-lookalike phrase (e.g. "--files 로
7
+ // 확인해라"). Only strip tokens that are actually recognized boolean/global
8
+ // flags; anything else stays in the reconstructed prompt.
9
+ const KNOWN_BOOLEAN_FLAGS = new Set([
10
+ '--json', '--mock', '--execute', '--auto', '--visual', '--research', '--db',
11
+ '--legacy-goal-runtime', '--help', '-h'
12
+ ]);
13
+ export function promptOf(args = [], knownFlags = KNOWN_BOOLEAN_FLAGS) {
14
+ return args.filter((x) => !knownFlags.has(String(x))).join(' ').trim();
6
15
  }
7
16
  export async function resolveMissionId(root, arg) {
8
17
  if (arg && arg !== 'latest')
@@ -56,8 +65,9 @@ export function positionalArgs(args = []) {
56
65
  i += 1;
57
66
  continue;
58
67
  }
59
- if (!arg.startsWith('--'))
60
- out.push(arg);
68
+ if (KNOWN_BOOLEAN_FLAGS.has(arg))
69
+ continue;
70
+ out.push(arg);
61
71
  }
62
72
  return out;
63
73
  }
@@ -2,6 +2,7 @@ import path from 'node:path';
2
2
  import { exists, readJson, sksRoot } from '../fsx.js';
3
3
  import { initProject } from '../init.js';
4
4
  import { createMission, loadMission, setCurrent, stateFile } from '../mission.js';
5
+ import { createAndWriteWorkOrderLedgerForPrompt, closeWorkOrderLedgerForRouteResult } from '../work-order-ledger.js';
5
6
  import { GOAL_BRIDGE_ARTIFACT, GOAL_WORKFLOW_ARTIFACT, updateGoalWorkflow, writeGoalWorkflow } from '../goal-workflow.js';
6
7
  import { flag, promptOf, resolveMissionId } from './command-utils.js';
7
8
  import { compileGoalToLoopPlan } from '../loops/goal-to-loop-compat.js';
@@ -37,11 +38,13 @@ async function goalCreate(args) {
37
38
  if (flag(args, '--legacy-goal-runtime') || process.env.SKS_LEGACY_GOAL_RUNTIME === '1')
38
39
  return legacyGoalCreate(root, prompt, args);
39
40
  const { id, dir, mission } = await createMission(root, { mode: 'goal', prompt });
41
+ await createAndWriteWorkOrderLedgerForPrompt(dir, { missionId: id, route: 'Goal', prompt });
40
42
  const workflow = await writeGoalWorkflow(dir, mission, { action: 'create', prompt });
41
43
  const plan = await compileGoalToLoopPlan({ root, missionId: id, goalText: prompt, legacyGoalOptions: { native_goal: workflow.native_goal } });
42
44
  const result = await runLoopPlan({ root, plan, parallelism: 'balanced' });
43
45
  const gate = await evaluateLocalGate({ root, missionId: id, gateFile: 'loop-graph-proof.json' });
44
46
  const ok = result.ok === true && gate.ok === true;
47
+ await closeWorkOrderLedgerForRouteResult(dir, { ok, blockers: gate.blockers || [] });
45
48
  await setCurrent(root, { mission_id: id, mode: 'GOAL', route: 'Goal', route_command: '$Goal', phase: ok ? 'GOAL_LOOP_COMPLETED' : 'GOAL_LOOP_BLOCKED', questions_allowed: true, implementation_allowed: true, native_goal: workflow.native_goal, stop_gate: 'loop-graph-proof.json', stop_gate_blockers: gate.blockers }, { replace: true });
46
49
  if (!ok)
47
50
  process.exitCode = 1;
@@ -13,6 +13,7 @@ import { sha256File, imageDimensions } from '../wiki-image/image-hash.js';
13
13
  import { writeRouteCollaborationArtifacts } from '../agents/route-collaboration-ledger.js';
14
14
  import { codexChromeExtensionStatus } from '../codex-app.js';
15
15
  import { requireCodexImagegen } from '../imagegen/require-imagegen.js';
16
+ import { evaluateGate } from '../stop-gate/gate-evaluator.js';
16
17
  const ONE_BY_ONE_PNG_BASE64 = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMB/axX7V8AAAAASUVORK5CYII=';
17
18
  const IMAGE_UX_REVIEW_ARTIFACT_PATHS = {
18
19
  policy: IMAGE_UX_REVIEW_POLICY_ARTIFACT,
@@ -358,9 +359,11 @@ async function statusImageUxReview(root, args = []) {
358
359
  const gate = await readJson(path.join(dir, 'image-ux-review-gate.json'), null);
359
360
  const issueLedger = await readJson(path.join(dir, IMAGE_UX_REVIEW_ISSUE_LEDGER_ARTIFACT), null);
360
361
  const generatedLedger = await readJson(path.join(dir, IMAGE_UX_REVIEW_GENERATED_REVIEW_LEDGER_ARTIFACT), null);
361
- const result = { schema: 'sks.image-ux-review-status.v2', ok: true, mission_id: missionId, gate, issue_ledger: issueLedger, generated_review_ledger: generatedLedger };
362
+ const gateVerdict = await evaluateGate(root, missionId, 'image-ux-review-gate.json');
363
+ const result = { schema: 'sks.image-ux-review-status.v2', ok: true, mission_id: missionId, gate, gate_verdict: gateVerdict, issue_ledger: issueLedger, generated_review_ledger: generatedLedger };
362
364
  if (flag(args, '--json'))
363
365
  return printJson(result);
366
+ console.log(gateVerdict.verdict);
364
367
  console.log(`Image UX Review mission: ${missionId}`);
365
368
  console.log(`Gate: ${gate?.status || (gate?.passed ? 'passed' : gate ? 'present' : 'missing')}`);
366
369
  if (gate?.verified_level)
@@ -26,6 +26,7 @@ import { repairZellijForSks } from '../zellij/zellij-self-heal.js';
26
26
  import { buildMadGlmLaunchArtifact, buildMadGlmLaunchProfileNoWrite, resolveMadGlmLaunchKey, writeMadGlmCodexWrapper } from '../providers/glm/glm-mad-launch.js';
27
27
  import { GLM_MAD_MODE } from '../providers/glm/glm-52-settings.js';
28
28
  import { assertNonGlmMadRoute } from '../routes/model-mode-router.js';
29
+ import { evaluateGate } from '../stop-gate/gate-evaluator.js';
29
30
  const MAD_SKS_DEFAULT_TTL_MS = 10 * 60 * 1000;
30
31
  export async function madHighCommand(args = [], deps = {}) {
31
32
  const subcommand = firstSubcommand(args);
@@ -1013,6 +1014,12 @@ async function madSksSubcommand(subcommand, args = []) {
1013
1014
  if (subcommand === 'doctor' || subcommand === 'status') {
1014
1015
  const protectedCore = resolveProtectedCore({ packageRoot: packageRoot(), targetRoot });
1015
1016
  const before = await snapshotProtectedCore(packageRoot(), 'status');
1017
+ const statusMissionId = await findLatestMission(root);
1018
+ const gateVerdict = statusMissionId
1019
+ ? await evaluateGate(root, statusMissionId, 'mad-sks-gate.json')
1020
+ : await evaluateGate(root, 'no-mission', 'mad-sks-gate.json');
1021
+ if (!json)
1022
+ console.log(gateVerdict.verdict);
1016
1023
  return emit({
1017
1024
  schema: subcommand === 'doctor' ? 'sks.mad-sks-doctor.v1' : 'sks.mad-sks-status.v1',
1018
1025
  ok: true,
@@ -1022,7 +1029,9 @@ async function madSksSubcommand(subcommand, args = []) {
1022
1029
  protected_core_snapshot: before,
1023
1030
  protected_core_immutable: !protectedCore.engine_source_exception,
1024
1031
  protected_core_write_allowed: protectedCore.engine_source_exception,
1025
- permission_active: false
1032
+ permission_active: false,
1033
+ mission_id: statusMissionId,
1034
+ gate_verdict: gateVerdict
1026
1035
  }, json);
1027
1036
  }
1028
1037
  if (subcommand === 'close' || subcommand === 'revoke') {
@@ -1,6 +1,7 @@
1
1
  import path from 'node:path';
2
2
  import { ui as cliUi } from '../../cli/cli-theme.js';
3
3
  import { createMission, findLatestMission, loadMission, setCurrent } from '../mission.js';
4
+ import { createAndWriteWorkOrderLedgerForPrompt, closeWorkOrderLedgerForRouteResult } from '../work-order-ledger.js';
4
5
  import { nowIso, readJson, sksRoot, writeJsonAtomic } from '../fsx.js';
5
6
  import { runNativeAgentOrchestrator } from '../agents/agent-orchestrator.js';
6
7
  import { classifyOllamaWorkerSlice } from '../agents/agent-runner-ollama.js';
@@ -95,6 +96,7 @@ async function narutoRun(parsed) {
95
96
  maxAgentCount: MAX_NARUTO_AGENT_COUNT
96
97
  });
97
98
  const mission = await createMission(root, { mode: 'naruto', prompt: parsed.prompt });
99
+ await createAndWriteWorkOrderLedgerForPrompt(mission.dir, { missionId: mission.id, route: 'Naruto', prompt: parsed.prompt });
98
100
  await writeCodex0138CapabilityArtifacts(root, { missionId: mission.id }).catch(() => null);
99
101
  await writeCodex0139CapabilityArtifacts(root, { missionId: mission.id }).catch(() => null);
100
102
  const gitWorktreeCapability = writeCapable
@@ -280,13 +282,13 @@ async function narutoRun(parsed) {
280
282
  rebalance_ready: rebalancePolicy.ok === true,
281
283
  concurrency_governor_ready: true,
282
284
  active_pool_simulated: activePool.ok === true,
283
- verification_dag_ready: true,
284
- gpt_final_pack_ready: true,
285
+ verification_dag_ready: Array.isArray(verificationDag?.tasks),
286
+ gpt_final_pack_ready: Boolean(gptFinalPack?.schema),
285
287
  zellij_dashboard_ready: zellijDashboard.ok === true,
286
288
  native_agent_proof: false,
287
289
  final_arbiter_accepted: false,
288
290
  session_cleanup: false,
289
- blockers: [],
291
+ blockers: [...(workGraph.blockers || []), ...(allocationPolicy.blockers || [])],
290
292
  updated_at: nowIso()
291
293
  });
292
294
  await setCurrent(root, {
@@ -417,9 +419,11 @@ async function narutoRun(parsed) {
417
419
  const regressionProof = summarizeRegressionProof(workGraph, result);
418
420
  await writeJsonAtomic(path.join(mission.dir, 'regression-proof-summary.json'), regressionProof);
419
421
  const tddOk = !regressionProof.required || (regressionProof.regression_test_added && regressionProof.regression_test_failed_before_fix && regressionProof.regression_test_passed_after_fix);
422
+ const narutoGateFullPassed = result.ok === true && nativeProofOk && finalAccepted && parallelRuntimeOk && tddOk && workGraph.ok === true && allocationPolicy.ok === true;
423
+ const narutoGateFullBlockers = [...(result.proof?.blockers || []), ...(parallelRuntimeOk ? [] : ['naruto_parallel_runtime_proof_below_gate']), ...(tddOk ? [] : ['tdd_evidence_missing']), ...(workGraph.blockers || []), ...(allocationPolicy.blockers || [])];
420
424
  await writeJsonAtomic(path.join(mission.dir, 'naruto-gate.json'), {
421
425
  schema: 'sks.naruto-gate.v1',
422
- passed: result.ok === true && nativeProofOk && finalAccepted && parallelRuntimeOk && tddOk,
426
+ passed: narutoGateFullPassed,
423
427
  mission_id: mission.id,
424
428
  clone_roster_built: true,
425
429
  clone_count: roster.agent_count,
@@ -429,8 +433,8 @@ async function narutoRun(parsed) {
429
433
  rebalance_ready: rebalancePolicy.ok === true,
430
434
  concurrency_governor_ready: true,
431
435
  active_pool_simulated: activePool.ok === true,
432
- verification_dag_ready: true,
433
- gpt_final_pack_ready: true,
436
+ verification_dag_ready: Array.isArray(verificationDag?.tasks),
437
+ gpt_final_pack_ready: Boolean(gptFinalPack?.schema),
434
438
  zellij_dashboard_ready: zellijDashboard.ok === true,
435
439
  native_agent_proof: nativeProofOk,
436
440
  parallel_runtime_proof: parallelRuntimeOk,
@@ -440,9 +444,10 @@ async function narutoRun(parsed) {
440
444
  regression_proof: 'regression-proof-summary.json',
441
445
  final_arbiter_accepted: finalAccepted,
442
446
  session_cleanup: result.proof?.all_sessions_closed === true || nativeProofOk,
443
- blockers: [...(result.proof?.blockers || []), ...(parallelRuntimeOk ? [] : ['naruto_parallel_runtime_proof_below_gate']), ...(tddOk ? [] : ['tdd_evidence_missing'])],
447
+ blockers: narutoGateFullBlockers,
444
448
  updated_at: nowIso()
445
449
  });
450
+ await closeWorkOrderLedgerForRouteResult(mission.dir, { ok: narutoGateFullPassed, blockers: narutoGateFullBlockers });
446
451
  const clones = result.roster?.agent_count ?? roster.agent_count;
447
452
  const localWorkerSummary = summarizeNarutoLocalWorkerResult(localWorker, result);
448
453
  // Finalizer policy: when local LLM workers contributed patches, the GPT
@@ -337,6 +337,45 @@ function mockPptFixtureGate(gate = {}) {
337
337
  blockers: ['ppt_fixture_mode_cannot_claim_real']
338
338
  };
339
339
  }
340
+ // The image-asset-ledger's `assets` array (see buildPptImageAssetLedger in ../ppt.ts) is the
341
+ // authoritative list of raster/bitmap image assets planned or generated for the deck; every
342
+ // entry in it is a raster PNG produced (or pending) via Codex App $imagegen/gpt-image-2. When the
343
+ // ledger omits `imagegen_evidence` outright, we must NOT assume the imagegen-required policy was
344
+ // satisfied. Instead derive a safe default from that asset list: any raster asset present forces
345
+ // the derived evidence to fail-closed (required + not passed) rather than silently pass.
346
+ function deriveImagegenEvidenceDefault(imageAssetLedger) {
347
+ if (imageAssetLedger?.imagegen_evidence)
348
+ return imageAssetLedger.imagegen_evidence;
349
+ const rasterAssets = Array.isArray(imageAssetLedger?.assets) ? imageAssetLedger.assets : [];
350
+ const rasterAssetCount = rasterAssets.length;
351
+ if (rasterAssetCount === 0) {
352
+ return {
353
+ schema: 'sks.ppt-imagegen-evidence.v1',
354
+ required: false,
355
+ passed: true,
356
+ blockers: [],
357
+ derived: true,
358
+ derivation_basis: { raster_asset_count: 0, source: 'derived_default_no_raster_assets' }
359
+ };
360
+ }
361
+ return {
362
+ schema: 'sks.ppt-imagegen-evidence.v1',
363
+ required: true,
364
+ passed: false,
365
+ required_count: imageAssetLedger?.required_count || rasterAssetCount,
366
+ generated_count: imageAssetLedger?.generated_count || 0,
367
+ generated_image_evidence: false,
368
+ assets: [],
369
+ blockers: ['imagegen_evidence_missing'],
370
+ derived: true,
371
+ derivation_basis: {
372
+ raster_asset_count: rasterAssetCount,
373
+ source: 'derived_default_raster_assets_present',
374
+ note: `imagegen_evidence section was absent from the image-asset-ledger while ${rasterAssetCount} raster asset(s) were present; failing closed instead of silently passing.`
375
+ },
376
+ passed_note: 'imagegen_evidence_missing: ledger omitted imagegen_evidence despite raster assets requiring Codex App imagegen verification'
377
+ };
378
+ }
340
379
  export async function evaluatePptGateArtifacts(dir, baseGate = {}) {
341
380
  const factLedger = await readJson(path.join(dir, PPT_FACT_LEDGER_ARTIFACT), null);
342
381
  const imageAssetLedger = await readJson(path.join(dir, PPT_IMAGE_ASSET_LEDGER_ARTIFACT), null);
@@ -370,7 +409,7 @@ export async function evaluatePptGateArtifacts(dir, baseGate = {}) {
370
409
  const renderReportPassed = renderReport?.passed === true;
371
410
  const factLedgerPassed = factLedger?.passed === true && Number(factLedger.unsupported_critical_claims_count || 0) === 0;
372
411
  const imageAssetLedgerPassed = imageAssetLedger?.passed === true;
373
- const imagegenEvidence = imageAssetLedger?.imagegen_evidence || { schema: 'sks.ppt-imagegen-evidence.v1', required: false, passed: true, blockers: [] };
412
+ const imagegenEvidence = deriveImagegenEvidenceDefault(imageAssetLedger);
374
413
  const imagegenEvidencePassed = imagegenEvidence?.required === true ? imagegenEvidence?.passed === true : true;
375
414
  const reviewLedgerPassed = reviewLedger?.passed === true;
376
415
  const iterationReportPassed = iterationReport?.passed === true;
@@ -14,6 +14,7 @@ import { maybeFinalizeRoute } from '../proof/auto-finalize.js';
14
14
  import { runNativeAgentOrchestrator } from '../agents/agent-orchestrator.js';
15
15
  import { flag, promptOf, readBoundedIntegerFlag, readFlagValue, readMaxCycles, resolveMissionId, safeReadTextFile } from './command-utils.js';
16
16
  import { runCodexAppHandoff, qaLoopShouldRequestAppHandoff } from '../codex-app/codex-app-handoff.js';
17
+ import { evaluateGate } from '../stop-gate/gate-evaluator.js';
17
18
  import { writeCodex0138CapabilityArtifacts } from '../codex-control/codex-0138-capability.js';
18
19
  import { writeCodexAccountUsageArtifacts } from '../usage/codex-account-usage.js';
19
20
  import { buildQaLoopBudgetPolicy, selectQaLoopEscalatedEffort } from '../qa-loop/qa-loop-budget-policy.js';
@@ -441,8 +442,10 @@ async function qaLoopStatus(args) {
441
442
  const desktop = await readJson(path.join(dir, 'qa-loop', 'app-handoff.json'), null);
442
443
  const desktopConfirmation = await readJson(path.join(dir, 'qa-loop', 'app-handoff-confirmation.json'), null);
443
444
  const desktopReviewComplete = desktopConfirmation?.verdict === 'pass';
445
+ const gateVerdict = await evaluateGate(root, id, 'qa-gate.json');
444
446
  if (flag(args, '--json'))
445
- return console.log(JSON.stringify({ mission, state, qa: status, desktop_app_handoff: desktop, desktop_app_confirmation: desktopConfirmation, desktop_review_complete: desktopReviewComplete, native_agent_plan: nativeAgentPlan, agent_sessions: agentSessions?.sessions || null }, null, 2));
447
+ return console.log(JSON.stringify({ mission, state, qa: status, desktop_app_handoff: desktop, desktop_app_confirmation: desktopConfirmation, desktop_review_complete: desktopReviewComplete, native_agent_plan: nativeAgentPlan, agent_sessions: agentSessions?.sessions || null, gate_verdict: gateVerdict }, null, 2));
448
+ console.log(gateVerdict.verdict);
446
449
  console.log('SKS QA-LOOP Status\n');
447
450
  console.log(`Mission: ${id}`);
448
451
  console.log(`Phase: ${state.phase || mission.phase}`);
@@ -27,7 +27,7 @@ export async function releaseCommand(args = []) {
27
27
  await writeTextAtomic(stdoutPath, String(result.stdout || ''));
28
28
  await writeTextAtomic(stderrPath, String(result.stderr || ''));
29
29
  const readiness = await findReleaseReadinessReport(root);
30
- const requiredSections = ['five_lane_review', 'integration_evidence', 'session_cleanup'];
30
+ const requiredSections = [];
31
31
  const missingSections = requiredSections.filter((section) => readiness.report?.[section] == null);
32
32
  if (readiness.report)
33
33
  await writeJsonAtomic(path.join(mission.dir, 'release-readiness-report.json'), readiness.report);
@@ -53,14 +53,14 @@ export async function releaseCommand(args = []) {
53
53
  stdout_tail: tail(String(result.stdout || '')),
54
54
  stderr_tail: tail(String(result.stderr || ''))
55
55
  };
56
+ if (!report.ok)
57
+ process.exitCode = result.status || 1;
56
58
  if (json)
57
59
  return printJson(report);
58
60
  if (result.stdout)
59
61
  process.stdout.write(result.stdout);
60
62
  if (result.stderr)
61
63
  process.stderr.write(result.stderr);
62
- if (!report.ok)
63
- process.exitCode = result.status || 1;
64
64
  return report;
65
65
  }
66
66
  async function findReleaseReadinessReport(root) {
@@ -23,6 +23,7 @@ import { readImplementationBlueprint, validateImplementationBlueprint } from '..
23
23
  import { readExperimentPlan, validateExperimentPlan } from '../research/experiment-plan.js';
24
24
  import { readReplicationPack, validateReplicationPack } from '../research/replication-pack.js';
25
25
  import { readResearchFinalReview } from '../research/research-final-reviewer.js';
26
+ import { evaluateGate } from '../stop-gate/gate-evaluator.js';
26
27
  const RESEARCH_DEFAULT_MAX_CYCLES = 12;
27
28
  const RESEARCH_DEFAULT_CYCLE_TIMEOUT_MINUTES = 120;
28
29
  const RESEARCH_MIN_CYCLE_TIMEOUT_MINUTES = 15;
@@ -360,6 +361,8 @@ async function researchStatus(args) {
360
361
  const { dir, mission } = await loadMission(root, id);
361
362
  const state = await readJson(stateFile(root), {});
362
363
  const gate = await readJson(path.join(dir, 'research-gate.evaluated.json'), await readJson(path.join(dir, 'research-gate.json'), null));
364
+ const gateVerdict = await evaluateGate(root, id, 'research-gate.json');
365
+ console.log(gateVerdict.verdict);
363
366
  const ledger = await readJson(path.join(dir, 'novelty-ledger.json'), null);
364
367
  const sourceLedger = await readJson(path.join(dir, 'source-ledger.json'), null);
365
368
  const agentLedger = await readJson(path.join(dir, 'agent-ledger.json'), null);
@@ -398,6 +401,7 @@ async function researchStatus(args) {
398
401
  autoresearch_cycle_policy: plan?.autoresearch_cycle_policy || null,
399
402
  legacy_alias_policy: plan?.native_agent_plan?.legacy_artifact_alias_policy || null,
400
403
  gate,
404
+ gate_verdict: gateVerdict,
401
405
  novelty_entries: ledger?.entries?.length ?? null,
402
406
  source_entries: sourceLedger?.sources?.length ?? null,
403
407
  source_layers_required: sourceLayerRows.length || gate?.metrics?.source_layers_required || gate?.source_layers_required || null,
@@ -36,6 +36,8 @@ export async function evaluateLocalGate(input) {
36
36
  blockers.push('gate_not_passed');
37
37
  if (gate.ok === false)
38
38
  blockers.push('gate_ok_false');
39
+ if (gate.execution_class === 'mock_fixture')
40
+ blockers.push('gate_execution_class_mock_fixture');
39
41
  if (Array.isArray(gate.blockers) && gate.blockers.length)
40
42
  blockers.push(...gate.blockers.map(String));
41
43
  if (Array.isArray(gate.missing_fields) && gate.missing_fields.length)