@skathio/somi 4.1.0 → 5.0.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.
- package/.claude-plugin/icon.png +0 -0
- package/.claude-plugin/marketplace.json +8 -3
- package/.claude-plugin/plugin.json +9 -10
- package/.copilot-extension/extension.json +32 -40
- package/.copilot-extension/marketplace.json +8 -3
- package/README.md +83 -228
- package/VERSION +1 -1
- package/agents/somi-reviewer.md +21 -40
- package/agents/somi-security-reviewer.md +16 -90
- package/agents/somi-worker-high.md +11 -0
- package/agents/somi-worker-low.md +11 -0
- package/agents/somi-worker-medium.md +11 -0
- package/agents/somi.md +8 -75
- package/commands/somi-config.md +5 -14
- package/commands/somi-deliver.md +11 -0
- package/commands/somi-quality.md +10 -0
- package/commands/somi-review.md +10 -0
- package/commands/somi-status.md +11 -0
- package/commands/somi.md +10 -0
- package/hooks/hooks.json +28 -23
- package/hooks/lib/common.mjs +45 -34
- package/hooks/pre-tool/apply-tier.mjs +31 -0
- package/hooks/pre-tool/block-dangerous-bash.mjs +15 -0
- package/hooks/pre-tool/gate-dep-install.mjs +2 -2
- package/hooks/pre-tool/guard-protected-paths.mjs +9 -16
- package/hooks/pre-tool/guard-tier-config.mjs +17 -0
- package/hooks/pre-tool/reviewers-read-only.mjs +11 -0
- package/hooks/session-start/inject-digest.mjs +51 -0
- package/hooks/stop/review-due.mjs +40 -0
- package/hooks/user-prompt/capture-prompt.mjs +17 -0
- package/library/lenses/architecture.md +1 -0
- package/library/lenses/test-strategy.md +1 -0
- package/library/roles/accessibility.md +1 -0
- package/library/roles/answer.md +1 -0
- package/library/roles/atlas.md +1 -0
- package/library/roles/build.md +1 -0
- package/library/roles/debug.md +6 -0
- package/library/roles/design.md +1 -0
- package/library/roles/discover.md +1 -0
- package/library/roles/incident.md +1 -0
- package/library/roles/migrate.md +1 -0
- package/library/roles/perf.md +1 -0
- package/library/roles/plan.md +1 -0
- package/library/roles/refactor.md +1 -0
- package/library/roles/review.md +1 -0
- package/library/roles/security-review.md +1 -0
- package/library/roles/upgrade.md +1 -0
- package/library/skills/accessibility.md +16 -0
- package/library/skills/ci-infra-gotchas.md +12 -0
- package/library/skills/perf-method.md +10 -0
- package/library/skills/secure-coding.md +18 -0
- package/library/skills/testing-checklist.md +16 -0
- package/library/skills/threat-modeling.md +10 -0
- package/package.json +12 -17
- package/profiles/claude.json +21 -0
- package/profiles/copilot.json +5 -0
- package/rules/digest.md +40 -0
- package/scripts/check-links.mjs +65 -76
- package/scripts/lib/advisor.mjs +207 -0
- package/scripts/lib/check.mjs +165 -0
- package/scripts/lib/copilot-workflow.mjs +41 -0
- package/scripts/lib/doctor.mjs +91 -0
- package/scripts/lib/gates.mjs +69 -0
- package/scripts/lib/git-tree.mjs +201 -0
- package/scripts/lib/init.mjs +23 -0
- package/scripts/lib/ledger.mjs +38 -0
- package/scripts/lib/mcp-project-root.mjs +63 -67
- package/scripts/lib/migrate.mjs +73 -0
- package/scripts/lib/path-facts.mjs +2 -2
- package/scripts/lib/path-safety.mjs +6 -134
- package/scripts/lib/plan.mjs +69 -0
- package/scripts/lib/policy.mjs +103 -0
- package/scripts/lib/pr.mjs +28 -0
- package/scripts/lib/prompt.mjs +72 -0
- package/scripts/lib/quality/clones.mjs +76 -0
- package/scripts/lib/quality/css.mjs +43 -0
- package/scripts/lib/quality/gate.mjs +230 -0
- package/scripts/lib/quality/limits.mjs +73 -0
- package/scripts/lib/quality/metrics.mjs +159 -0
- package/scripts/lib/quality/parse.mjs +73 -0
- package/scripts/lib/quality/repo.mjs +69 -0
- package/scripts/lib/quality/run.mjs +38 -0
- package/scripts/lib/reviews.mjs +132 -0
- package/scripts/lib/routes.mjs +108 -0
- package/scripts/lib/setup.mjs +34 -0
- package/scripts/lib/shards.mjs +166 -0
- package/scripts/lib/signals.mjs +110 -0
- package/scripts/lib/state.mjs +42 -0
- package/scripts/lib/tiers.mjs +42 -0
- package/scripts/lib/update-notice.mjs +48 -0
- package/scripts/lib/views.mjs +62 -0
- package/scripts/lib/workflows.mjs +56 -0
- package/scripts/somi-mcp.mjs +181 -323
- package/scripts/somi.mjs +208 -0
- package/scripts/vendor/tree-sitter/LICENSE.vscode-tree-sitter-wasm +21 -0
- package/scripts/vendor/tree-sitter/LICENSE.web-tree-sitter +21 -0
- package/scripts/vendor/tree-sitter/cgmanifest.vscode-tree-sitter-wasm.json +16 -0
- package/scripts/vendor/tree-sitter/manifest.json +59 -0
- package/scripts/vendor/tree-sitter/package.json +3 -0
- package/scripts/vendor/tree-sitter/tree-sitter-css.wasm +0 -0
- package/scripts/vendor/tree-sitter/tree-sitter-javascript.wasm +0 -0
- package/scripts/vendor/tree-sitter/tree-sitter-tsx.wasm +0 -0
- package/scripts/vendor/tree-sitter/tree-sitter-typescript.wasm +0 -0
- package/scripts/vendor/tree-sitter/web-tree-sitter.js +4081 -0
- package/scripts/vendor/tree-sitter/web-tree-sitter.wasm +0 -0
- package/skills/somi-expertise/SKILL.md +6 -0
- package/workflows/deliver-stages.js +81 -0
- package/.claude/settings.json +0 -131
- package/agents/somi-architecture-reviewer.md +0 -101
- package/agents/somi-atlas.md +0 -100
- package/agents/somi-coder.md +0 -60
- package/agents/somi-designer.md +0 -36
- package/agents/somi-discovery-analyst.md +0 -57
- package/agents/somi-flow.md +0 -47
- package/agents/somi-general.md +0 -36
- package/agents/somi-impact.md +0 -95
- package/agents/somi-incident.md +0 -94
- package/agents/somi-plan-reviewer.md +0 -68
- package/agents/somi-planner.md +0 -57
- package/agents/somi-pr.md +0 -99
- package/agents/somi-refactor-designer.md +0 -81
- package/agents/somi-refactorer.md +0 -99
- package/agents/somi-sdlc-reviewer.md +0 -67
- package/agents/somi-test-strategist.md +0 -87
- package/commands/adopt.md +0 -14
- package/commands/architecture-review.md +0 -19
- package/commands/atlas.md +0 -19
- package/commands/code-loop.md +0 -19
- package/commands/code-parallel.md +0 -19
- package/commands/code.md +0 -19
- package/commands/debug.md +0 -19
- package/commands/design.md +0 -19
- package/commands/discover.md +0 -19
- package/commands/impact.md +0 -19
- package/commands/incident.md +0 -19
- package/commands/plan-loop.md +0 -19
- package/commands/plan.md +0 -19
- package/commands/pr.md +0 -19
- package/commands/refactor-design.md +0 -19
- package/commands/refactor.md +0 -19
- package/commands/release-readiness.md +0 -19
- package/commands/review-panel.md +0 -19
- package/commands/review.md +0 -19
- package/commands/security-review.md +0 -19
- package/commands/ship-loop.md +0 -19
- package/commands/ship.md +0 -19
- package/commands/test-strategy.md +0 -19
- package/commands/upgrade.md +0 -19
- package/examples/README.md +0 -19
- package/examples/code-review-example.md +0 -88
- package/examples/discovery-example.md +0 -200
- package/examples/feature-plan-example.md +0 -377
- package/examples/full-pipeline-example.md +0 -188
- package/examples/sample-consumer/.claude/settings.json +0 -29
- package/examples/sample-consumer/CLAUDE.md +0 -78
- package/examples/sample-consumer/README.md +0 -102
- package/hooks/post-tool/lint-changed-files.mjs +0 -209
- package/hooks/pre-tool/guard-cost-lowering.mjs +0 -192
- package/hooks/session-start/detect-repo-instructions.mjs +0 -287
- package/hooks/session-start/ensure-default-config.mjs +0 -113
- package/hooks/user-prompt-submit/inject-workflow-context.mjs +0 -580
- package/rules/00-priorities.md +0 -48
- package/rules/10-solid.md +0 -87
- package/rules/20-clean-code.md +0 -62
- package/rules/30-security-owasp.md +0 -83
- package/rules/40-engineering-practices.md +0 -65
- package/rules/50-collaboration.md +0 -114
- package/rules/99-overrides.md +0 -52
- package/rules/CLAUDE.md +0 -200
- package/scripts/check-session-artefacts.mjs +0 -149
- package/scripts/check-size-budget.mjs +0 -137
- package/scripts/generate-digest.mjs +0 -176
- package/scripts/lib/agent-info.mjs +0 -85
- package/scripts/lib/agent-registry.mjs +0 -92
- package/scripts/lib/cost-ceiling.mjs +0 -328
- package/scripts/lib/cost-config-edit.mjs +0 -102
- package/scripts/lib/cost-config.mjs +0 -64
- package/scripts/lib/cost-defaults.mjs +0 -53
- package/scripts/lib/cost-lowering.mjs +0 -89
- package/scripts/lib/cost-model.mjs +0 -110
- package/scripts/lib/dispatch-resolver.mjs +0 -243
- package/scripts/lib/escalation-facts.mjs +0 -146
- package/scripts/lib/escalation.mjs +0 -129
- package/scripts/lib/findings-ledger.mjs +0 -241
- package/scripts/lib/install-text.mjs +0 -97
- package/scripts/lib/loop-caps.mjs +0 -140
- package/scripts/lib/loop-diff.mjs +0 -38
- package/scripts/lib/loop-dispatch.mjs +0 -19
- package/scripts/lib/loop-engine.mjs +0 -226
- package/scripts/lib/loop-escalate.mjs +0 -49
- package/scripts/lib/loop-exit.mjs +0 -47
- package/scripts/lib/loop-notes-compact.mjs +0 -72
- package/scripts/lib/loop-notes.mjs +0 -278
- package/scripts/lib/loop-review.mjs +0 -395
- package/scripts/lib/loop-state.mjs +0 -44
- package/scripts/lib/loop-step-close.mjs +0 -75
- package/scripts/lib/loop-step-kit.mjs +0 -179
- package/scripts/lib/loop-step-review.mjs +0 -140
- package/scripts/lib/loop-step-tool.mjs +0 -89
- package/scripts/lib/loop-step.mjs +0 -301
- package/scripts/lib/run-budget.mjs +0 -28
- package/scripts/lib/run-card.mjs +0 -73
- package/scripts/lib/size-tier.mjs +0 -184
- package/scripts/lib/tier-record.mjs +0 -82
- package/scripts/size-budget-overrides.json +0 -58
- package/scripts/somi-card.mjs +0 -39
- package/scripts/somi-check.mjs +0 -237
- package/scripts/somi-config.mjs +0 -421
- package/scripts/somi-dispatch.mjs +0 -141
- package/scripts/somi-findings.mjs +0 -100
- package/scripts/somi-loop.mjs +0 -128
- package/scripts/somi-tier.mjs +0 -393
- package/scripts/validate.sh +0 -653
- package/skills/api-design/SKILL.md +0 -147
- package/skills/clean-code/SKILL.md +0 -142
- package/skills/flow-adopt/SKILL.md +0 -92
- package/skills/flow-architecture-review/SKILL.md +0 -94
- package/skills/flow-atlas/SKILL.md +0 -34
- package/skills/flow-code/SKILL.md +0 -167
- package/skills/flow-code-loop/SKILL.md +0 -263
- package/skills/flow-code-parallel/SKILL.md +0 -160
- package/skills/flow-debug/SKILL.md +0 -141
- package/skills/flow-design/SKILL.md +0 -170
- package/skills/flow-discover/SKILL.md +0 -204
- package/skills/flow-impact/SKILL.md +0 -35
- package/skills/flow-incident/SKILL.md +0 -49
- package/skills/flow-plan/SKILL.md +0 -254
- package/skills/flow-plan-loop/SKILL.md +0 -254
- package/skills/flow-pr/SKILL.md +0 -34
- package/skills/flow-refactor/SKILL.md +0 -58
- package/skills/flow-refactor-design/SKILL.md +0 -97
- package/skills/flow-release-readiness/SKILL.md +0 -82
- package/skills/flow-review/SKILL.md +0 -193
- package/skills/flow-review-panel/SKILL.md +0 -154
- package/skills/flow-security-review/SKILL.md +0 -83
- package/skills/flow-ship/SKILL.md +0 -125
- package/skills/flow-ship-loop/SKILL.md +0 -274
- package/skills/flow-somi-config/SKILL.md +0 -142
- package/skills/flow-status/SKILL.md +0 -43
- package/skills/flow-test-strategy/SKILL.md +0 -83
- package/skills/flow-upgrade/SKILL.md +0 -82
- package/skills/market-research/SKILL.md +0 -125
- package/skills/observability/SKILL.md +0 -133
- package/skills/owasp-defense/SKILL.md +0 -141
- package/skills/plan-review/SKILL.md +0 -83
- package/skills/reasoning-craft/SKILL.md +0 -213
- package/skills/requirements-engineering/SKILL.md +0 -137
- package/skills/role-coder/SKILL.md +0 -247
- package/skills/role-designer/SKILL.md +0 -172
- package/skills/role-discovery-analyst/SKILL.md +0 -288
- package/skills/role-planner/SKILL.md +0 -353
- package/skills/role-reviewer/SKILL.md +0 -218
- package/skills/rules/SKILL.md +0 -47
- package/skills/sdlc-process/SKILL.md +0 -74
- package/skills/solid-principles/SKILL.md +0 -143
- package/skills/somi-checkpoint/SKILL.md +0 -95
- package/skills/somi-dispatch/SKILL.md +0 -259
- package/skills/somi-routing/SKILL.md +0 -158
- package/skills/testing-playbook/SKILL.md +0 -133
- package/skills/threat-modeling/SKILL.md +0 -117
- package/templates/ADR.md.tmpl +0 -73
- package/templates/ATLAS.md.tmpl +0 -75
- package/templates/BRD.md.tmpl +0 -68
- package/templates/BRIEF.md.tmpl +0 -119
- package/templates/CONTEXT.md.tmpl +0 -74
- package/templates/DECISIONS.md.tmpl +0 -105
- package/templates/DESIGN.md.tmpl +0 -83
- package/templates/DIARY.md.tmpl +0 -70
- package/templates/DOD.md.tmpl +0 -90
- package/templates/FRD.md.tmpl +0 -64
- package/templates/PHASE.md.tmpl +0 -80
- package/templates/PROGRESS.md.tmpl +0 -63
- package/templates/RCA.md.tmpl +0 -53
- package/templates/RD-README.md.tmpl +0 -70
- package/templates/RESEARCH.md.tmpl +0 -96
- package/templates/REVIEW.md.tmpl +0 -82
- package/templates/SDD.md.tmpl +0 -82
- package/templates/SOMI-README.md.tmpl +0 -83
- package/templates/SPEC.md.tmpl +0 -123
- package/templates/SRS.md.tmpl +0 -85
- package/templates/TDD.md.tmpl +0 -77
- package/tests/hooks/cases/audit-log.json +0 -21
- package/tests/hooks/cases/block-dangerous-bash.json +0 -166
- package/tests/hooks/cases/block-secret-writes.json +0 -140
- package/tests/hooks/cases/detect-repo-instructions.json +0 -105
- package/tests/hooks/cases/gate-dep-install.json +0 -42
- package/tests/hooks/cases/guard-protected-paths.json +0 -222
- package/tests/hooks/cases/inject-workflow-context.json +0 -239
- package/tests/hooks/cases/lint-changed-files.json +0 -120
- package/tests/hooks/run.sh +0 -392
- package/tests/scripts/agent-model-frontmatter.sh +0 -38
- package/tests/scripts/agent-names.sh +0 -77
- package/tests/scripts/check-frontmatter.sh +0 -37
- package/tests/scripts/check-links.sh +0 -105
- package/tests/scripts/check-session-artefacts.sh +0 -60
- package/tests/scripts/check-size-budget.sh +0 -71
- package/tests/scripts/checkpoint-gate.sh +0 -131
- package/tests/scripts/convergence-runner.sh +0 -1514
- package/tests/scripts/cost-ceiling.sh +0 -255
- package/tests/scripts/cost-defaults.sh +0 -130
- package/tests/scripts/cost-hardcap.sh +0 -338
- package/tests/scripts/cost-lowering.sh +0 -261
- package/tests/scripts/cost-model.sh +0 -196
- package/tests/scripts/dispatch-guard.sh +0 -108
- package/tests/scripts/dispatch-line-gate.sh +0 -61
- package/tests/scripts/dispatch-reference-gate.sh +0 -173
- package/tests/scripts/ensure-default-config.sh +0 -162
- package/tests/scripts/escalation.sh +0 -409
- package/tests/scripts/eval-runner.sh +0 -3692
- package/tests/scripts/evals-packaging.sh +0 -224
- package/tests/scripts/fact-sheet.sh +0 -296
- package/tests/scripts/fixtures/legacy-shard-no-schema.json +0 -50
- package/tests/scripts/fixtures/mock-stdin-read-throw.cjs +0 -18
- package/tests/scripts/fixtures/size-tier-cases.json +0 -87
- package/tests/scripts/generate-digest.sh +0 -180
- package/tests/scripts/global-config.sh +0 -167
- package/tests/scripts/goldens/loop-state-breach.json +0 -1
- package/tests/scripts/goldens/loop-state-done.json +0 -1
- package/tests/scripts/goldens/somi-findings.json +0 -336
- package/tests/scripts/goldens/somi-loop.json +0 -168
- package/tests/scripts/lib/adr-shape.mjs +0 -41
- package/tests/scripts/lib/agent-registry-tests.mjs +0 -95
- package/tests/scripts/lib/brief-only-guard.mjs +0 -27
- package/tests/scripts/lib/checkpoint-gate.mjs +0 -91
- package/tests/scripts/lib/digest-marker-coupling.mjs +0 -52
- package/tests/scripts/lib/dispatch-reference-gate.mjs +0 -121
- package/tests/scripts/lib/escalation-facts-tests.mjs +0 -140
- package/tests/scripts/lib/escalation-tests.mjs +0 -154
- package/tests/scripts/lib/findings-ledger-tests.mjs +0 -118
- package/tests/scripts/lib/loop-engine-tests.mjs +0 -287
- package/tests/scripts/lib/loop-escalate-tests.mjs +0 -356
- package/tests/scripts/lib/loop-flow-gate.mjs +0 -173
- package/tests/scripts/lib/loop-notes-tests.mjs +0 -371
- package/tests/scripts/lib/loop-step-cli-tests.mjs +0 -141
- package/tests/scripts/lib/loop-step-close-tests.mjs +0 -351
- package/tests/scripts/lib/loop-step-lenient-tests.mjs +0 -114
- package/tests/scripts/lib/loop-step-state-tests.mjs +0 -127
- package/tests/scripts/lib/loop-step-tests.mjs +0 -499
- package/tests/scripts/lib/loop-step-unwritten-tests.mjs +0 -55
- package/tests/scripts/lib/multipass-dependence.mjs +0 -192
- package/tests/scripts/lib/multipass-source-identity.mjs +0 -243
- package/tests/scripts/lib/path-facts-tests.mjs +0 -198
- package/tests/scripts/lib/path-safety-tests.mjs +0 -201
- package/tests/scripts/lib/reference-pair.mjs +0 -61
- package/tests/scripts/lib/retirement-gate.mjs +0 -172
- package/tests/scripts/lib/run-suites.mjs +0 -139
- package/tests/scripts/lib/shell-embedded-js.mjs +0 -47
- package/tests/scripts/lib/ship-loop-sizing-guard.mjs +0 -52
- package/tests/scripts/lib/site-roadmap-gate.mjs +0 -64
- package/tests/scripts/lib/size-tier-drift.mjs +0 -74
- package/tests/scripts/lib/sizing-score-tests.mjs +0 -210
- package/tests/scripts/lib/sizing-set-tests.mjs +0 -131
- package/tests/scripts/lib/somi-mcp-client.mjs +0 -102
- package/tests/scripts/lib/somi-mcp-config-tests.mjs +0 -92
- package/tests/scripts/lib/somi-mcp-loop-tests.mjs +0 -226
- package/tests/scripts/lib/somi-mcp-tests.mjs +0 -491
- package/tests/scripts/lib/somi-mcp-tier-tests.mjs +0 -64
- package/tests/scripts/lib/somi-mcp-tool-schema.mjs +0 -38
- package/tests/scripts/loop-engine.sh +0 -22
- package/tests/scripts/loop-flow-gate.sh +0 -11
- package/tests/scripts/retirement-gate.sh +0 -306
- package/tests/scripts/review-panel-seats.sh +0 -32
- package/tests/scripts/run-card.sh +0 -57
- package/tests/scripts/run-suites.sh +0 -74
- package/tests/scripts/run.sh +0 -689
- package/tests/scripts/site-roadmap-gate.sh +0 -76
- package/tests/scripts/size-tier.sh +0 -562
- package/tests/scripts/somi-agent-dispatch-contract.sh +0 -224
- package/tests/scripts/somi-config.sh +0 -286
- package/tests/scripts/somi-dispatch.sh +0 -465
- package/tests/scripts/somi-mcp.sh +0 -15
- package/tests/scripts/suite-plan.json +0 -20
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"base": { "T1": true, "T2": true, "T3": true, "T4": true, "T5": true, "sensitive_core": false, "hard_surface": false, "design_open": false, "open_questions": 0, "acceptance_testable": true, "modules_touched": 1, "est_files": 1, "est_diff_lines": 40, "existing_work_item": false, "brief_exists": false },
|
|
3
|
-
"comment": "set: id -> value (evidence added) or {entry: raw}; drop: ids removed; noEvidence: ids without evidence; raw: whole input. expect: tier, floor (absent = null), unknown, invalid (failed is their union), reasons, basis (the ids present in the basis map, optional). Corpus rows are the seven A/B tickets mapped by hand under the rubric's rulings; count signals are production code only, tests excluded.",
|
|
4
|
-
"cases": [
|
|
5
|
-
{ "name": "all clear, one file", "expect": { "tier": "trivial", "reasons": [], "basis": ["T1", "T2", "T3", "T4", "T5", "sensitive_core", "hard_surface", "design_open", "open_questions", "acceptance_testable", "modules_touched", "est_files", "est_diff_lines", "existing_work_item", "brief_exists"] } },
|
|
6
|
-
{ "name": "T1 corpus: new two-function module, greenfield", "set": { "T2": false, "est_diff_lines": 80 }, "expect": { "tier": "small", "reasons": ["T2", "est_diff_lines"] } },
|
|
7
|
-
{ "name": "H1 corpus: order CSV export; PII and query filters; also a new network contract", "set": { "T1": false, "T2": false, "T3": false, "hard_surface": true, "est_files": 3, "est_diff_lines": 120, "sensitive_core": true }, "expect": { "tier": "full", "floor": "full", "reasons": ["sensitive_core"], "basis": ["T3", "sensitive_core"], "securityLens": true } },
|
|
8
|
-
{ "name": "H1 corpus if T3 were read true: still full as a new network contract", "set": { "T1": false, "T2": false, "hard_surface": true, "est_files": 3, "est_diff_lines": 120 }, "expect": { "tier": "full", "reasons": ["hard_surface"], "basis": ["T3", "sensitive_core"] } },
|
|
9
|
-
{ "name": "H2 corpus: ledger file migration plus new batch API", "set": { "T1": false, "T2": false, "hard_surface": true, "modules_touched": 2, "est_files": 4, "est_diff_lines": 300 }, "expect": { "tier": "full", "reasons": ["hard_surface"] } },
|
|
10
|
-
{ "name": "H4 corpus: file serving from a shared folder, path handling unprompted", "set": { "T1": false, "T2": false, "T3": false, "hard_surface": true, "est_files": 3, "est_diff_lines": 180 }, "expect": { "tier": "full", "reasons": ["hard_surface"], "securityLens": true } },
|
|
11
|
-
{ "name": "H5 corpus: split one 300-line function into four modules", "set": { "T1": false, "T2": false, "est_files": 5, "est_diff_lines": 650 }, "expect": { "tier": "full", "reasons": ["est_diff_lines"] } },
|
|
12
|
-
{ "name": "H6 corpus: recurring-schedule bug, cause not isolated", "set": { "T1": false, "T4": false, "est_files": 2, "est_diff_lines": 60 }, "expect": { "tier": "full", "reasons": ["T4"] } },
|
|
13
|
-
{ "name": "H7 corpus: wiki links; typed page names rendered into HTML links", "set": { "T1": false, "T2": false, "T3": false, "est_files": 3, "est_diff_lines": 150 }, "expect": { "tier": "full", "reasons": ["est_diff_lines"], "securityLens": true } },
|
|
14
|
-
{ "name": "T1 false alone", "set": { "T1": false }, "expect": { "tier": "small", "reasons": ["T1"] } },
|
|
15
|
-
{ "name": "T2 false alone", "set": { "T2": false }, "expect": { "tier": "small", "reasons": ["T2"] } },
|
|
16
|
-
{ "name": "T3 false alone: at least small, security lens, no floor", "set": { "T3": false }, "expect": { "tier": "small", "reasons": ["T3"], "basis": ["T1", "T2", "T3", "T4", "T5", "sensitive_core", "hard_surface", "design_open", "open_questions", "acceptance_testable", "modules_touched", "est_files", "est_diff_lines", "existing_work_item", "brief_exists"], "securityLens": true } },
|
|
17
|
-
{ "name": "T4 false alone", "set": { "T4": false }, "expect": { "tier": "full", "reasons": ["T4"], "basis": ["T3", "sensitive_core"] } },
|
|
18
|
-
{ "name": "T5 false alone", "set": { "T5": false }, "expect": { "tier": "small", "reasons": ["T5"] } },
|
|
19
|
-
{ "name": "T1..T5 all false: the T4 rule fires, security lens on", "set": { "T1": false, "T2": false, "T3": false, "T4": false, "T5": false }, "expect": { "tier": "full", "reasons": ["T4"], "securityLens": true } },
|
|
20
|
-
{ "name": "trivial at the diff limit 50", "set": { "est_diff_lines": 50 }, "expect": { "tier": "trivial", "reasons": [] } },
|
|
21
|
-
{ "name": "small at diff exactly 50 does not blame the diff", "set": { "T2": false, "est_diff_lines": 50 }, "expect": { "tier": "small", "reasons": ["T2"] } },
|
|
22
|
-
{ "name": "diff 51 is no longer trivial", "set": { "est_diff_lines": 51 }, "expect": { "tier": "small", "reasons": ["est_diff_lines"] } },
|
|
23
|
-
{ "name": "two files with T1 true: T1 is contradicted", "set": { "est_files": 2 }, "expect": { "tier": "small", "invalid": ["T1"], "reasons": ["T1", "est_files"] } },
|
|
24
|
-
{ "name": "two modules with T1 true: T1 is contradicted", "set": { "modules_touched": 2 }, "expect": { "tier": "small", "invalid": ["T1"], "reasons": ["T1", "modules_touched"] } },
|
|
25
|
-
{ "name": "two files with T1 false: honest small", "set": { "T1": false, "est_files": 2 }, "expect": { "tier": "small", "reasons": ["T1", "est_files"] } },
|
|
26
|
-
{ "name": "contradiction is not judged against an unknown count", "set": { "est_files": "unknown" }, "expect": { "tier": "full", "unknown": ["est_files"], "reasons": ["est_files"] } },
|
|
27
|
-
{ "name": "diff 100 is not over the line", "set": { "T1": false, "est_diff_lines": 100 }, "expect": { "tier": "small", "reasons": ["T1", "est_diff_lines"] } },
|
|
28
|
-
{ "name": "diff 101 is full", "set": { "T1": false, "est_diff_lines": 101 }, "expect": { "tier": "full", "reasons": ["est_diff_lines"] } },
|
|
29
|
-
{ "name": "files 6 is not over the line", "set": { "T1": false, "est_files": 6 }, "expect": { "tier": "small", "reasons": ["T1", "est_files"] } },
|
|
30
|
-
{ "name": "files 7 is full", "set": { "T1": false, "est_files": 7 }, "expect": { "tier": "full", "reasons": ["est_files"] } },
|
|
31
|
-
{ "name": "modules 2 is not over the line", "set": { "T1": false, "modules_touched": 2 }, "expect": { "tier": "small", "reasons": ["T1", "modules_touched"] } },
|
|
32
|
-
{ "name": "modules 3 is full", "set": { "T1": false, "modules_touched": 3 }, "expect": { "tier": "full", "reasons": ["modules_touched"] } },
|
|
33
|
-
{ "name": "one file but 300 lines: size rule beats the trivial rule", "set": { "est_diff_lines": 300 }, "expect": { "tier": "full", "reasons": ["est_diff_lines"] } },
|
|
34
|
-
{ "name": "one file in three modules: T1 contradicted, size rule fires", "set": { "modules_touched": 3 }, "expect": { "tier": "full", "invalid": ["T1"], "reasons": ["modules_touched"] } },
|
|
35
|
-
{ "name": "hard surface alone", "set": { "hard_surface": true }, "expect": { "tier": "full", "reasons": ["hard_surface"] } },
|
|
36
|
-
{ "name": "design open alone", "set": { "design_open": true }, "expect": { "tier": "full", "reasons": ["design_open"] } },
|
|
37
|
-
{ "name": "one open question", "set": { "open_questions": 1 }, "expect": { "tier": "full", "reasons": ["open_questions"] } },
|
|
38
|
-
{ "name": "acceptance not testable", "set": { "acceptance_testable": false }, "expect": { "tier": "full", "reasons": ["acceptance_testable"] } },
|
|
39
|
-
{ "name": "existing work item", "set": { "existing_work_item": true }, "expect": { "tier": "full", "reasons": ["existing_work_item"] } },
|
|
40
|
-
{ "name": "brief exists", "set": { "brief_exists": true }, "expect": { "tier": "full", "reasons": ["brief_exists"] } },
|
|
41
|
-
{ "name": "work item beats the sensitive_core rule in reasons, floor still set", "set": { "T3": false, "existing_work_item": true, "sensitive_core": true }, "expect": { "tier": "full", "floor": "full", "reasons": ["existing_work_item"], "securityLens": true } },
|
|
42
|
-
{ "name": "sensitive_core rule beats the hard-surface rule", "set": { "T3": false, "hard_surface": true, "sensitive_core": true }, "expect": { "tier": "full", "floor": "full", "reasons": ["sensitive_core"], "securityLens": true } },
|
|
43
|
-
{ "name": "hard-surface rule beats the size rule", "set": { "hard_surface": true, "est_diff_lines": 900 }, "expect": { "tier": "full", "reasons": ["hard_surface"] } },
|
|
44
|
-
{ "name": "several rule-three signals are all named", "set": { "hard_surface": true, "open_questions": 2, "T4": false }, "expect": { "tier": "full", "reasons": ["hard_surface", "open_questions", "T4"] } },
|
|
45
|
-
{ "name": "T1 unknown: worst case, small", "set": { "T1": "unknown" }, "expect": { "tier": "small", "unknown": ["T1"], "reasons": ["T1"] } },
|
|
46
|
-
{ "name": "T3 null: at least small with the security lens, no floor", "set": { "T3": null }, "expect": { "tier": "small", "unknown": ["T3"], "reasons": ["T3"], "basis": ["T1", "T2", "T4", "T5", "sensitive_core", "hard_surface", "design_open", "open_questions", "acceptance_testable", "modules_touched", "est_files", "est_diff_lines", "existing_work_item", "brief_exists"], "securityLens": true } },
|
|
47
|
-
{ "name": "T4 unknown goes full", "set": { "T4": "unknown" }, "expect": { "tier": "full", "unknown": ["T4"], "reasons": ["T4"] } },
|
|
48
|
-
{ "name": "est_files missing goes full", "drop": ["est_files"], "expect": { "tier": "full", "invalid": ["est_files"], "reasons": ["est_files"] } },
|
|
49
|
-
{ "name": "hard_surface unknown goes full", "set": { "hard_surface": "unknown" }, "expect": { "tier": "full", "unknown": ["hard_surface"], "reasons": ["hard_surface"] } },
|
|
50
|
-
{ "name": "existing_work_item missing: reason says unknown", "drop": ["existing_work_item"], "expect": { "tier": "full", "invalid": ["existing_work_item"], "reasons": ["existing_work_item_unknown"] } },
|
|
51
|
-
{ "name": "brief_exists unknown: reason says unknown", "set": { "brief_exists": null }, "expect": { "tier": "full", "unknown": ["brief_exists"], "reasons": ["brief_exists_unknown"] } },
|
|
52
|
-
{ "name": "missing evidence on T2 is invalid", "noEvidence": ["T2"], "expect": { "tier": "small", "invalid": ["T2"], "reasons": ["T2"] } },
|
|
53
|
-
{ "name": "whitespace evidence is invalid", "set": { "T5": { "entry": { "value": true, "evidence": " " } } }, "expect": { "tier": "small", "invalid": ["T5"], "reasons": ["T5"] } },
|
|
54
|
-
{ "name": "evidence of exactly 300 characters is accepted", "set": { "T5": { "entry": { "value": true, "evidence": "ABCDEFGHIJ" } } }, "evidenceLength": { "T5": 300 }, "expect": { "tier": "trivial", "reasons": [] } },
|
|
55
|
-
{ "name": "evidence of 301 characters is invalid", "set": { "T5": { "entry": { "value": true, "evidence": "x" } } }, "evidenceLength": { "T5": 301 }, "expect": { "tier": "small", "invalid": ["T5"], "reasons": ["T5"] } },
|
|
56
|
-
{ "name": "newline in evidence is invalid", "set": { "T5": { "entry": { "value": true, "evidence": "a\nb" } } }, "expect": { "tier": "small", "invalid": ["T5"], "reasons": ["T5"] } },
|
|
57
|
-
{ "name": "control character in evidence is invalid", "set": { "T5": { "entry": { "value": true, "evidence": "a\u001b[31mb" } } }, "expect": { "tier": "small", "invalid": ["T5"], "reasons": ["T5"] } },
|
|
58
|
-
{ "name": "C1 control U+009B in evidence is invalid", "set": { "T5": { "entry": { "value": true, "evidence": "a\u009bb" } } }, "expect": { "tier": "small", "invalid": ["T5"], "reasons": ["T5"] } },
|
|
59
|
-
{ "name": "bidi override U+202E in evidence is invalid", "set": { "T5": { "entry": { "value": true, "evidence": "a\u202eb" } } }, "expect": { "tier": "small", "invalid": ["T5"], "reasons": ["T5"] } },
|
|
60
|
-
{ "name": "line separator U+2028 in evidence is invalid", "set": { "T5": { "entry": { "value": true, "evidence": "a\u2028b" } } }, "expect": { "tier": "small", "invalid": ["T5"], "reasons": ["T5"] } },
|
|
61
|
-
{ "name": "zero-width space U+200B in evidence is invalid", "set": { "T5": { "entry": { "value": true, "evidence": "a\u200bb" } } }, "expect": { "tier": "small", "invalid": ["T5"], "reasons": ["T5"] } },
|
|
62
|
-
{ "name": "byte order mark U+FEFF in evidence is invalid", "set": { "T5": { "entry": { "value": true, "evidence": "a\ufeffb" } } }, "expect": { "tier": "small", "invalid": ["T5"], "reasons": ["T5"] } },
|
|
63
|
-
{ "name": "Arabic letter mark U+061C in evidence is invalid", "set": { "T5": { "entry": { "value": true, "evidence": "a\u061cb" } } }, "expect": { "tier": "small", "invalid": ["T5"], "reasons": ["T5"] } },
|
|
64
|
-
{ "name": "bidi isolate U+2066 in evidence is invalid", "set": { "T5": { "entry": { "value": true, "evidence": "a\u2066b" } } }, "expect": { "tier": "small", "invalid": ["T5"], "reasons": ["T5"] } },
|
|
65
|
-
{ "name": "string 'true' is malformed", "set": { "T1": "true" }, "expect": { "tier": "small", "invalid": ["T1"], "reasons": ["T1"] } },
|
|
66
|
-
{ "name": "negative open_questions is invalid", "set": { "open_questions": -1 }, "expect": { "tier": "full", "invalid": ["open_questions"], "reasons": ["open_questions"] } },
|
|
67
|
-
{ "name": "est_files 0 is invalid", "set": { "est_files": 0 }, "expect": { "tier": "full", "invalid": ["est_files"], "reasons": ["est_files"] } },
|
|
68
|
-
{ "name": "modules_touched 0 is invalid", "set": { "modules_touched": 0 }, "expect": { "tier": "full", "invalid": ["modules_touched"], "reasons": ["modules_touched"] } },
|
|
69
|
-
{ "name": "est_diff_lines 0 is invalid", "set": { "est_diff_lines": 0 }, "expect": { "tier": "full", "invalid": ["est_diff_lines"], "reasons": ["est_diff_lines"] } },
|
|
70
|
-
{ "name": "fractional count is invalid", "set": { "est_diff_lines": 1.5 }, "expect": { "tier": "full", "invalid": ["est_diff_lines"], "reasons": ["est_diff_lines"] } },
|
|
71
|
-
{ "name": "numeric string count is invalid", "set": { "modules_touched": "1" }, "expect": { "tier": "full", "invalid": ["modules_touched"], "reasons": ["modules_touched"] } },
|
|
72
|
-
{ "name": "unsafe huge count is invalid", "set": { "est_files": 1e300 }, "expect": { "tier": "full", "invalid": ["est_files"], "reasons": ["est_files"] } },
|
|
73
|
-
{ "name": "boolean given for a count is invalid", "set": { "est_files": true }, "expect": { "tier": "full", "invalid": ["est_files"], "reasons": ["est_files"] } },
|
|
74
|
-
{ "name": "entry given as a bare value", "set": { "T1": { "entry": true } }, "expect": { "tier": "small", "invalid": ["T1"], "reasons": ["T1"] } },
|
|
75
|
-
{ "name": "entry given as an array", "set": { "T2": { "entry": [] } }, "expect": { "tier": "small", "invalid": ["T2"], "reasons": ["T2"] } },
|
|
76
|
-
{ "name": "unrelated extra key is ignored", "set": { "tier": { "entry": { "value": "trivial", "evidence": "x" } } }, "expect": { "tier": "trivial", "reasons": [] } },
|
|
77
|
-
{ "name": "empty object: every id invalid", "raw": {}, "expect": { "tier": "full", "floor": "full", "invalid": "ALL", "reasons": ["existing_work_item_unknown", "brief_exists_unknown"], "securityLens": true } },
|
|
78
|
-
{ "name": "null input is refused", "raw": null, "expect": { "tier": "full", "floor": "full", "invalid": "ALL", "reasons": ["signals_unreadable"], "securityLens": true } },
|
|
79
|
-
{ "name": "array input is refused", "raw": [], "expect": { "tier": "full", "floor": "full", "invalid": "ALL", "reasons": ["signals_unreadable"], "securityLens": true } },
|
|
80
|
-
{ "name": "string input is refused", "raw": "trivial", "expect": { "tier": "full", "floor": "full", "invalid": "ALL", "reasons": ["signals_unreadable"], "securityLens": true } },
|
|
81
|
-
{ "name": "number input is refused", "raw": 7, "expect": { "tier": "full", "floor": "full", "invalid": "ALL", "reasons": ["signals_unreadable"], "securityLens": true } },
|
|
82
|
-
{ "name": "T1-proration corpus: argument checks in a pure function; untrusted input only", "set": { "T2": false, "T3": false, "est_diff_lines": 80 }, "expect": { "tier": "small", "securityLens": true, "reasons": ["T2", "T3", "est_diff_lines"] } },
|
|
83
|
-
{ "name": "sensitive_core alone sets the floor", "set": { "T3": false, "sensitive_core": true }, "expect": { "tier": "full", "floor": "full", "securityLens": true, "reasons": ["sensitive_core"], "basis": ["T3", "sensitive_core"] } },
|
|
84
|
-
{ "name": "sensitive_core null: floor holds", "set": { "sensitive_core": null }, "expect": { "tier": "full", "floor": "full", "securityLens": true, "unknown": ["sensitive_core"], "reasons": ["sensitive_core"], "basis": ["T3"] } },
|
|
85
|
-
{ "name": "T3 claimed true while sensitive_core is true: the T3 claim is not believed", "set": { "sensitive_core": true }, "expect": { "tier": "full", "floor": "full", "securityLens": true, "invalid": ["T3"], "reasons": ["sensitive_core"] } }
|
|
86
|
-
]
|
|
87
|
-
}
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# End-to-end tests for scripts/generate-digest.mjs.
|
|
3
|
-
#
|
|
4
|
-
# The digest lives in three files and drifted once already — the Copilot copy was missing a whole
|
|
5
|
-
# bullet and nothing could see it. The generator exists to make that unrepresentable, so it needs a
|
|
6
|
-
# regression guard of its own; manual mutation testing evaporates at the end of a session.
|
|
7
|
-
#
|
|
8
|
-
# Runs the real script against a throwaway repo whose layout mirrors this one (rules/CLAUDE.md
|
|
9
|
-
# canonical + two targets at different depths), so the per-target prefix transform is exercised for
|
|
10
|
-
# BOTH targets independently — getting one right and the other wrong is exactly the silent-drift
|
|
11
|
-
# class this script removes.
|
|
12
|
-
#
|
|
13
|
-
# Wired into scripts/validate.sh (npm test).
|
|
14
|
-
|
|
15
|
-
set -euo pipefail
|
|
16
|
-
|
|
17
|
-
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
18
|
-
GEN="$ROOT/scripts/generate-digest.mjs"
|
|
19
|
-
|
|
20
|
-
TMP="$(mktemp -d)"
|
|
21
|
-
trap 'rm -rf "$TMP"' EXIT
|
|
22
|
-
|
|
23
|
-
failures=0
|
|
24
|
-
total=0
|
|
25
|
-
check() { # $1 = name, $2 = 0/1 pass
|
|
26
|
-
total=$((total + 1))
|
|
27
|
-
if [[ "$2" != "0" ]]; then
|
|
28
|
-
echo "FAIL: $1" >&2
|
|
29
|
-
failures=$((failures + 1))
|
|
30
|
-
fi
|
|
31
|
-
}
|
|
32
|
-
expect_exit() { # $1 = name, $2 = expected code, then the command …
|
|
33
|
-
local name="$1" want="$2" got=0; shift 2
|
|
34
|
-
"$@" >/dev/null 2>&1 || got=$?
|
|
35
|
-
if [[ "$got" != "$want" ]]; then
|
|
36
|
-
echo "FAIL: $name — expected exit $want, got $got" >&2
|
|
37
|
-
failures=$((failures + 1))
|
|
38
|
-
fi
|
|
39
|
-
total=$((total + 1))
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
# --- throwaway repo mirroring this one's layout --------------------------------
|
|
43
|
-
# The generator resolves paths from its own location (../ = repo root), so the fixture repo gets a
|
|
44
|
-
# copy of the script rather than the fixture being pointed at the real repo.
|
|
45
|
-
REPO="$TMP/repo"
|
|
46
|
-
mkdir -p "$REPO/scripts" "$REPO/rules" "$REPO/.github"
|
|
47
|
-
cp "$GEN" "$REPO/scripts/generate-digest.mjs"
|
|
48
|
-
for n in 00-priorities 20-clean-code; do printf '# %s\n' "$n" > "$REPO/rules/$n.md"; done
|
|
49
|
-
|
|
50
|
-
write_canonical() { # $1 = extra bullet or ""
|
|
51
|
-
cat > "$REPO/rules/CLAUDE.md" <<EOF
|
|
52
|
-
# Rules
|
|
53
|
-
|
|
54
|
-
## Always-on digest
|
|
55
|
-
|
|
56
|
-
Framing paragraph that must NOT be copied into the targets.
|
|
57
|
-
|
|
58
|
-
<!-- digest:start -->
|
|
59
|
-
- **Priorities:** first. ([\`00\`](./00-priorities.md))
|
|
60
|
-
- **Clean code:** second. ([\`20\`](./20-clean-code.md))${1:+
|
|
61
|
-
$1}
|
|
62
|
-
<!-- digest:end -->
|
|
63
|
-
|
|
64
|
-
## Composition
|
|
65
|
-
EOF
|
|
66
|
-
}
|
|
67
|
-
write_targets() {
|
|
68
|
-
printf '# Agents\n\n## Always-on digest\n\nSTALE\n\n## After\n\nkeep me\n' > "$REPO/AGENTS.md"
|
|
69
|
-
printf '# Copilot\n\n## Always-on digest\n\nSTALE\n\n## After\n\nkeep me\n' > "$REPO/.github/copilot-instructions.md"
|
|
70
|
-
}
|
|
71
|
-
write_canonical ""
|
|
72
|
-
write_targets
|
|
73
|
-
|
|
74
|
-
GENC="$REPO/scripts/generate-digest.mjs"
|
|
75
|
-
|
|
76
|
-
# --- drift is detected, then fixed ---------------------------------------------
|
|
77
|
-
expect_exit "check reports drift before first generate" 1 node "$GENC" --check
|
|
78
|
-
expect_exit "generate succeeds" 0 node "$GENC"
|
|
79
|
-
expect_exit "check is clean after generate" 0 node "$GENC" --check
|
|
80
|
-
|
|
81
|
-
# --- BOTH targets transformed, each with its own prefix -------------------------
|
|
82
|
-
# The whole point of a per-target prefix: root-level AGENTS.md needs ./rules/, and
|
|
83
|
-
# .github/copilot-instructions.md one level down needs ../rules/. A generator that got one right
|
|
84
|
-
# and the other wrong would still report "in sync".
|
|
85
|
-
check "AGENTS.md uses ./rules/ prefix" \
|
|
86
|
-
"$(grep -qF '](./rules/00-priorities.md)' "$REPO/AGENTS.md"; echo $?)"
|
|
87
|
-
check "AGENTS.md has no ../rules/ prefix" \
|
|
88
|
-
"$(! grep -qF '](../rules/' "$REPO/AGENTS.md"; echo $?)"
|
|
89
|
-
check "copilot copy uses ../rules/ prefix" \
|
|
90
|
-
"$(grep -qF '](../rules/00-priorities.md)' "$REPO/.github/copilot-instructions.md"; echo $?)"
|
|
91
|
-
check "copilot copy has no ./rules/ prefix" \
|
|
92
|
-
"$(! grep -qF '](./rules/' "$REPO/.github/copilot-instructions.md"; echo $?)"
|
|
93
|
-
|
|
94
|
-
# --- the framing paragraph and following sections are NOT copied/clobbered ------
|
|
95
|
-
check "framing paragraph not copied into target" \
|
|
96
|
-
"$(! grep -q 'must NOT be copied' "$REPO/AGENTS.md"; echo $?)"
|
|
97
|
-
check "content after the digest section preserved" \
|
|
98
|
-
"$(grep -q 'keep me' "$REPO/AGENTS.md"; echo $?)"
|
|
99
|
-
check "stale content replaced" \
|
|
100
|
-
"$(! grep -q 'STALE' "$REPO/AGENTS.md"; echo $?)"
|
|
101
|
-
|
|
102
|
-
# --- a new canonical bullet propagates to both ----------------------------------
|
|
103
|
-
write_canonical '- **Third:** added. ([`00`](./00-priorities.md))'
|
|
104
|
-
expect_exit "check detects a new canonical bullet" 1 node "$GENC" --check
|
|
105
|
-
node "$GENC" >/dev/null
|
|
106
|
-
check "new bullet reached AGENTS.md" \
|
|
107
|
-
"$(grep -q 'Third' "$REPO/AGENTS.md"; echo $?)"
|
|
108
|
-
check "new bullet reached copilot copy" \
|
|
109
|
-
"$(grep -q 'Third' "$REPO/.github/copilot-instructions.md"; echo $?)"
|
|
110
|
-
|
|
111
|
-
# --- drift in EITHER target alone is caught -------------------------------------
|
|
112
|
-
# The original defect was one copy silently missing a bullet.
|
|
113
|
-
perl -0pi -e 's/- \*\*Third:.*\n//' "$REPO/AGENTS.md"
|
|
114
|
-
expect_exit "drift in AGENTS.md alone is caught" 1 node "$GENC" --check
|
|
115
|
-
node "$GENC" >/dev/null
|
|
116
|
-
perl -0pi -e 's/- \*\*Third:.*\n//' "$REPO/.github/copilot-instructions.md"
|
|
117
|
-
expect_exit "drift in the copilot copy alone is caught" 1 node "$GENC" --check
|
|
118
|
-
node "$GENC" >/dev/null
|
|
119
|
-
|
|
120
|
-
# --- malformed inputs fail loudly, never with a raw stack trace ------------------
|
|
121
|
-
cp "$REPO/rules/CLAUDE.md" "$TMP/canon.bak"
|
|
122
|
-
perl -0pi -e 's/<!-- digest:end -->/<!-- digest:ended -->/' "$REPO/rules/CLAUDE.md"
|
|
123
|
-
err="$(node "$GENC" --check 2>&1 || true)"
|
|
124
|
-
check "malformed markers give a clean error, not a stack trace" \
|
|
125
|
-
"$([[ "$err" == *"generate-digest:"* && "$err" != *"at Object."* && "$err" != *" at "* ]]; echo $?)"
|
|
126
|
-
cp "$TMP/canon.bak" "$REPO/rules/CLAUDE.md"
|
|
127
|
-
|
|
128
|
-
# --- a duplicate heading is ambiguous, not silently first-wins -------------------
|
|
129
|
-
cp "$REPO/AGENTS.md" "$TMP/agents.bak"
|
|
130
|
-
printf '\n## Always-on digest\n\nstray\n' >> "$REPO/AGENTS.md"
|
|
131
|
-
err="$(node "$GENC" --check 2>&1 || true)"
|
|
132
|
-
check "duplicate heading is rejected as ambiguous" \
|
|
133
|
-
"$([[ "$err" == *"ambiguous"* ]]; echo $?)"
|
|
134
|
-
cp "$TMP/agents.bak" "$REPO/AGENTS.md"
|
|
135
|
-
|
|
136
|
-
# --- a heading MENTIONED in prose does not hijack the anchor ---------------------
|
|
137
|
-
perl -0pi -e 's/^# Agents$/# Agents\n\nSee the ## Always-on digest section below./m' "$REPO/AGENTS.md"
|
|
138
|
-
expect_exit "prose mentioning the heading does not hijack the anchor" 0 node "$GENC" --check
|
|
139
|
-
check "the prose mention survived intact" \
|
|
140
|
-
"$(grep -q 'See the ## Always-on digest section below.' "$REPO/AGENTS.md"; echo $?)"
|
|
141
|
-
|
|
142
|
-
# --- retarget() rewrites ONLY citations, never other relative links -------------
|
|
143
|
-
# An unanchored `](./` pattern rewrote every relative link in a bullet: a prose link became
|
|
144
|
-
# ./rules/docs/GUIDE.md in one copy and ../rules/docs/GUIDE.md in the other — both dead — while
|
|
145
|
-
# --check reported "in sync". The hook exists to keep prose links in bullets intact, so
|
|
146
|
-
# an unanchored rewrite here put the two halves of that seam in disagreement.
|
|
147
|
-
write_canonical '- **Guide:** see [guide](./docs/GUIDE.md) first. ([`20`](./20-clean-code.md))'
|
|
148
|
-
node "$GENC" >/dev/null
|
|
149
|
-
check "prose link survives untouched in AGENTS.md" \
|
|
150
|
-
"$(grep -qF '[guide](./docs/GUIDE.md)' "$REPO/AGENTS.md"; echo $?)"
|
|
151
|
-
check "prose link survives untouched in the copilot copy" \
|
|
152
|
-
"$(grep -qF '[guide](./docs/GUIDE.md)' "$REPO/.github/copilot-instructions.md"; echo $?)"
|
|
153
|
-
check "the citation beside it still retargets (AGENTS.md)" \
|
|
154
|
-
"$(grep -qF '](./rules/20-clean-code.md)' "$REPO/AGENTS.md"; echo $?)"
|
|
155
|
-
check "the citation beside it still retargets (copilot copy)" \
|
|
156
|
-
"$(grep -qF '](../rules/20-clean-code.md)' "$REPO/.github/copilot-instructions.md"; echo $?)"
|
|
157
|
-
write_canonical ""
|
|
158
|
-
node "$GENC" >/dev/null
|
|
159
|
-
|
|
160
|
-
# --- a fenced `## ` inside the digest section does not terminate the splice ------
|
|
161
|
-
# The fence sits INSIDE the digest section, which is generated territory — so correct behaviour is
|
|
162
|
-
# that the whole fence is REPLACED, leaving the following section untouched.
|
|
163
|
-
#
|
|
164
|
-
# Without fence tracking, `## Not a real heading` reads as the next heading: the splice ends there,
|
|
165
|
-
# the opening ``` (before it) is swallowed as generated content, and the fake heading plus the
|
|
166
|
-
# CLOSING ``` survive as an orphan — an unbalanced fence — while `--check` still reports "in sync".
|
|
167
|
-
# So the discriminator is the presence of that debris, not the survival of the fence.
|
|
168
|
-
cp "$REPO/AGENTS.md" "$TMP/agents-fence.bak"
|
|
169
|
-
perl -0pi -e 's/^## After$/```md\n## Not a real heading\n```\n\n## After/m' "$REPO/AGENTS.md"
|
|
170
|
-
node "$GENC" >/dev/null 2>&1 || true
|
|
171
|
-
check "fenced '## ' did not terminate the splice early (no orphan heading)" \
|
|
172
|
-
"$(! grep -q 'Not a real heading' "$REPO/AGENTS.md"; echo $?)"
|
|
173
|
-
check "no unbalanced fence left behind" \
|
|
174
|
-
"$([[ $(grep -c '^```' "$REPO/AGENTS.md") -eq 0 ]]; echo $?)"
|
|
175
|
-
check "section following the fence survived" \
|
|
176
|
-
"$(grep -q 'keep me' "$REPO/AGENTS.md"; echo $?)"
|
|
177
|
-
cp "$TMP/agents-fence.bak" "$REPO/AGENTS.md"
|
|
178
|
-
|
|
179
|
-
echo "generate-digest tests: $((total - failures)) of $total checks passed."
|
|
180
|
-
[[ "$failures" -eq 0 ]] || exit 1
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Guard for the global config and the merge (scripts/lib/config-files.mjs) and for reads through links:
|
|
3
|
-
# the loader on its own, then every consumer that must see the merged config -- the resolver, the
|
|
4
|
-
# somi-config CLI, the SessionStart default-config hook, the cost-lowering hook and the hooks' config().
|
|
5
|
-
# Every case sets SOMI_GLOBAL_CONFIG itself, so a real global config on the machine never leaks in.
|
|
6
|
-
set -uo pipefail
|
|
7
|
-
|
|
8
|
-
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
9
|
-
LIB="$ROOT/scripts/lib/config-files.mjs"
|
|
10
|
-
CLI="$ROOT/scripts/somi-config.mjs"
|
|
11
|
-
DISPATCH="$ROOT/scripts/somi-dispatch.mjs"
|
|
12
|
-
ENSURE="$ROOT/hooks/session-start/ensure-default-config.mjs"
|
|
13
|
-
GUARD="$ROOT/hooks/pre-tool/guard-cost-lowering.mjs"
|
|
14
|
-
|
|
15
|
-
pass=0; fail=0
|
|
16
|
-
ok() { pass=$((pass+1)); printf ' ok %s\n' "$1"; }
|
|
17
|
-
bad() { fail=$((fail+1)); printf ' FAIL %s\n' "$1"; }
|
|
18
|
-
check() { if [ "$2" = "$3" ]; then ok "$1"; else bad "$1 (want '$3', got '$2')"; fi; }
|
|
19
|
-
|
|
20
|
-
TMP="$(mktemp -d)"
|
|
21
|
-
trap 'rm -rf "$TMP"' EXIT
|
|
22
|
-
proj() { mktemp -d -p "$TMP"; }
|
|
23
|
-
node_lib() { SOMI_GLOBAL_CONFIG="${G:-}" node --input-type=module -e "import * as L from '$LIB'; $1"; }
|
|
24
|
-
|
|
25
|
-
echo "== global config: the loader =="
|
|
26
|
-
|
|
27
|
-
check "SOMI_GLOBAL_CONFIG names the file" "$(SOMI_GLOBAL_CONFIG=/x/y.json node --input-type=module -e "import {globalConfigPath} from '$LIB'; process.stdout.write(String(globalConfigPath()))")" "/x/y.json"
|
|
28
|
-
check "an empty SOMI_GLOBAL_CONFIG means no global config" "$(SOMI_GLOBAL_CONFIG= node --input-type=module -e "import {globalConfigPath} from '$LIB'; process.stdout.write(String(globalConfigPath()))")" "null"
|
|
29
|
-
check "platform defaults: XDG, ~/.config, %APPDATA%" "$(node --input-type=module -e "
|
|
30
|
-
import {globalConfigPath as g} from '$LIB';
|
|
31
|
-
process.stdout.write([g({XDG_CONFIG_HOME:'/xdg'},'linux','/h'), g({XDG_CONFIG_HOME:'rel'},'linux','/h'), g({},'darwin','/h'), g({APPDATA:'C:/A'},'win32','C:/h')].join('|'))")" \
|
|
32
|
-
"/xdg/somi/config.json|/h/.config/somi/config.json|/h/.config/somi/config.json|C:/A/somi/config.json"
|
|
33
|
-
|
|
34
|
-
check "merge: the user's example (project changes only somi-coder and the medium mapping)" "$(node_lib "
|
|
35
|
-
const g = {cost:{ceiling:'medium',agents:{'somi-coder':'medium','somi-reviewer':'high'},mapping:{'copilot-cli':{low:['a'],medium:['b','c'],high:['d']}}},dep_install:{allow:['x']}};
|
|
36
|
-
const p = {cost:{agents:{'somi-coder':'high'},mapping:{'copilot-cli':{medium:['z']}}}};
|
|
37
|
-
const m = L.mergeConfig(g, p);
|
|
38
|
-
process.stdout.write(JSON.stringify(m) + '|' + g.cost.agents['somi-coder'] + '|' + JSON.stringify(p))")" \
|
|
39
|
-
'{"cost":{"ceiling":"medium","agents":{"somi-coder":"high","somi-reviewer":"high"},"mapping":{"copilot-cli":{"low":["a"],"medium":["z"],"high":["d"]}}},"dep_install":{"allow":["x"]}}|medium|{"cost":{"agents":{"somi-coder":"high"},"mapping":{"copilot-cli":{"medium":["z"]}}}}'
|
|
40
|
-
check "merge: arrays, scalars and null replace; objects merge" "$(node_lib "
|
|
41
|
-
process.stdout.write(JSON.stringify(L.mergeConfig({a:[1,2],b:{c:1,d:2},e:'x',f:{g:1}}, {a:[3],b:{d:3},e:null,f:5})))")" \
|
|
42
|
-
'{"a":[3],"b":{"c":1,"d":3},"e":null,"f":5}'
|
|
43
|
-
check "merge: a __proto__ key stays data and pollutes nothing" "$(node_lib "
|
|
44
|
-
const m = L.mergeConfig({}, JSON.parse('{\"__proto__\":{\"polluted\":1},\"cost\":{\"__proto__\":{\"x\":1}}}'));
|
|
45
|
-
process.stdout.write([String(({}).polluted), Object.getPrototypeOf(m) === Object.prototype, Object.hasOwn(m, '__proto__'), Object.getPrototypeOf(m.cost) === Object.prototype].join(','))")" \
|
|
46
|
-
"undefined,true,true,true"
|
|
47
|
-
|
|
48
|
-
P="$(proj)"; mkdir "$P/.somi"
|
|
49
|
-
check "absent files read as unconfigured" "$(G="$TMP/none.json" node_lib "const r = L.loadConfig('$P'); process.stdout.write(JSON.stringify([r.config, r.global.present, r.project.present]))")" '[{},false,false]'
|
|
50
|
-
printf '{"cost":{"ceiling":"high"}}' > "$TMP/g1.json"; printf '{"cost":{"agents":{"somi-coder":"low"}}}' > "$P/.somi/config.json"
|
|
51
|
-
check "global and project merge, each file reported" "$(G="$TMP/g1.json" node_lib "const r = L.loadConfig('$P'); process.stdout.write(JSON.stringify([r.config, r.global.present, r.project.present]))")" \
|
|
52
|
-
'[{"cost":{"ceiling":"high","agents":{"somi-coder":"low"}}},true,true]'
|
|
53
|
-
P="$(proj)"; SHARED="$(mktemp -d -p "$TMP")"; printf '{"cost":{"ceiling":"low"}}' > "$SHARED/config.json"; ln -s "$SHARED" "$P/.somi"
|
|
54
|
-
check "a symlinked .somi (a junction on Windows) is read through" "$(G= node_lib "process.stdout.write(L.loadConfig('$P').config.cost.ceiling)")" "low"
|
|
55
|
-
ln -s "$SHARED/config.json" "$TMP/linked.json"
|
|
56
|
-
check "a symlinked global config is read through" "$(G="$TMP/linked.json" node_lib "process.stdout.write(L.loadConfig('$(proj)').config.cost.ceiling)")" "low"
|
|
57
|
-
ln -s "$TMP/gone.json" "$TMP/dangling.json"
|
|
58
|
-
check "a dangling link is an error, not 'no config'" "$(G="$TMP/dangling.json" node_lib "try { L.loadConfig('$(proj)'); console.log('read'); } catch (e) { console.log(e instanceof L.ConfigFileError && /link to a missing file/.test(e.message) ? 'refused' : e.message); }")" "refused"
|
|
59
|
-
mkdir "$TMP/dir.json"
|
|
60
|
-
check "a directory is not a config" "$(G="$TMP/dir.json" node_lib "try { L.loadConfig('$(proj)'); console.log('read'); } catch (e) { console.log(/not a regular file/.test(e.message) ? 'refused' : e.message); }")" "refused"
|
|
61
|
-
mkfifo "$TMP/fifo.json"; rc=0
|
|
62
|
-
out="$(G="$TMP/fifo.json" timeout 5 node --input-type=module -e "import * as L from '$LIB'; process.env.SOMI_GLOBAL_CONFIG='$TMP/fifo.json'; try { L.loadConfig('$(proj)'); console.log('read'); } catch (e) { console.log(/not a regular file/.test(e.message) ? 'refused' : e.message); }")" || rc=$?
|
|
63
|
-
check "a FIFO is refused without blocking" "$rc|$out" "0|refused"
|
|
64
|
-
{ printf '{"pad":"'; head -c 70000 /dev/zero | tr '\0' x; printf '"}'; } > "$TMP/big.json"
|
|
65
|
-
check "an oversize global config is refused" "$(G="$TMP/big.json" node_lib "try { L.loadConfig('$(proj)'); console.log('read'); } catch (e) { console.log(/byte limit/.test(e.message) ? 'refused' : e.message); }")" "refused"
|
|
66
|
-
printf '\x1b[31mSECRET {nope' > "$TMP/bad.json"
|
|
67
|
-
msg="$(G="$TMP/bad.json" node_lib "try { L.loadConfig('$(proj)'); } catch (e) { console.log(e.message); }")"
|
|
68
|
-
case "$msg" in *SECRET*|*$'\x1b'*) bad "a parse error leaks file text: $msg" ;; *"not valid JSON"*) ok "a parse error names the file and leaks no text" ;; *) bad "unexpected parse error: $msg" ;; esac
|
|
69
|
-
|
|
70
|
-
node -e "const n=20000; require('fs').writeFileSync('$TMP/deep.json', '{\"deep\":'+'['.repeat(n)+']'.repeat(n)+'}')"
|
|
71
|
-
out="$(SOMI_GLOBAL_CONFIG="$TMP/deep.json" node --stack-size=200 --input-type=module -e "import * as L from '$LIB'; try { L.loadConfig('$(proj)'); console.log('read'); } catch (e) { console.log(e instanceof L.ConfigFileError && /nested deeper/.test(e.message) ? 'refused' : 'crash'); }" 2>&1)"
|
|
72
|
-
check "a config nested 20000 deep is refused cleanly, even on a small stack (CI's Node)" "$out" "refused"
|
|
73
|
-
|
|
74
|
-
echo "== global config: the resolver =="
|
|
75
|
-
resolve() { # $1 = global file, $2 = project, $3.. = resolve args -> stdout JSON
|
|
76
|
-
local g="$1" p="$2"; shift 2
|
|
77
|
-
(cd "$p" && SOMI_GLOBAL_CONFIG="$g" CLAUDE_PROJECT_DIR="$p" env -u SOMI_COST_CEILING node "$DISPATCH" resolve "$@" 2>&1)
|
|
78
|
-
}
|
|
79
|
-
jget() { node -e "const o = JSON.parse(require('fs').readFileSync(0,'utf8')); process.stdout.write(String($1))"; }
|
|
80
|
-
GF="$TMP/global.json"
|
|
81
|
-
printf '%s' '{"cost":{"ceiling":"medium","agents":{"somi-coder":"medium","somi-planner":"high"},"mapping":{"copilot-cli":{"low":["g-low"],"medium":["g-med"],"high":["g-high"]}}}}' > "$GF"
|
|
82
|
-
P="$(proj)"; mkdir "$P/.somi"; printf '%s' '{"cost":{"agents":{"somi-coder":"high"},"mapping":{"copilot-cli":{"medium":["p-med"]}}}}' > "$P/.somi/config.json"
|
|
83
|
-
check "the project overrides somi-coder" "$(resolve "$GF" "$P" --agent somi-coder --host copilot-cli | jget 'o.tier + "," + o.tier_source + "," + o.model')" "high,override,g-high"
|
|
84
|
-
check "an agent the project does not name keeps the global pin" "$(resolve "$GF" "$P" --agent somi-planner --host copilot-cli | jget 'o.tier + "," + o.model')" "high,g-high"
|
|
85
|
-
check "the project's medium mapping replaces the global one; other tiers stay" "$(resolve "$GF" "$P" --agent somi-impact --host copilot-cli | jget 'o.tier + "," + o.model')" "medium,p-med"
|
|
86
|
-
check "the ceiling comes from the global file" "$(resolve "$GF" "$P" --agent somi-impact --host copilot-cli | jget 'o.ceiling + "," + o.ceiling_source')" "medium,config"
|
|
87
|
-
printf '%s' '{"cost":{"celing":"low"}}' > "$TMP/typo.json"; rc=0
|
|
88
|
-
resolve "$TMP/typo.json" "$(proj)" --agent somi-coder > "$TMP/typo.out" || rc=$?
|
|
89
|
-
check "a typo in the global file exits 67 and names that file" "$rc|$(grep -c 'typo.json' "$TMP/typo.out")" "67|1"
|
|
90
|
-
|
|
91
|
-
echo "== global config: somi-config =="
|
|
92
|
-
cfg() { # $1 = global file, $2 = project, $3.. = args -> exit code; stdout in $TMP/out
|
|
93
|
-
local g="$1" p="$2"; shift 2
|
|
94
|
-
SOMI_GLOBAL_CONFIG="$g" env -u SOMI_COST_CEILING node "$CLI" "$@" --project-dir "$p" > "$TMP/out" 2> "$TMP/err"; echo $?
|
|
95
|
-
}
|
|
96
|
-
jf() { node -e "const o = JSON.parse(require('fs').readFileSync('$TMP/out','utf8')); process.stdout.write(typeof ($1) === 'string' ? ($1) : JSON.stringify($1))"; }
|
|
97
|
-
check "show merges both files and says where each value came from" \
|
|
98
|
-
"$(cfg "$GF" "$P" show)|$(jf 'o.global.exists')|$(jf 'o.ceiling.from')|$(jf 'o.agents.find((a) => a.name === "somi-coder").from')|$(jf 'o.agents.find((a) => a.name === "somi-planner").from')" \
|
|
99
|
-
"0|true|global|project|global"
|
|
100
|
-
check "get reads the merged value" "$(cfg "$GF" "$P" get cost.mapping.copilot-cli.medium)|$(jf 'o.value')" '0|["p-med"]'
|
|
101
|
-
|
|
102
|
-
H="$TMP/home"; NG="$H/.config/somi/config.json"
|
|
103
|
-
check "init --global creates the default global file, parents included" "$(cfg "$NG" "$(proj)" init --global)|$(jf 'o.created')|$([ -f "$NG" ] && echo file)" "0|true|file"
|
|
104
|
-
P="$(proj)"
|
|
105
|
-
check "init in a project is a no-op while a global config exists" "$(cfg "$NG" "$P" init)|$(jf 'o.created')|$([ -e "$P/.somi/config.json" ] && echo made || echo none)" "0|false|none"
|
|
106
|
-
check "set --global changes the global file" "$(cfg "$NG" "$P" set cost.agents.somi-coder high --global)|$(node -e "process.stdout.write(JSON.parse(require('fs').readFileSync('$NG','utf8')).cost.agents['somi-coder'])")" "0|high"
|
|
107
|
-
check "a first project set over a global config writes only that key" "$(cfg "$NG" "$P" set cost.agents.somi-pr high)|$(cat "$P/.somi/config.json" | tr -d ' \n')" '0|{"cost":{"agents":{"somi-pr":"high"}}}'
|
|
108
|
-
check "unset of a value only the global file sets changes nothing and says where it lives" "$(cfg "$NG" "$P" unset cost.agents.somi-coder)|$(jf 'o.changed')|$(jf 'String(o.warnings[0].startsWith("that value is set in your global config"))')" "0|false|true"
|
|
109
|
-
check "--global is refused on show" "$(cfg "$NG" "$P" show --global)" "64"
|
|
110
|
-
check "--refuse-lowering judges a project change merged over the global file" "$(cfg "$NG" "$P" set cost.agents.somi-coder low --refuse-lowering)|$(cat "$P/.somi/config.json" | tr -d ' \n')" '64|{"cost":{"agents":{"somi-pr":"high"}}}'
|
|
111
|
-
DOT="$TMP/dotfiles"; mkdir -p "$DOT" "$H/.config/linked"; printf '{"cost":{"ceiling":"medium"}}' > "$DOT/somi.json"; ln -s "$DOT/somi.json" "$H/.config/linked/config.json"
|
|
112
|
-
check "set --global through a dotfiles link writes the real file and keeps the link" \
|
|
113
|
-
"$(cfg "$H/.config/linked/config.json" "$P" set cost.ceiling high --global)|$([ -L "$H/.config/linked/config.json" ] && echo link)|$(node -e "process.stdout.write(JSON.parse(require('fs').readFileSync('$DOT/somi.json','utf8')).cost.ceiling)")" \
|
|
114
|
-
"0|link|high"
|
|
115
|
-
check "with SOMI_GLOBAL_CONFIG empty, --global is a usage error" "$(cfg "" "$P" set cost.ceiling high --global)" "64"
|
|
116
|
-
|
|
117
|
-
echo "== global config: hooks =="
|
|
118
|
-
runhook() { # $1 = hook, $2 = global file, $3 = project; payload on stdin -> stdout
|
|
119
|
-
(cd "$3" && SOMI_GLOBAL_CONFIG="$2" CLAUDE_PROJECT_DIR="$3" node "$1")
|
|
120
|
-
}
|
|
121
|
-
P="$(proj)"
|
|
122
|
-
out="$(printf '{}' | runhook "$ENSURE" "$NG" "$P")"
|
|
123
|
-
check "SessionStart writes no project default while a global config exists" "$([ -e "$P/.somi/config.json" ] && echo made || echo none)" "none"
|
|
124
|
-
printf '{"cost":{"ceiling":"medium","agents":{}}}' > "$TMP/nopin.json"
|
|
125
|
-
out="$(printf '{}' | runhook "$ENSURE" "$TMP/nopin.json" "$(proj)")"
|
|
126
|
-
case "$out" in *"your global config"*"no cost.agents pin for somi-security-reviewer"*) ok "the pin notice reads the merged config and names the global file" ;; *) bad "the pin notice reads the merged config and names the global file ($out)" ;; esac
|
|
127
|
-
P="$(proj)"; mkdir "$P/.somi"; printf '{"cost":{"agents":{"somi-security-reviewer":"high"}}}' > "$P/.somi/config.json"
|
|
128
|
-
check "... and a project pin satisfies it" "$(printf '{}' | runhook "$ENSURE" "$TMP/nopin.json" "$P")" ""
|
|
129
|
-
|
|
130
|
-
verdict() { # $1 = global file, $2 = project, $3 = payload -> ask | allow
|
|
131
|
-
local out; out="$(printf '%s' "$3" | runhook "$GUARD" "$1" "$2")"
|
|
132
|
-
case "$out" in *'"permissionDecision":"ask"'*) echo ask ;; *) echo allow ;; esac
|
|
133
|
-
}
|
|
134
|
-
wr() { node -e "process.stdout.write(JSON.stringify({tool_name:'Write',tool_input:{file_path:process.argv[1],content:process.argv[2]}}))" "$1" "$2"; }
|
|
135
|
-
GP="$TMP/gp.json"; printf '{"cost":{"ceiling":"medium","agents":{"somi-security-reviewer":"high","somi-coder":"high"}}}' > "$GP"
|
|
136
|
-
P="$(proj)"; mkdir "$P/.somi"; printf '{}' > "$P/.somi/config.json"
|
|
137
|
-
check "a tool write to the global config always asks" "$(verdict "$GP" "$P" "$(wr "$GP" '{"cost":{"ceiling":"high"}}')")" "ask"
|
|
138
|
-
check "... also when the global file does not exist yet" "$(verdict "$TMP/new/somi/config.json" "$P" "$(wr "$TMP/new/somi/config.json" '{}')")" "ask"
|
|
139
|
-
check "a project write that drops below a global pin asks" "$(verdict "$GP" "$P" "$(wr "$P/.somi/config.json" '{"cost":{"agents":{"somi-coder":"low"}}}')")" "ask"
|
|
140
|
-
check "a project write that raises over the global file passes" "$(verdict "$GP" "$P" "$(wr "$P/.somi/config.json" '{"cost":{"ceiling":"high"}}')")" "allow"
|
|
141
|
-
check "an unrelated write passes" "$(verdict "$GP" "$P" "$(wr "$P/notes.txt" 'hi')")" "allow"
|
|
142
|
-
|
|
143
|
-
printf '{"dep_install":{"allow":["left-pad"]},"lockfiles":{"allow_edit":true}}' > "$TMP/policy.json"
|
|
144
|
-
P="$(proj)"; mkdir "$P/.somi"; printf '{"dep_install":{"allow":["is-odd"]}}' > "$P/.somi/config.json"
|
|
145
|
-
check "the hooks' config() sees the merge (project array replaces, global key stays)" "$(cd "$P" && SOMI_GLOBAL_CONFIG="$TMP/policy.json" CLAUDE_PROJECT_DIR="$P" node --input-type=module -e "
|
|
146
|
-
import { config } from '$ROOT/hooks/lib/common.mjs';
|
|
147
|
-
process.stdout.write(JSON.stringify([config('.dep_install.allow[]?'), config('.lockfiles.allow_edit')]))")" '[["is-odd"],"true"]'
|
|
148
|
-
|
|
149
|
-
echo "== global config: red proofs =="
|
|
150
|
-
# Each mutant removes one rule from a copy of the plugin's scripts/ and hooks/; the case it guards must flip.
|
|
151
|
-
mutant() { # $1 = name, $2 = file below the copy, $3 = sed expression
|
|
152
|
-
local d="$TMP/mut-$1"; mkdir -p "$d"; cp -r "$ROOT/scripts" "$ROOT/hooks" "$d/"
|
|
153
|
-
sed -i "$3" "$d/$2"
|
|
154
|
-
cmp -s "$ROOT/$2" "$d/$2" && bad "mutant $1 did not change $2"
|
|
155
|
-
}
|
|
156
|
-
mutant shallow scripts/lib/config-files.mjs 's/isObj(v) \&\& isObj(prev) ? mergeConfig(prev, v) : copy(v)/copy(v)/'
|
|
157
|
-
check "red proof: a shallow merge loses the global pins the project does not name" "$(node --input-type=module -e "
|
|
158
|
-
import * as L from '$TMP/mut-shallow/scripts/lib/config-files.mjs';
|
|
159
|
-
process.stdout.write(String(L.mergeConfig({cost:{agents:{a:'high',b:'high'}}}, {cost:{agents:{a:'low'}}}).cost.agents.b))")" "undefined"
|
|
160
|
-
mutant no-global-ask hooks/pre-tool/guard-cost-lowering.mjs 's/askPretool(payload, GLOBAL_WRITE)/void 0/'
|
|
161
|
-
check "red proof: without its rule a global write is not asked about" "$(out="$(wr "$GP" '{"cost":{"ceiling":"high"}}' | (cd "$P" && SOMI_GLOBAL_CONFIG="$GP" CLAUDE_PROJECT_DIR="$P" node "$TMP/mut-no-global-ask/hooks/pre-tool/guard-cost-lowering.mjs"))"; case "$out" in *ask*) echo ask ;; *) echo allow ;; esac)" "allow"
|
|
162
|
-
mutant no-global-skip hooks/session-start/ensure-default-config.mjs 's/if (existing || hasGlobal) {/if (existing) {/'
|
|
163
|
-
P="$(proj)"; printf '{}' | runhook "$TMP/mut-no-global-skip/hooks/session-start/ensure-default-config.mjs" "$NG" "$P" > /dev/null
|
|
164
|
-
check "red proof: without the global check SessionStart writes a project default that masks it" "$([ -e "$P/.somi/config.json" ] && echo made || echo none)" "made"
|
|
165
|
-
|
|
166
|
-
echo " $pass passed, $fail failed"
|
|
167
|
-
[ "$fail" -eq 0 ]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"slug":"eval-corpus-rebuild","loop":"code","iteration":"3.3","baseline_sha":"d9421b3","started":"2026-09-03T17:33:37Z","status":"stopped-user-stop","caps":{"max_passes":6,"diff_cap_lines":510,"severity_floor":"Major"},"iteration_files":["tests/evals/convergence.mjs","tests/scripts/eval-runner.sh"],"pass":2,"history":[{"pass":1,"verdict":"request-changes","blockers":1,"majors":4,"diff_lines":508,"at":"2026-09-04T05:15:35Z"}],"finished":"2026-09-04T10:24:41Z"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"slug":"context-economy-overhaul","loop":"code","iteration":"2.1","baseline_sha":"40186ed1cd531e5f7cb991aec8d939e475ee3a53","started":"2026-07-27T15:44:46Z","status":"done","caps":{"max_passes":6,"diff_cap_lines":400,"severity_floor":"Major"},"iteration_files":["agents/somi-reviewer.md","docs/AGENTS.md","docs/COMMANDS.md","commands/review.md","commands/test-strategy.md","commands/architecture-review.md","commands/review-panel.md","commands/code-loop.md","docs/WORKFLOWS.md"],"pass":2,"history":[{"pass":2,"verdict":"request-changes","blockers":2,"majors":4,"diff_lines":98,"at":"2026-07-27T15:58:26Z"},{"pass":2,"verdict":"approve","blockers":0,"majors":0,"diff_lines":103,"at":"2026-07-27T16:10:12Z"}],"finished":"2026-07-27T16:10:12Z"}
|