sneakoscope 0.9.18 → 0.9.20

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 (101) hide show
  1. package/README.md +33 -10
  2. package/bin/sks.mjs +20 -3
  3. package/crates/sks-core/Cargo.lock +1 -1
  4. package/crates/sks-core/Cargo.toml +1 -1
  5. package/crates/sks-core/src/main.rs +5 -5
  6. package/package.json +59 -2
  7. package/src/cli/command-registry.mjs +85 -42
  8. package/src/cli/help-fast.mjs +31 -0
  9. package/src/core/bench.mjs +97 -0
  10. package/src/core/commands/bench-command.mjs +49 -0
  11. package/src/core/commands/paths-command.mjs +17 -0
  12. package/src/core/commands/rollback-command.mjs +42 -0
  13. package/src/core/commands/run-command.mjs +89 -0
  14. package/src/core/commands/scouts-command.mjs +22 -4
  15. package/src/core/commands/status-command.mjs +51 -0
  16. package/src/core/commands/trust-command.mjs +47 -0
  17. package/src/core/evidence/evidence-dedupe.mjs +19 -0
  18. package/src/core/evidence/evidence-freshness.mjs +34 -0
  19. package/src/core/evidence/evidence-proof-linker.mjs +20 -0
  20. package/src/core/evidence/evidence-redaction.mjs +9 -0
  21. package/src/core/evidence/evidence-router.mjs +186 -0
  22. package/src/core/evidence/evidence-schema.mjs +105 -0
  23. package/src/core/evidence/evidence-store.mjs +73 -0
  24. package/src/core/feature-fixtures.mjs +57 -32
  25. package/src/core/feature-registry.mjs +42 -2
  26. package/src/core/fsx.mjs +1 -1
  27. package/src/core/managed-paths.mjs +65 -0
  28. package/src/core/pipeline/active-context.mjs +1 -1
  29. package/src/core/pipeline/pipeline-plan-writer.mjs +1 -1
  30. package/src/core/pipeline/plan-schema.mjs +1 -1
  31. package/src/core/pipeline/prompt-context.mjs +1 -1
  32. package/src/core/pipeline/route-prep.mjs +1 -1
  33. package/src/core/pipeline/scout-stage-policy.mjs +1 -1
  34. package/src/core/pipeline/stage-policy.mjs +1 -1
  35. package/src/core/pipeline/stop-gate.mjs +1 -1
  36. package/src/core/pipeline/validation.mjs +1 -1
  37. package/src/core/pipeline-internals/runtime-core.mjs +1693 -0
  38. package/src/core/pipeline-runtime.mjs +22 -1693
  39. package/src/core/proof/auto-finalize.mjs +1 -1
  40. package/src/core/proof/proof-writer.mjs +2 -0
  41. package/src/core/proof/route-adapter.mjs +24 -1
  42. package/src/core/routes.mjs +6 -0
  43. package/src/core/rust-accelerator.mjs +4 -1
  44. package/src/core/scouts/engines/codex-app-subagent-engine.mjs +66 -5
  45. package/src/core/scouts/engines/codex-exec-parallel-engine.mjs +18 -4
  46. package/src/core/scouts/engines/scout-engine-base.mjs +5 -1
  47. package/src/core/scouts/engines/scout-engine-detect.mjs +7 -3
  48. package/src/core/scouts/engines/tmux-lane-cleanup.mjs +16 -0
  49. package/src/core/scouts/engines/tmux-lane-engine.mjs +72 -5
  50. package/src/core/scouts/engines/tmux-lane-watcher.mjs +26 -0
  51. package/src/core/scouts/scout-consensus.mjs +31 -0
  52. package/src/core/scouts/scout-output-fixtures.mjs +27 -0
  53. package/src/core/scouts/scout-output-normalizer.mjs +4 -0
  54. package/src/core/scouts/scout-output-parser.mjs +266 -0
  55. package/src/core/scouts/scout-output-validator.mjs +3 -0
  56. package/src/core/scouts/scout-readonly-guard.mjs +23 -2
  57. package/src/core/scouts/scout-runner.mjs +69 -11
  58. package/src/core/trust-kernel/completion-contract.mjs +37 -0
  59. package/src/core/trust-kernel/evidence-router.mjs +4 -0
  60. package/src/core/trust-kernel/route-contract.mjs +66 -0
  61. package/src/core/trust-kernel/route-state-machine.mjs +29 -0
  62. package/src/core/trust-kernel/trust-kernel-schema.mjs +23 -0
  63. package/src/core/trust-kernel/trust-report.mjs +111 -0
  64. package/src/core/trust-kernel/trust-status.mjs +16 -0
  65. package/src/core/version-manager.mjs +9 -0
  66. package/src/core/version.mjs +1 -1
  67. package/src/core/wiki-image/validation.mjs +2 -0
  68. package/src/commands/aliases.mjs +0 -2
  69. package/src/commands/autoresearch.mjs +0 -5
  70. package/src/commands/bootstrap.mjs +0 -2
  71. package/src/commands/code-structure.mjs +0 -5
  72. package/src/commands/commands.mjs +0 -5
  73. package/src/commands/computer-use.mjs +0 -5
  74. package/src/commands/context7.mjs +0 -5
  75. package/src/commands/db.mjs +0 -6
  76. package/src/commands/deps.mjs +0 -5
  77. package/src/commands/dfix.mjs +0 -2
  78. package/src/commands/dollar-commands.mjs +0 -2
  79. package/src/commands/eval.mjs +0 -5
  80. package/src/commands/fix-path.mjs +0 -2
  81. package/src/commands/gc.mjs +0 -2
  82. package/src/commands/goal.mjs +0 -5
  83. package/src/commands/gx.mjs +0 -5
  84. package/src/commands/harness.mjs +0 -5
  85. package/src/commands/image-ux-review.mjs +0 -5
  86. package/src/commands/init.mjs +0 -2
  87. package/src/commands/memory.mjs +0 -5
  88. package/src/commands/postinstall.mjs +0 -2
  89. package/src/commands/ppt.mjs +0 -5
  90. package/src/commands/qa-loop.mjs +0 -5
  91. package/src/commands/quickstart.mjs +0 -2
  92. package/src/commands/reasoning.mjs +0 -2
  93. package/src/commands/research.mjs +0 -5
  94. package/src/commands/selftest.mjs +0 -2
  95. package/src/commands/setup.mjs +0 -2
  96. package/src/commands/skill-dream.mjs +0 -5
  97. package/src/commands/stats.mjs +0 -2
  98. package/src/commands/team.mjs +0 -2
  99. package/src/commands/update-check.mjs +0 -2
  100. package/src/commands/usage.mjs +0 -2
  101. package/src/commands/validate-artifacts.mjs +0 -2
package/README.md CHANGED
@@ -2,22 +2,37 @@
2
2
 
3
3
  Fast legacy-free proof-first Codex trust layer with image-based Voxel TriWiki.
4
4
 
5
- Sneakoscope Codex (`sks`) is a Codex CLI/App harness that makes repeatable Codex work auditable. `0.9.18` makes route execution hermetic and evidence-strict: Five-Scout intake can use real Codex/tmux engines when available, route E2E runs in temp project roots, feature fixtures no longer receive implicit static-pass fallback, and pipeline planning is exposed through split policy modules with a facade compatibility layer.
5
+ Sneakoscope Codex (`sks`) is a Codex CLI/App harness that makes repeatable Codex work auditable. `0.9.20` adds the SKS Trust Kernel: serious route finalization now writes Completion Proof, a route completion contract, an evidence index, and a trust report through one release-gated core loop.
6
+
7
+ SKS does not try to clone every other harness. It focuses on one thing: making Codex work auditable, visual-evidence-bound, safety-gated, and reproducible through Completion Proof.
6
8
 
7
9
  ![Sneakoscope Codex architecture and pipeline](https://raw.githubusercontent.com/mandarange/Sneakoscope-Codex/dev/docs/assets/sneakoscope-architecture-pipeline.jpg)
8
10
 
9
- ## 0.9.18 Current Release
11
+ ## 0.9.20 Current Release
12
+
13
+ 0.9.20 strengthens the core trust loop instead of expanding route names. The new `sks trust` surface validates `route-completion-contract.json`, `evidence-index.json`, stale/mock/static evidence rules, and Completion Proof status. `sks run` and `sks status` give novices a smaller control surface while preserving the existing Team, QA, Research, PPT, Image UX, DB, Wiki, GX, and Goal routes.
14
+
15
+ Highlights:
16
+
17
+ - `sks trust report latest --json`, `sks trust validate latest --json`, and `sks trust explain latest` expose the route trust kernel.
18
+ - Route finalization writes mission-local `route-completion-contract.json`, `evidence-index.json`, `evidence.jsonl`, and `trust-report.json`.
19
+ - Mock/static evidence stays `verified_partial` or lower; it cannot support a real `verified` route claim.
20
+ - Visual route validation blocks stale image/voxel anchors.
21
+ - `sks bench core --json` writes `.sneakoscope/reports/performance/core-bench.json` and `.md`.
22
+ - `sks paths managed --json` and `sks rollback list --json` document SKS-owned project paths and explicit rollback actions.
23
+
24
+ ## 0.9.19 Release
10
25
 
11
- 0.9.18 makes SKS route execution hermetic and evidence-strict. Five-Scout intake can run through real Codex/tmux engines when available, falls back honestly when not, and never claims speedup from mock/static evidence. E2E route tests run in isolated temp project roots. Feature fixtures no longer receive implicit static-pass fallback; every feature declares an explicit fixture. Pipeline architecture is split into stage policy, scout policy, prompt context, active context, and stop-gate modules.
26
+ 0.9.19 makes SKS Scout evidence parse-bound and package-install verified. Real Codex/tmux/Codex App subagent engines must write parseable scout output before consensus can use them as primary evidence. If an engine is unavailable or output cannot be parsed, SKS records a blocked or verified-partial result instead of substituting static evidence. Packed package checks now cover temp install, npx one-shot, and global shim behavior.
12
27
 
13
28
  Highlights:
14
29
 
15
- - Serious route mock/fixture commands call `maybeFinalizeRoute`, so Team, QA-LOOP, Research, PPT, Image UX Review, Computer Use, DB, Wiki, and GX fixtures produce route-local `completion-proof.json` without a separate repair/finalize step.
16
- - `sks scouts engines --json` reports Codex exec, tmux, Codex App subagent, local static, and sequential fallback availability with blockers.
17
- - Scout read-only guards snapshot source state and allow only mission-local `scout-*` artifacts plus scout reports.
18
- - E2E route tests run actual route commands inside isolated temp roots instead of sharing the source checkout `.sneakoscope`.
19
- - Feature fixtures execute deterministic allowlisted commands in hermetic temp roots and validate artifacts generated by those commands, including mission-local proof, visual ledgers, DB reports, and GX/Wiki evidence.
20
- - `npm run release:check` includes `pipeline-budget:check`, `scout-engines:check`, strict scout validation, and hermetic fixture execution.
30
+ - Real Scout outputs are parsed from pure JSON, fenced JSON, `SCOUT_RESULT_JSON:` markdown, or final JSON blocks into `sks.scout-result.v1`.
31
+ - `scout-consensus.json` records whether primary evidence came from parsed real outputs or local static fixtures.
32
+ - `tmux-lanes` has an opt-in session/window/watcher/cleanup path; release gates skip or block honestly when live tmux/Codex is unavailable.
33
+ - Codex App subagents require a local `sks.codex-app-subagents-capability.v1` descriptor; `SKS_CODEX_APP_SUBAGENTS=1` alone is not enough.
34
+ - `npm run release:check` includes `pipeline-runtime:check`, `feature-quality:check`, `scouts:parser-check`, and `blackbox:check`.
35
+ - Feature fixtures report `runtime_verified`, `runtime_mock_verified`, `integration_optional`, `static_contract`, and `missing` counts.
21
36
  - `sks rust status|smoke --json` reports optional Rust availability, detects stale native binaries, and proves JS fallback parity when native Rust is missing or version-mismatched.
22
37
  - `npm run release:check` includes `route-modularity:check`, `command-budget:check`, and `feature-fixtures:strict`.
23
38
 
@@ -34,10 +49,16 @@ Highlights:
34
49
 
35
50
  Learn more:
36
51
  - Completion Proof: [docs/completion-proof.md](docs/completion-proof.md)
52
+ - Trust Kernel: [docs/trust-kernel.md](docs/trust-kernel.md)
53
+ - Core dominance: [docs/core-dominance.md](docs/core-dominance.md)
54
+ - Performance budgets: [docs/performance-budgets.md](docs/performance-budgets.md)
37
55
  - Five-Scout Pipeline: [docs/five-scout-pipeline.md](docs/five-scout-pipeline.md)
38
56
  - Image Voxel TriWiki: [docs/image-voxel-ledger.md](docs/image-voxel-ledger.md)
39
57
  - Route finalization: [docs/route-finalization.md](docs/route-finalization.md)
40
58
  - Feature fixtures: [docs/feature-fixtures.md](docs/feature-fixtures.md)
59
+ - Managed paths: [docs/managed-paths.md](docs/managed-paths.md)
60
+ - Rollback: [docs/rollback.md](docs/rollback.md)
61
+ - Known gaps: [docs/known-gaps.md](docs/known-gaps.md)
41
62
  - Scout engines: [docs/scout-engines.md](docs/scout-engines.md)
42
63
  - Hermetic E2E: [docs/testing-hermetic-e2e.md](docs/testing-hermetic-e2e.md)
43
64
  - Pipeline architecture: [docs/pipeline-architecture.md](docs/pipeline-architecture.md)
@@ -51,6 +72,8 @@ Learn more:
51
72
  npm i -g sneakoscope
52
73
  sks root
53
74
  sks doctor
75
+ sks status
76
+ sks trust report latest
54
77
  sks codex-app check
55
78
  sks selftest --mock
56
79
  sks rust smoke --json
@@ -60,7 +83,7 @@ sks rust smoke --json
60
83
 
61
84
  1. Completion Proof for every serious route
62
85
  2. Image Voxel TriWiki anchors and relations for every visual route
63
- 3. Codex App, codex-lb, hooks, Rust fallback parity, DB, route modularity, and generated fixtures verified by release gates
86
+ 3. Route contracts, evidence indexes, trust reports, Codex App, codex-lb, hooks, Rust fallback parity, DB, route modularity, and generated fixtures verified by release gates
64
87
 
65
88
  ## Install Options
66
89
 
package/bin/sks.mjs CHANGED
@@ -1,8 +1,25 @@
1
1
  #!/usr/bin/env node
2
- import { main } from '../src/cli/main.mjs';
3
2
 
4
- main(process.argv.slice(2)).catch((err) => {
3
+ const FAST_PACKAGE_VERSION = '0.9.20';
4
+ const args = process.argv.slice(2);
5
+
6
+ try {
7
+ if (args[0] === '--version' || args[0] === '-v' || args[0] === 'version') {
8
+ console.log(`sneakoscope ${FAST_PACKAGE_VERSION}`);
9
+ } else if (args[0] === 'help' || args[0] === '--help' || args[0] === '-h') {
10
+ if (args.length > 1) {
11
+ const { helpCommand } = await import('../src/core/commands/basic-cli.mjs');
12
+ await helpCommand(args.slice(1));
13
+ } else {
14
+ const { helpFast } = await import('../src/cli/help-fast.mjs');
15
+ helpFast();
16
+ }
17
+ } else {
18
+ const { main } = await import('../src/cli/main.mjs');
19
+ await main(args);
20
+ }
21
+ } catch (err) {
5
22
  const message = err && err.stack ? err.stack : String(err);
6
23
  console.error(message);
7
24
  process.exitCode = 1;
8
- });
25
+ }
@@ -76,7 +76,7 @@ dependencies = [
76
76
 
77
77
  [[package]]
78
78
  name = "sks-core"
79
- version = "0.9.18"
79
+ version = "0.9.20"
80
80
  dependencies = [
81
81
  "serde_json",
82
82
  ]
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "sks-core"
3
- version = "0.9.18"
3
+ version = "0.9.20"
4
4
  edition = "2021"
5
5
 
6
6
  [dependencies]
@@ -4,7 +4,7 @@ use std::io::{self, Read, Seek, SeekFrom};
4
4
  fn main() {
5
5
  let mut args = std::env::args().skip(1);
6
6
  match args.next().as_deref() {
7
- Some("--version") => println!("sks-rs 0.9.18"),
7
+ Some("--version") => println!("sks-rs 0.9.20"),
8
8
  Some("compact-info") => {
9
9
  let mut input = String::new();
10
10
  let _ = io::stdin().read_to_string(&mut input);
@@ -28,7 +28,7 @@ fn main() {
28
28
  }
29
29
  }
30
30
  }
31
- Some("image-hash") => {
31
+ Some("image-hash") | Some("image-voxel-index") => {
32
32
  let path = args.next().unwrap_or_default();
33
33
  match image_hash(&path) {
34
34
  Ok((sha, bytes)) => println!("{{\"ok\":true,\"engine\":\"rust\",\"path\":\"{}\",\"sha256\":\"{}\",\"bytes\":{}}}", json_escape(&path), sha, bytes),
@@ -38,7 +38,7 @@ fn main() {
38
38
  }
39
39
  }
40
40
  }
41
- Some("voxel-validate") => {
41
+ Some("voxel-validate") | Some("image-voxel-validate-fast") => {
42
42
  let path = args.next().unwrap_or_default();
43
43
  let mut require_anchors = false;
44
44
  let mut require_relations = false;
@@ -58,7 +58,7 @@ fn main() {
58
58
  }
59
59
  }
60
60
  }
61
- Some("secret-scan") => {
61
+ Some("secret-scan") | Some("evidence-secret-scan") => {
62
62
  let path = args.next().unwrap_or_default();
63
63
  match std::fs::read_to_string(&path) {
64
64
  Ok(text) => {
@@ -75,7 +75,7 @@ fn main() {
75
75
  }
76
76
  }
77
77
  _ => {
78
- eprintln!("sks-rs optional accelerator. Commands: --version, compact-info, jsonl-tail, secret-scan, image-hash, voxel-validate");
78
+ eprintln!("sks-rs optional accelerator. Commands: --version, compact-info, jsonl-tail, secret-scan, evidence-secret-scan, image-hash, image-voxel-index, voxel-validate, image-voxel-validate-fast");
79
79
  std::process::exit(2);
80
80
  }
81
81
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sneakoscope",
3
3
  "displayName": "ㅅㅋㅅ",
4
- "version": "0.9.18",
4
+ "version": "0.9.20",
5
5
  "description": "Sneakoscope Codex: fast proof-first Codex trust layer with image-based Voxel TriWiki.",
6
6
  "type": "module",
7
7
  "homepage": "https://github.com/mandarange/Sneakoscope-Codex#readme",
@@ -23,6 +23,49 @@
23
23
  "files": [
24
24
  "bin",
25
25
  "src",
26
+ "!src/commands/aliases.mjs",
27
+ "!src/commands/autoresearch.mjs",
28
+ "!src/commands/bench.mjs",
29
+ "!src/commands/bootstrap.mjs",
30
+ "!src/commands/code-structure.mjs",
31
+ "!src/commands/commands.mjs",
32
+ "!src/commands/computer-use.mjs",
33
+ "!src/commands/context7.mjs",
34
+ "!src/commands/db.mjs",
35
+ "!src/commands/deps.mjs",
36
+ "!src/commands/dfix.mjs",
37
+ "!src/commands/dollar-commands.mjs",
38
+ "!src/commands/eval.mjs",
39
+ "!src/commands/fix-path.mjs",
40
+ "!src/commands/gc.mjs",
41
+ "!src/commands/goal.mjs",
42
+ "!src/commands/gx.mjs",
43
+ "!src/commands/harness.mjs",
44
+ "!src/commands/image-ux-review.mjs",
45
+ "!src/commands/init.mjs",
46
+ "!src/commands/memory.mjs",
47
+ "!src/commands/paths.mjs",
48
+ "!src/commands/postinstall.mjs",
49
+ "!src/commands/ppt.mjs",
50
+ "!src/commands/qa-loop.mjs",
51
+ "!src/commands/quickstart.mjs",
52
+ "!src/commands/reasoning.mjs",
53
+ "!src/commands/research.mjs",
54
+ "!src/commands/rollback.mjs",
55
+ "!src/commands/run.mjs",
56
+ "!src/commands/selftest.mjs",
57
+ "!src/commands/setup.mjs",
58
+ "!src/commands/skill-dream.mjs",
59
+ "!src/commands/stats.mjs",
60
+ "!src/commands/status.mjs",
61
+ "!src/commands/team.mjs",
62
+ "!src/commands/trust.mjs",
63
+ "!src/commands/update-check.mjs",
64
+ "!src/commands/usage.mjs",
65
+ "!src/commands/validate-artifacts.mjs",
66
+ "!src/core/pipeline/route-prep-*.mjs",
67
+ "!src/core/pipeline/prompt-context-*.mjs",
68
+ "!src/core/pipeline/stop-gate-*.mjs",
26
69
  "crates/sks-core/Cargo.lock",
27
70
  "crates/sks-core/Cargo.toml",
28
71
  "crates/sks-core/src",
@@ -41,18 +84,27 @@
41
84
  "changelog:check": "node ./scripts/changelog-check.mjs",
42
85
  "cli-entrypoint:check": "node ./scripts/check-cli-entrypoint.mjs",
43
86
  "legacy-free:check": "node ./scripts/check-legacy-free.mjs",
87
+ "architecture:check": "node ./scripts/check-architecture.mjs",
44
88
  "route-modularity:check": "node ./scripts/check-route-modularity.mjs",
45
89
  "command-budget:check": "node ./scripts/check-command-module-budget.mjs",
46
90
  "pipeline-budget:check": "node ./scripts/check-pipeline-budget.mjs",
91
+ "pipeline-runtime:check": "node ./scripts/check-pipeline-runtime.mjs",
47
92
  "sizecheck": "node ./scripts/sizecheck.mjs",
48
93
  "registry:check": "node ./scripts/release-registry-check.mjs",
49
94
  "feature:check": "node ./bin/sks.mjs features check --json",
95
+ "feature-quality:check": "node ./scripts/check-feature-quality.mjs",
50
96
  "all-features:selftest": "node ./bin/sks.mjs all-features selftest --mock --json",
51
97
  "all-features:execute-fixtures": "node ./bin/sks.mjs all-features selftest --mock --execute-fixtures --strict-artifacts --json",
52
98
  "feature-fixtures:strict": "node ./bin/sks.mjs all-features selftest --mock --execute-fixtures --strict-artifacts --hermetic --json",
53
99
  "scout-engines:check": "node ./bin/sks.mjs scouts engines --json",
100
+ "scouts:parser-check": "node --test \"test/unit/scout-output-parser.test.mjs\"",
54
101
  "scouts:selftest": "node ./bin/sks.mjs scouts run latest --engine local-static --mock --json",
55
102
  "scouts:check": "node ./bin/sks.mjs scouts validate latest --strict --json",
103
+ "trust:check": "node ./bin/sks.mjs trust validate latest --json || node ./scripts/trust-fixture-check.mjs",
104
+ "evidence:check": "node ./scripts/evidence-fixture-check.mjs",
105
+ "safety:check": "node ./scripts/safety-check.mjs",
106
+ "chaos:check": "node --test \"test/chaos/**/*.test.mjs\"",
107
+ "bench:core": "node ./bin/sks.mjs bench core --json",
56
108
  "perf:cold-start": "node ./bin/sks.mjs perf cold-start --json",
57
109
  "perf:gate": "node ./scripts/perf-gate.mjs",
58
110
  "test": "node --test \"test/**/*.test.mjs\"",
@@ -60,10 +112,15 @@
60
112
  "test:integration:mock": "node --test \"test/integration/**/*.test.mjs\"",
61
113
  "test:e2e:mock": "node --test \"test/e2e/**/*.test.mjs\"",
62
114
  "test:real-scouts": "node --test \"test/real/**/*.test.mjs\"",
115
+ "blackbox:pack-install": "node ./scripts/blackbox-pack-install.mjs",
116
+ "blackbox:npx": "node ./scripts/blackbox-npx-one-shot.mjs",
117
+ "blackbox:global-shim": "node ./scripts/blackbox-global-shim.mjs",
118
+ "blackbox:matrix": "node ./scripts/blackbox-matrix.mjs",
119
+ "blackbox:check": "npm run blackbox:pack-install && npm run blackbox:npx && npm run blackbox:global-shim",
63
120
  "rust:check": "cargo check --manifest-path crates/sks-core/Cargo.toml",
64
121
  "rust:smoke": "node ./scripts/rust-smoke.mjs",
65
122
  "coverage": "node --experimental-test-coverage --test \"test/**/*.test.mjs\"",
66
- "release:check": "npm run repo-audit && npm run changelog:check && npm run cli-entrypoint:check && npm run legacy-free:check && npm run route-modularity:check && npm run command-budget:check && npm run pipeline-budget:check && npm run packcheck && npm run feature:check && npm run all-features:selftest && npm run scout-engines:check && npm run scouts:selftest && npm run scouts:check && npm run feature-fixtures:strict && npm run selftest && npm run test:unit && npm run test:integration:mock && npm run test:e2e:mock && npm run rust:check && npm run rust:smoke && npm run perf:gate && npm run sizecheck && npm run registry:check",
123
+ "release:check": "npm run repo-audit && npm run changelog:check && npm run cli-entrypoint:check && npm run legacy-free:check && npm run architecture:check && npm run route-modularity:check && npm run command-budget:check && npm run pipeline-budget:check && npm run pipeline-runtime:check && npm run packcheck && npm run feature:check && npm run feature-quality:check && npm run all-features:selftest && npm run scout-engines:check && npm run scouts:parser-check && npm run scouts:selftest && npm run scouts:check && npm run trust:check && npm run evidence:check && npm run safety:check && npm run chaos:check && npm run bench:core && npm run feature-fixtures:strict && npm run selftest && npm run test:unit && npm run test:integration:mock && npm run test:e2e:mock && npm run rust:check && npm run rust:smoke && npm run perf:gate && npm run blackbox:matrix && npm run blackbox:check && npm run sizecheck && npm run registry:check",
67
124
  "publish:dry": "npm run release:check && npm --cache /tmp/sks-npm-cache publish --dry-run --registry https://registry.npmjs.org/ --access public",
68
125
  "publish:npm": "npm --cache /tmp/sks-npm-cache publish --registry https://registry.npmjs.org/ --access public",
69
126
  "prepublishOnly": "npm run release:check && node ./scripts/release-registry-check.mjs --require-unpublished"
@@ -1,19 +1,60 @@
1
+ function argsCommand(loader, exportName) {
2
+ return async () => {
3
+ const mod = await loader();
4
+ return { run: (_command, args = []) => mod[exportName](args) };
5
+ };
6
+ }
7
+
8
+ function noArgsCommand(loader, exportName) {
9
+ return async () => {
10
+ const mod = await loader();
11
+ return { run: () => mod[exportName]() };
12
+ };
13
+ }
14
+
15
+ function commandArgsCommand(loader, exportName) {
16
+ return async () => {
17
+ const mod = await loader();
18
+ return { run: (command, args = []) => mod[exportName](command, args) };
19
+ };
20
+ }
21
+
22
+ function subcommand(loader, exportName, fallbackSubcommand) {
23
+ return async () => {
24
+ const mod = await loader();
25
+ return {
26
+ run: (_command, args = []) => {
27
+ const [subcommandName = fallbackSubcommand, ...rest] = args;
28
+ return mod[exportName](subcommandName, rest);
29
+ }
30
+ };
31
+ };
32
+ }
33
+
34
+ const basicArgs = (exportName) => argsCommand(() => import('../core/commands/basic-cli.mjs'), exportName);
35
+ const basicNoArgs = (exportName) => noArgsCommand(() => import('../core/commands/basic-cli.mjs'), exportName);
36
+ const gcArgs = (exportName) => argsCommand(() => import('../core/commands/gc-command.mjs'), exportName);
37
+
1
38
  export const COMMANDS = {
2
39
  help: { maturity: 'stable', summary: 'Show SKS help', lazy: () => import('../commands/help.mjs') },
3
40
  version: { maturity: 'stable', summary: 'Show SKS version', lazy: () => import('../commands/version.mjs') },
4
- commands: { maturity: 'stable', summary: 'List SKS commands', lazy: () => import('../commands/commands.mjs') },
41
+ commands: { maturity: 'stable', summary: 'List SKS commands', lazy: basicArgs('commandsCommand') },
42
+ run: { maturity: 'beta', summary: 'Classify and start a task through the SKS trust kernel', lazy: argsCommand(() => import('../core/commands/run-command.mjs'), 'runCommand') },
43
+ status: { maturity: 'stable', summary: 'Show concise active mission and trust status', lazy: argsCommand(() => import('../core/commands/status-command.mjs'), 'statusCommand') },
5
44
  root: { maturity: 'stable', summary: 'Show active SKS root', lazy: () => import('../commands/root.mjs') },
6
- 'update-check': { maturity: 'stable', summary: 'Check npm package freshness', lazy: () => import('../commands/update-check.mjs') },
7
- wizard: { maturity: 'stable', summary: 'Open setup wizard help', lazy: () => import('../commands/quickstart.mjs') },
8
- usage: { maturity: 'stable', summary: 'Show focused usage topic', lazy: () => import('../commands/usage.mjs') },
9
- quickstart: { maturity: 'stable', summary: 'Show quickstart flow', lazy: () => import('../commands/quickstart.mjs') },
10
- setup: { maturity: 'stable', summary: 'Initialize SKS state', lazy: () => import('../commands/setup.mjs') },
11
- bootstrap: { maturity: 'stable', summary: 'Initialize SKS project files', lazy: () => import('../commands/bootstrap.mjs') },
12
- init: { maturity: 'stable', summary: 'Initialize local control surface', lazy: () => import('../commands/init.mjs') },
13
- deps: { maturity: 'stable', summary: 'Check local dependencies', lazy: () => import('../commands/deps.mjs') },
14
- 'fix-path': { maturity: 'stable', summary: 'Repair hook command paths', lazy: () => import('../commands/fix-path.mjs') },
45
+ 'update-check': { maturity: 'stable', summary: 'Check npm package freshness', lazy: basicArgs('updateCheckCommand') },
46
+ wizard: { maturity: 'stable', summary: 'Open setup wizard help', lazy: basicNoArgs('quickstartCommand') },
47
+ usage: { maturity: 'stable', summary: 'Show focused usage topic', lazy: basicArgs('usageCommand') },
48
+ quickstart: { maturity: 'stable', summary: 'Show quickstart flow', lazy: basicNoArgs('quickstartCommand') },
49
+ setup: { maturity: 'stable', summary: 'Initialize SKS state', lazy: basicArgs('setupCommand') },
50
+ bootstrap: { maturity: 'stable', summary: 'Initialize SKS project files', lazy: basicArgs('bootstrapCommand') },
51
+ init: { maturity: 'stable', summary: 'Initialize local control surface', lazy: basicArgs('initCommand') },
52
+ deps: { maturity: 'stable', summary: 'Check local dependencies', lazy: subcommand(() => import('../core/commands/basic-cli.mjs'), 'depsCommand', 'check') },
53
+ 'fix-path': { maturity: 'stable', summary: 'Repair hook command paths', lazy: basicArgs('fixPathCommand') },
15
54
  doctor: { maturity: 'stable', summary: 'Check and repair SKS install', lazy: () => import('../commands/doctor.mjs') },
16
- postinstall: { maturity: 'stable', summary: 'Run postinstall bootstrap', lazy: () => import('../commands/postinstall.mjs') },
55
+ paths: { maturity: 'beta', summary: 'Inspect SKS managed paths', lazy: argsCommand(() => import('../core/commands/paths-command.mjs'), 'pathsCommand') },
56
+ rollback: { maturity: 'beta', summary: 'List or apply managed-path rollback actions', lazy: argsCommand(() => import('../core/commands/rollback-command.mjs'), 'rollbackCommand') },
57
+ postinstall: { maturity: 'stable', summary: 'Run postinstall bootstrap', lazy: basicArgs('postinstallCommand') },
17
58
  'codex-app': { maturity: 'beta', summary: 'Check Codex App readiness', lazy: () => import('../commands/codex-app.mjs') },
18
59
  'codex-lb': { maturity: 'beta', summary: 'Inspect codex-lb status and circuit health', lazy: () => import('../commands/codex-lb.mjs') },
19
60
  auth: { maturity: 'beta', summary: 'Alias for codex-lb auth commands', lazy: () => import('../commands/codex-lb.mjs') },
@@ -24,24 +65,24 @@ export const COMMANDS = {
24
65
  'mad-sks': { maturity: 'beta', summary: 'MAD-SKS scoped permission modifier', lazy: () => import('../commands/mad-sks.mjs') },
25
66
  'auto-review': { maturity: 'beta', summary: 'Manage auto-review profile', lazy: () => import('../commands/auto-review.mjs') },
26
67
  autoreview: { maturity: 'beta', summary: 'Alias for auto-review', lazy: () => import('../commands/auto-review.mjs') },
27
- 'dollar-commands': { maturity: 'stable', summary: 'List Codex App dollar commands', lazy: () => import('../commands/dollar-commands.mjs') },
28
- dollars: { maturity: 'stable', summary: 'Alias for dollar-commands', lazy: () => import('../commands/dollar-commands.mjs') },
29
- '$': { maturity: 'stable', summary: 'Alias for dollar-commands', lazy: () => import('../commands/dollar-commands.mjs') },
68
+ 'dollar-commands': { maturity: 'stable', summary: 'List Codex App dollar commands', lazy: basicArgs('dollarCommandsCommand') },
69
+ dollars: { maturity: 'stable', summary: 'Alias for dollar-commands', lazy: basicArgs('dollarCommandsCommand') },
70
+ '$': { maturity: 'stable', summary: 'Alias for dollar-commands', lazy: basicArgs('dollarCommandsCommand') },
30
71
  commit: { maturity: 'stable', summary: 'Create a simple git commit', lazy: () => import('../commands/commit.mjs') },
31
72
  'commit-and-push': { maturity: 'stable', summary: 'Create a simple git commit and push', lazy: () => import('../commands/commit-and-push.mjs') },
32
- dfix: { maturity: 'stable', summary: 'Explain DFix route', lazy: () => import('../commands/dfix.mjs') },
33
- team: { maturity: 'beta', summary: 'Create and observe Team missions', lazy: () => import('../commands/team.mjs') },
34
- 'qa-loop': { maturity: 'beta', summary: 'Run QA loop missions', lazy: () => import('../commands/qa-loop.mjs') },
35
- research: { maturity: 'labs', summary: 'Run research missions', lazy: () => import('../commands/research.mjs') },
36
- autoresearch: { maturity: 'labs', summary: 'Alias for research/autoresearch route', lazy: () => import('../commands/autoresearch.mjs') },
37
- ppt: { maturity: 'labs', summary: 'Inspect/build PPT artifacts', lazy: () => import('../commands/ppt.mjs') },
38
- 'image-ux-review': { maturity: 'labs', summary: 'Inspect image UX artifacts', lazy: () => import('../commands/image-ux-review.mjs') },
39
- 'ux-review': { maturity: 'labs', summary: 'Alias for image UX review', lazy: () => import('../commands/image-ux-review.mjs') },
40
- 'visual-review': { maturity: 'labs', summary: 'Alias for image UX review', lazy: () => import('../commands/image-ux-review.mjs') },
41
- 'ui-ux-review': { maturity: 'labs', summary: 'Alias for image UX review', lazy: () => import('../commands/image-ux-review.mjs') },
42
- 'computer-use': { maturity: 'beta', summary: 'Record Computer Use visual evidence', lazy: () => import('../commands/computer-use.mjs') },
43
- cu: { maturity: 'beta', summary: 'Alias for Computer Use', lazy: () => import('../commands/computer-use.mjs') },
44
- context7: { maturity: 'beta', summary: 'Context7 checks and docs', lazy: () => import('../commands/context7.mjs') },
73
+ dfix: { maturity: 'stable', summary: 'Explain DFix route', lazy: basicNoArgs('dfixCommand') },
74
+ team: { maturity: 'beta', summary: 'Create and observe Team missions', lazy: argsCommand(() => import('../core/commands/team-command.mjs'), 'team') },
75
+ 'qa-loop': { maturity: 'beta', summary: 'Run QA loop missions', lazy: subcommand(() => import('../core/commands/qa-loop-command.mjs'), 'qaLoopCommand') },
76
+ research: { maturity: 'labs', summary: 'Run research missions', lazy: subcommand(() => import('../core/commands/research-command.mjs'), 'researchCommand') },
77
+ autoresearch: { maturity: 'labs', summary: 'Alias for research/autoresearch route', lazy: subcommand(() => import('../core/commands/autoresearch-command.mjs'), 'autoresearchCommand', 'status') },
78
+ ppt: { maturity: 'labs', summary: 'Inspect/build PPT artifacts', lazy: commandArgsCommand(() => import('../core/commands/ppt-command.mjs'), 'pptCommand') },
79
+ 'image-ux-review': { maturity: 'labs', summary: 'Inspect image UX artifacts', lazy: commandArgsCommand(() => import('../core/commands/image-ux-review-command.mjs'), 'imageUxReviewCommand') },
80
+ 'ux-review': { maturity: 'labs', summary: 'Alias for image UX review', lazy: commandArgsCommand(() => import('../core/commands/image-ux-review-command.mjs'), 'imageUxReviewCommand') },
81
+ 'visual-review': { maturity: 'labs', summary: 'Alias for image UX review', lazy: commandArgsCommand(() => import('../core/commands/image-ux-review-command.mjs'), 'imageUxReviewCommand') },
82
+ 'ui-ux-review': { maturity: 'labs', summary: 'Alias for image UX review', lazy: commandArgsCommand(() => import('../core/commands/image-ux-review-command.mjs'), 'imageUxReviewCommand') },
83
+ 'computer-use': { maturity: 'beta', summary: 'Record Computer Use visual evidence', lazy: commandArgsCommand(() => import('../core/commands/computer-use-command.mjs'), 'computerUseCommand') },
84
+ cu: { maturity: 'beta', summary: 'Alias for Computer Use', lazy: commandArgsCommand(() => import('../core/commands/computer-use-command.mjs'), 'computerUseCommand') },
85
+ context7: { maturity: 'beta', summary: 'Context7 checks and docs', lazy: subcommand(() => import('./context7-command.mjs'), 'context7Command', 'check') },
45
86
  recallpulse: { maturity: 'labs', summary: 'RecallPulse evidence route', lazy: () => import('../commands/recallpulse.mjs') },
46
87
  pipeline: { maturity: 'beta', summary: 'Inspect pipeline missions', lazy: () => import('../commands/pipeline.mjs') },
47
88
  scouts: { maturity: 'beta', summary: 'Run the default read-only 5-scout intake phase', lazy: () => import('../commands/scouts.mjs') },
@@ -49,30 +90,32 @@ export const COMMANDS = {
49
90
  guard: { maturity: 'beta', summary: 'Check harness guard', lazy: () => import('../commands/guard.mjs') },
50
91
  conflicts: { maturity: 'beta', summary: 'Check harness conflicts', lazy: () => import('../commands/conflicts.mjs') },
51
92
  versioning: { maturity: 'stable', summary: 'Manage release version metadata', lazy: () => import('../commands/versioning.mjs') },
52
- reasoning: { maturity: 'labs', summary: 'Show reasoning route', lazy: () => import('../commands/reasoning.mjs') },
53
- aliases: { maturity: 'stable', summary: 'Show command aliases', lazy: () => import('../commands/aliases.mjs') },
54
- selftest: { maturity: 'stable', summary: 'Run local mock selftest', lazy: () => import('../commands/selftest.mjs') },
55
- goal: { maturity: 'beta', summary: 'Manage Goal bridge workflow', lazy: () => import('../commands/goal.mjs') },
93
+ reasoning: { maturity: 'labs', summary: 'Show reasoning route', lazy: basicArgs('reasoningCommand') },
94
+ aliases: { maturity: 'stable', summary: 'Show command aliases', lazy: basicNoArgs('aliasesCommand') },
95
+ selftest: { maturity: 'stable', summary: 'Run local mock selftest', lazy: basicArgs('selftestCommand') },
96
+ goal: { maturity: 'beta', summary: 'Manage Goal bridge workflow', lazy: subcommand(() => import('../core/commands/goal-command.mjs'), 'goalCommand') },
56
97
  hook: { maturity: 'beta', summary: 'Codex hook entrypoint', lazy: () => import('../commands/hook.mjs') },
57
98
  profile: { maturity: 'labs', summary: 'Inspect/set profile', lazy: () => import('../commands/profile.mjs') },
58
99
  hproof: { maturity: 'beta', summary: 'Evaluate H-Proof gate', lazy: () => import('../commands/hproof.mjs') },
59
- 'validate-artifacts': { maturity: 'beta', summary: 'Validate mission artifacts', lazy: () => import('../commands/validate-artifacts.mjs') },
100
+ 'validate-artifacts': { maturity: 'beta', summary: 'Validate mission artifacts', lazy: argsCommand(() => import('../core/commands/validate-artifacts-command.mjs'), 'validateArtifactsCommand') },
60
101
  proof: { maturity: 'beta', summary: 'Show and validate completion proof', lazy: () => import('../commands/proof.mjs') },
102
+ trust: { maturity: 'beta', summary: 'Report and validate route trust kernel evidence', lazy: argsCommand(() => import('../core/commands/trust-command.mjs'), 'trustCommand') },
61
103
  'proof-field': { maturity: 'beta', summary: 'Scan proof field', lazy: () => import('../commands/proof-field.mjs') },
62
- 'skill-dream': { maturity: 'labs', summary: 'Track skill dream counters', lazy: () => import('../commands/skill-dream.mjs') },
63
- 'code-structure': { maturity: 'labs', summary: 'Scan source structure', lazy: () => import('../commands/code-structure.mjs') },
104
+ 'skill-dream': { maturity: 'labs', summary: 'Track skill dream counters', lazy: subcommand(() => import('../core/commands/skill-dream-command.mjs'), 'skillDreamCommand', 'status') },
105
+ 'code-structure': { maturity: 'labs', summary: 'Scan source structure', lazy: subcommand(() => import('../core/commands/code-structure-command.mjs'), 'codeStructureCommand', 'scan') },
64
106
  rust: { maturity: 'beta', summary: 'Inspect optional Rust accelerator status and smoke parity', lazy: () => import('../commands/rust.mjs') },
65
- memory: { maturity: 'labs', summary: 'Run retention checks', lazy: () => import('../commands/memory.mjs') },
66
- gx: { maturity: 'labs', summary: 'Render/validate GX cartridges', lazy: () => import('../commands/gx.mjs') },
67
- db: { maturity: 'beta', summary: 'Inspect DB safety policy', lazy: () => import('../commands/db.mjs') },
68
- eval: { maturity: 'labs', summary: 'Run eval reports', lazy: () => import('../commands/eval.mjs') },
69
- harness: { maturity: 'labs', summary: 'Run harness fixtures', lazy: () => import('../commands/harness.mjs') },
107
+ memory: { maturity: 'labs', summary: 'Run retention checks', lazy: subcommand(() => import('../core/commands/gc-command.mjs'), 'memoryCommand') },
108
+ gx: { maturity: 'labs', summary: 'Render/validate GX cartridges', lazy: subcommand(() => import('../core/commands/gx-command.mjs'), 'gxCommand', 'validate') },
109
+ db: { maturity: 'beta', summary: 'Inspect DB safety policy', lazy: subcommand(() => import('../core/commands/db-command.mjs'), 'dbCommand', 'policy') },
110
+ eval: { maturity: 'labs', summary: 'Run eval reports', lazy: subcommand(() => import('../core/commands/eval-command.mjs'), 'evalCommand', 'run') },
111
+ harness: { maturity: 'labs', summary: 'Run harness fixtures', lazy: subcommand(() => import('../core/commands/harness-command.mjs'), 'harnessCommand', 'fixture') },
70
112
  wiki: { maturity: 'beta', summary: 'Manage TriWiki and image voxel ledgers', lazy: () => import('../commands/wiki.mjs') },
71
- gc: { maturity: 'labs', summary: 'Compact/prune runtime state', lazy: () => import('../commands/gc.mjs') },
72
- stats: { maturity: 'labs', summary: 'Show storage stats', lazy: () => import('../commands/stats.mjs') },
113
+ gc: { maturity: 'labs', summary: 'Compact/prune runtime state', lazy: gcArgs('gcCommand') },
114
+ stats: { maturity: 'labs', summary: 'Show storage stats', lazy: gcArgs('statsCommand') },
73
115
  features: { maturity: 'beta', summary: 'Validate feature registry', lazy: () => import('../commands/features.mjs') },
74
116
  'all-features': { maturity: 'beta', summary: 'Run all-features selftest', lazy: () => import('../commands/all-features.mjs') },
75
- perf: { maturity: 'beta', summary: 'Run performance checks', lazy: () => import('../commands/perf.mjs') }
117
+ perf: { maturity: 'beta', summary: 'Run performance checks', lazy: () => import('../commands/perf.mjs') },
118
+ bench: { maturity: 'beta', summary: 'Run core trust-kernel benchmark budgets', lazy: argsCommand(() => import('../core/commands/bench-command.mjs'), 'benchCommand') }
76
119
  };
77
120
 
78
121
  export const COMMAND_ALIASES = {
@@ -0,0 +1,31 @@
1
+ import { COMMANDS } from './command-registry.mjs';
2
+ import { PACKAGE_VERSION } from '../core/version.mjs';
3
+ import { COMMAND_CATALOG } from '../core/routes.mjs';
4
+
5
+ export function helpFast() {
6
+ console.log(`SKS
7
+ SNEAKOSCOPE CODEX v${PACKAGE_VERSION}
8
+
9
+ Usage
10
+
11
+ sks
12
+ sks help [topic]
13
+ sks commands [--json]
14
+ sks dollar-commands [--json]
15
+ sks proof show --json
16
+ `);
17
+ for (const row of commandRows().filter((entry) => entry.maturity !== 'labs')) {
18
+ console.log(` ${row.usage.padEnd(58)} ${row.description}`);
19
+ }
20
+ console.log('\nThree core promises: Completion Proof for serious routes, Image Voxel TriWiki for visual routes, and release-gated Codex App/codex-lb/hooks/Rust evidence.');
21
+ }
22
+
23
+ function commandRows() {
24
+ const registry = new Map(Object.entries(COMMANDS).map(([name, meta]) => [name, meta]));
25
+ return COMMAND_CATALOG.map((entry) => ({
26
+ name: entry.name,
27
+ usage: entry.usage,
28
+ description: entry.description,
29
+ maturity: registry.get(entry.name)?.maturity || entry.maturity || 'labs'
30
+ })).sort((a, b) => a.name.localeCompare(b.name));
31
+ }
@@ -0,0 +1,97 @@
1
+ import path from 'node:path';
2
+ import { performance } from 'node:perf_hooks';
3
+ import { ensureDir, nowIso, packageRoot, projectRoot, runProcess, writeJsonAtomic, writeTextAtomic } from './fsx.mjs';
4
+ import { percentile } from './perf-bench.mjs';
5
+
6
+ export const CORE_BENCH_BUDGETS = Object.freeze({
7
+ 'sks --version': 50,
8
+ 'sks help': 80,
9
+ 'sks root --json': 80,
10
+ 'sks commands --json': 120,
11
+ 'sks proof validate --json': 250,
12
+ 'sks trust validate latest --json': 300,
13
+ 'sks wiki image-validate --json': 300,
14
+ 'sks features check --json': 1200,
15
+ 'sks scouts engines --json': 1000
16
+ });
17
+
18
+ const CORE_COMMANDS = Object.freeze([
19
+ ['sks --version', ['--version']],
20
+ ['sks help', ['help']],
21
+ ['sks root --json', ['root', '--json']],
22
+ ['sks commands --json', ['commands', '--json']],
23
+ ['sks proof validate --json', ['proof', 'validate', '--json']],
24
+ ['sks trust validate latest --json', ['trust', 'validate', 'latest', '--json']],
25
+ ['sks wiki image-validate --json', ['wiki', 'image-validate', '--json']],
26
+ ['sks features check --json', ['features', 'check', '--json']],
27
+ ['sks scouts engines --json', ['scouts', 'engines', '--json']]
28
+ ]);
29
+
30
+ export async function runCoreBench(root = process.cwd(), { iterations = 3 } = {}) {
31
+ const script = path.join(packageRoot(), 'bin', 'sks.mjs');
32
+ await ensureBenchTrustMission(root, script);
33
+ const rows = [];
34
+ for (const [label, args] of CORE_COMMANDS) {
35
+ const values = [];
36
+ const failures = [];
37
+ for (let i = 0; i < Math.max(1, Number(iterations) || 1); i += 1) {
38
+ const t0 = performance.now();
39
+ const result = await runProcess(process.execPath, [script, ...args], {
40
+ cwd: root,
41
+ timeoutMs: 30_000,
42
+ maxOutputBytes: 256 * 1024,
43
+ env: { SKS_SKIP_NPM_FRESHNESS_CHECK: '1', SKS_DISABLE_UPDATE_CHECK: '1', CI: 'true' }
44
+ });
45
+ values.push(performance.now() - t0);
46
+ if (result.code !== 0) failures.push({ code: result.code, stderr_tail: result.stderr.slice(-400), stdout_tail: result.stdout.slice(-400) });
47
+ }
48
+ const p95 = Math.round(percentile(values, 95));
49
+ rows.push({
50
+ command: label,
51
+ budget_p95_ms: CORE_BENCH_BUDGETS[label],
52
+ p95_ms: p95,
53
+ ok: failures.length === 0 && p95 <= CORE_BENCH_BUDGETS[label],
54
+ failures,
55
+ raw_ms: values.map((value) => Math.round(value))
56
+ });
57
+ }
58
+ const report = {
59
+ schema: 'sks.core-bench.v1',
60
+ generated_at: nowIso(),
61
+ iterations: Math.max(1, Number(iterations) || 1),
62
+ ok: rows.every((row) => row.ok),
63
+ commands: rows
64
+ };
65
+ await writeCoreBenchArtifacts(root, report);
66
+ return report;
67
+ }
68
+
69
+ async function ensureBenchTrustMission(root, script) {
70
+ await runProcess(process.execPath, [script, 'run', 'bench trust fixture', '--mock', '--json'], {
71
+ cwd: root,
72
+ timeoutMs: 60_000,
73
+ maxOutputBytes: 256 * 1024,
74
+ env: { SKS_SKIP_NPM_FRESHNESS_CHECK: '1', SKS_DISABLE_UPDATE_CHECK: '1', CI: 'true' }
75
+ });
76
+ }
77
+
78
+ export async function writeCoreBenchArtifacts(root, report) {
79
+ const dir = path.join(root, '.sneakoscope', 'reports', 'performance');
80
+ await ensureDir(dir);
81
+ await writeJsonAtomic(path.join(dir, 'core-bench.json'), report);
82
+ const lines = [
83
+ '# SKS Core Bench',
84
+ '',
85
+ `Generated: ${report.generated_at}`,
86
+ `Status: ${report.ok ? 'pass' : 'verified_partial_or_blocked'}`,
87
+ '',
88
+ '| Command | Budget p95 | Result p95 | Status |',
89
+ '| --- | ---: | ---: | --- |'
90
+ ];
91
+ for (const row of report.commands) lines.push(`| \`${row.command}\` | ${row.budget_p95_ms}ms | ${row.p95_ms}ms | ${row.ok ? 'pass' : 'blocked'} |`);
92
+ await writeTextAtomic(path.join(dir, 'core-bench.md'), `${lines.join('\n')}\n`);
93
+ }
94
+
95
+ export async function benchRoot() {
96
+ return projectRoot();
97
+ }