omc-os 0.3.0__tar.gz

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 (68) hide show
  1. omc_os-0.3.0/LICENSE +21 -0
  2. omc_os-0.3.0/PKG-INFO +443 -0
  3. omc_os-0.3.0/README.md +434 -0
  4. omc_os-0.3.0/deploy/seat-runner/Dockerfile +52 -0
  5. omc_os-0.3.0/deploy/seat-runner/README.md +127 -0
  6. omc_os-0.3.0/deploy/seat-runner/__init__.py +4 -0
  7. omc_os-0.3.0/deploy/seat-runner/build.sh +19 -0
  8. omc_os-0.3.0/deploy/seat-runner/entrypoint.sh +53 -0
  9. omc_os-0.3.0/deploy/seat-runner/launch.sh +105 -0
  10. omc_os-0.3.0/deploy/seat-runner/model_api_gateway.py +426 -0
  11. omc_os-0.3.0/deploy/seat-runner/seat_model_client.py +309 -0
  12. omc_os-0.3.0/omc/__init__.py +26 -0
  13. omc_os-0.3.0/omc/__main__.py +15 -0
  14. omc_os-0.3.0/pyproject.toml +65 -0
  15. omc_os-0.3.0/runtime/vcos/__init__.py +61 -0
  16. omc_os-0.3.0/runtime/vcos/ai_bom.py +80 -0
  17. omc_os-0.3.0/runtime/vcos/approval_config.py +176 -0
  18. omc_os-0.3.0/runtime/vcos/artifact_validator.py +62 -0
  19. omc_os-0.3.0/runtime/vcos/assurance.py +108 -0
  20. omc_os-0.3.0/runtime/vcos/charter_builder.py +26 -0
  21. omc_os-0.3.0/runtime/vcos/context_heatmap.py +93 -0
  22. omc_os-0.3.0/runtime/vcos/context_packet.py +141 -0
  23. omc_os-0.3.0/runtime/vcos/contracts.py +199 -0
  24. omc_os-0.3.0/runtime/vcos/corpus.py +276 -0
  25. omc_os-0.3.0/runtime/vcos/decision_ledger.py +178 -0
  26. omc_os-0.3.0/runtime/vcos/decision_tree.py +70 -0
  27. omc_os-0.3.0/runtime/vcos/eval_packs.py +69 -0
  28. omc_os-0.3.0/runtime/vcos/evidence_parsers.py +164 -0
  29. omc_os-0.3.0/runtime/vcos/evidence_registry.py +79 -0
  30. omc_os-0.3.0/runtime/vcos/evidence_store.py +74 -0
  31. omc_os-0.3.0/runtime/vcos/failure_taxonomy.py +109 -0
  32. omc_os-0.3.0/runtime/vcos/guides.py +101 -0
  33. omc_os-0.3.0/runtime/vcos/handoff.py +117 -0
  34. omc_os-0.3.0/runtime/vcos/inner_loop.py +141 -0
  35. omc_os-0.3.0/runtime/vcos/kpi.py +54 -0
  36. omc_os-0.3.0/runtime/vcos/lifecycle.py +100 -0
  37. omc_os-0.3.0/runtime/vcos/lifecycle_conformance.py +317 -0
  38. omc_os-0.3.0/runtime/vcos/loader.py +163 -0
  39. omc_os-0.3.0/runtime/vcos/loop_contract.py +111 -0
  40. omc_os-0.3.0/runtime/vcos/merge_gate.py +515 -0
  41. omc_os-0.3.0/runtime/vcos/merge_queue.py +154 -0
  42. omc_os-0.3.0/runtime/vcos/migrate.py +68 -0
  43. omc_os-0.3.0/runtime/vcos/node_judge.py +434 -0
  44. omc_os-0.3.0/runtime/vcos/observe.py +172 -0
  45. omc_os-0.3.0/runtime/vcos/orchestrate.py +117 -0
  46. omc_os-0.3.0/runtime/vcos/policy.py +81 -0
  47. omc_os-0.3.0/runtime/vcos/recursion_guard.py +115 -0
  48. omc_os-0.3.0/runtime/vcos/reliability.py +110 -0
  49. omc_os-0.3.0/runtime/vcos/review_orchestrator.py +87 -0
  50. omc_os-0.3.0/runtime/vcos/sdd_adapter.py +83 -0
  51. omc_os-0.3.0/runtime/vcos/skill_diff.py +56 -0
  52. omc_os-0.3.0/runtime/vcos/sota_watcher.py +90 -0
  53. omc_os-0.3.0/runtime/vcos/source_truth.py +60 -0
  54. omc_os-0.3.0/runtime/vcos/validators.py +239 -0
  55. omc_os-0.3.0/scripts/merge_discretion_gate.py +744 -0
  56. omc_os-0.3.0/scripts/omc_adapters.py +201 -0
  57. omc_os-0.3.0/scripts/omc_driver.py +970 -0
  58. omc_os-0.3.0/scripts/omc_live.py +527 -0
  59. omc_os-0.3.0/scripts/omc_os.egg-info/PKG-INFO +443 -0
  60. omc_os-0.3.0/scripts/omc_os.egg-info/SOURCES.txt +66 -0
  61. omc_os-0.3.0/scripts/omc_os.egg-info/dependency_links.txt +1 -0
  62. omc_os-0.3.0/scripts/omc_os.egg-info/entry_points.txt +2 -0
  63. omc_os-0.3.0/scripts/omc_os.egg-info/top_level.txt +11 -0
  64. omc_os-0.3.0/scripts/omc_seat_assets.py +145 -0
  65. omc_os-0.3.0/scripts/seat_patch_sanitizer.py +348 -0
  66. omc_os-0.3.0/scripts/seat_preflight.py +180 -0
  67. omc_os-0.3.0/scripts/vcos_autoloop.py +850 -0
  68. omc_os-0.3.0/setup.cfg +4 -0
omc_os-0.3.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 lin-mouren
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
omc_os-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,443 @@
1
+ Metadata-Version: 2.4
2
+ Name: omc-os
3
+ Version: 0.3.0
4
+ Summary: OMC external-driver front door — goal -> dry-run composition plan over the harness modules (Evidence-First agent OS).
5
+ Requires-Python: >=3.9
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Dynamic: license-file
9
+
10
+ # Evidence-First OS for AI Coding Agents
11
+
12
+ [![CI](https://github.com/lin-mouren/evidence-first-os/actions/workflows/ci.yml/badge.svg)](https://github.com/lin-mouren/evidence-first-os/actions/workflows/ci.yml)
13
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
14
+ [![Spec V3](https://img.shields.io/badge/Spec-V3.23-blue)](EVIDENCE-FIRST-OS-COMPLETE-SPEC.md)
15
+
16
+ 🇨🇳 中文版: [README.zh.md](README.zh.md) · 📖 **New here?** See [docs/quickstart.md](docs/quickstart.md) for copy-paste onboarding prompts.
17
+
18
+ 🧩 **Consuming the VCOS runtime in your own project?** See **[docs/CONSUMING-VCOS.md](docs/CONSUMING-VCOS.md)** — the complete end-to-end guide (idea → develop → ship → iterate), observer + harness modes, the `agent_step` protocol, conformance, and shipped-vs-gated boundaries.
19
+
20
+ 📐 **Structuring your own repo for humans + AI agents?** See **[docs/STANDARD-PROJECT-STRUCTURE.md](docs/STANDARD-PROJECT-STRUCTURE.md)** — a portable, evidence-backed world-class standard (AGENTS.md/CLAUDE.md entry · README/ARCHITECTURE/ADR/Diátaxis · navigation-vs-architecture diagrams) you can copy into any project. 可移植的世界级项目结构规范。
21
+
22
+ User-level default configuration that makes **Claude Code + OpenAI Codex** refuse guess-based answers and shallow diagnoses by **default**, in every session, every project.
23
+
24
+ > "Verification > Instruction" (ETH Zurich 2026, arXiv:2602.11988) — long instruction files reduce success rate 3% and cost 20%. This repo enforces evidence-first behavior through **hooks** (deterministic gates), not prose.
25
+
26
+ ## TL;DR — What you get (after `bash install.sh`)
27
+
28
+ - ✅ **Iron Law enforced**: hook-level blocking of unverified facts ("82k stars" without `gh repo view`), shallow fixes (`change line 42` without `Mechanism gap:`), and false completion claims ("done" without `npm test`)
29
+ - ✅ **L0-L4 diagnosis ladder** mandatory for debug tasks (Evidence → Root cause → Mechanism gap → Prevention)
30
+ - ✅ **Stop quality gate**: 7 numbered quality checks + spec archive guard + retired-recap drift guard; a non-blocking recap emitter adds one italic-gray `Stop says: 🛡️ <project> V3 — ...` line on rule-applied turns; set `CODEX_STOP_GATE_ADVISORY=1` to switch the Codex stop gate from hard-block to warn-only
31
+ - ✅ **V3.19' folded routing**: 8-pattern keyword router on every prompt — spec writing emits EARS/grilling pointer, debug emits taxonomy pointer, implement emits Simplicity reminder, goal-criteria emits Goal-Driven reminder
32
+ - ✅ **Audit-grade trace**: `~/.claude/audit/*.log` + `<project>/.ai/evidence.jsonl` prove every hook fire, every prompt classification, every tool call's claim type
33
+ - ✅ **Survives existing setup**: merge-preserve installer keeps your OMC, skill-os, claude-mem, mattpocock, oh-my-codex hooks intact
34
+
35
+ ## One-command install
36
+
37
+ ```bash
38
+ git clone https://github.com/lin-mouren/evidence-first-os.git
39
+ cd evidence-first-os
40
+ bash install.sh
41
+ ```
42
+
43
+ Default behavior (`merge-preserve`):
44
+ - Renames existing `~/.claude/CLAUDE.md` → `~/.claude/OMC.md`, writes new `CLAUDE.md` that `@import`s both
45
+ - Backs up `settings.json` to `*.bak-<timestamp>`, `jq`-merges V3 hooks into existing array (no overwrites)
46
+ - Skills installed only if absent (preserves obra-superpowers `systematic-debugging` etc.)
47
+
48
+ For a clean machine: `bash install.sh --force` overwrites instead of merging.
49
+
50
+ ## Verify install
51
+
52
+ ```bash
53
+ bash verify.sh
54
+ # §9.1 anti-guessing verification PASS
55
+ # §9.2 L0-L4 diagnosis ladder PASS
56
+ # §9.3 completion claim gate PASS
57
+ # §9.5 configuration integrity guard PASS (2 checks)
58
+ # §9.5b reference-integrity scan PASS (3 checks)
59
+ # Positive control PASS
60
+ # §9.6 Codex cross-stack hook smoke PASS (4 checks)
61
+ # §9.7 Stop hook surgical gate PASS (2 checks)
62
+ # §9.8 Project doctor PASS
63
+ # Result: 16 passed, 0 failed
64
+ ```
65
+
66
+ After your next Claude Code session start:
67
+
68
+ ```bash
69
+ tail -3 ~/.claude/audit/session-start.log
70
+ # Expect: "2026-... PWD=... HOOK_EVENT=... matcher=session-start-policy.sh"
71
+ ```
72
+
73
+ ---
74
+
75
+ # 🚀 Recommended efficient usage
76
+
77
+ This is the **single most important section of this README**. Read it before doing real work with V3.
78
+
79
+ ## 1. The daily-driver mental model
80
+
81
+ V3 is invisible until you give it a signal. The signal lives **in your prompt**. Choose your verb wisely; the right verb activates the right rule pointer at zero token cost.
82
+
83
+ | What you want to do | Use these words in your prompt | What the hook injects |
84
+ |---|---|---|
85
+ | Write a new feature spec | `spec` · `requirements` · `feature` · `需求` · `specify` · `EARS` · `grilling` | `[vcos-spec]` pointer → grilling 8-field intake + EARS template (V3.19' P1+R1) |
86
+ | Implement / fix code | `方案` · `solution` · `implement` · `fix` · `修复` | `[simplicity-first]` Karpathy Rule 2 reminder |
87
+ | Define success criteria | `goal` · `criteria` · `success` · `measurable` · `verifiable` · `目标` · `指标` | `[goal-driven]` Karpathy Rule 4 + verify-after-each-step template |
88
+ | Debug / find root cause | `debug` · `root cause` · `why` · `为什么` · `最佳方案` | `[evidence-required]` Evidence/Symptom/Root cause/Gap/Prevention scaffold |
89
+ | Verify external facts | `verify` · `check` · `actual` · `latest` · `当前` · `最新` · `验证` | `[evidence-required]` 5-step claim protocol |
90
+ | Audit Claude Code config | `skill` · `hook` · `AGENTS` · `CLAUDE` · `settings` · `managed` | `[evidence-required]` |
91
+ | Hedge-flag self-check | `应该是` · `可能是` · `看起来` · `通常` · `显然` · `不可能` | `[evidence-required]` red-flag downgrade |
92
+
93
+ **Karpathy Simplicity hint**: do *not* try to use every signal in every prompt. Use the most relevant one. The hooks decay gracefully if no signal matches (silent — zero injection).
94
+
95
+ ## 2. Per-project setup (one command, 5 seconds)
96
+
97
+ The fastest path is the **`init-project.sh`** helper. From any project root:
98
+
99
+ ```bash
100
+ bash ~/.claude/scripts/init-project.sh
101
+ ```
102
+
103
+ It is idempotent and skips any file that already exists. What it does:
104
+
105
+ 1. Drops a portable `.envrc` (auto-discovers most-recent `.ai/specs/in-progress/<feature>/`, exports `V3_SPEC_ID` + `V3_CTX_MANIFEST_HASH`; safe to source in bash or zsh)
106
+ 2. Drops a ≤30-line `CLAUDE.md` project pointer (lists active V3 indicators + spec lifecycle + V3.19' shared-schema names)
107
+ 3. Ensures `.ai/specs/{in-progress,plans-executed}/` directories exist
108
+ 4. Appends `.envrc.local` + `.ai/` to existing `.gitignore` if missing
109
+ 5. Runs `direnv allow .` when direnv is installed; otherwise prints the manual `source .envrc` reminder
110
+
111
+ ### Alternative: install + bootstrap in one shot
112
+
113
+ If you are installing V3 for the first time AND want to bootstrap the current project in the same call:
114
+
115
+ ```bash
116
+ bash install.sh --with-direnv-template
117
+ ```
118
+
119
+ The `--with-direnv-template` flag runs `init-project.sh` against the cwd at the end of the standard install. Useful when cloning evidence-first-os itself or installing into a brand-new repo.
120
+
121
+ ### If your project already has CLAUDE.md (or AGENTS.md)
122
+
123
+ `init-project.sh` is **idempotent** — it never overwrites existing files. When you run it in a project that already has a project-level `CLAUDE.md` (e.g., AIEP / Spec Kit / company framework), the script will:
124
+
125
+ - `[skip]` CLAUDE.md (your project constitution is preserved verbatim)
126
+ - `[created]` `.envrc` (P3 env auto-export)
127
+ - `[ensured]` `.ai/specs/{in-progress,plans-executed}/`
128
+ - `[appended]` `.gitignore` (`.envrc.local` + `.ai/`)
129
+
130
+ This is by design: V3 user-level rules in `~/.claude/CLAUDE.md` coexist with any project-level `CLAUDE.md` (Karpathy Surgical Changes — V3 adds, project retains).
131
+
132
+ To explicitly cross-reference V3 indicators inside an existing project `CLAUDE.md`, prepend a small block at the top (≤10 lines):
133
+
134
+ ```markdown
135
+ > **V3.19' Evidence-First OS integration** (added by `~/.claude/scripts/init-project.sh`)
136
+ > User-level V3 defaults from `~/.claude/CLAUDE.md` + `~/.ai-policies/core.md` apply.
137
+ > - **Active V3 indicators** (Stop hook check 8 auto-emit): Think-Before-Coding ✓ / Deep-Diagnosis ✓ / Surgical-Changes ✓ / Karpathy ✓ / Goal-Driven ✓
138
+ > - **Spec lifecycle**: `.ai/specs/in-progress/<feature>/` → `.ai/specs/plans-executed/`
139
+ > - **Templates**: `~/.claude/templates/ai-spec/{spec.md, grilling.md}`
140
+ > - **V3.19' shared schema** (env-gated via `.envrc`): `spec_id` / `task_id` / `failure_taxonomy` / `context_manifest_hash`
141
+
142
+ ---
143
+ ```
144
+
145
+ The block coexists with your project constitution; no conflict.
146
+
147
+ ### Mid-session refresh (already-running Claude Code / Codex CLI)
148
+
149
+ `~/.claude/` hooks are read fresh per-tool invocation, so **new hook behavior is active on the very next prompt** without restart. But the LLM context (always-loaded rules) is cached at `SessionStart` (per ADR-0008 / 0012):
150
+
151
+ | You want to refresh | Action | Side effect |
152
+ |---|---|---|
153
+ | Hook behavior only | none — automatic next turn | — |
154
+ | LLM-side rules (e.g., new R2 taxonomy) | type `/clear` in the session | session history compacts |
155
+ | P3 env vars in tool calls (`V3_SPEC_ID`, `V3_CTX_MANIFEST_HASH`) | exit + `source .envrc` + relaunch CC/Codex | session history lost |
156
+ | All of the above | exit + `source .envrc` + relaunch | clean cold start |
157
+
158
+ Recommended daily-driver: `/clear` after running `init-project.sh` from another terminal — covers 90% (P3 env vars defer to next session).
159
+
160
+ ## 3. The 5-minute new-feature workflow
161
+
162
+ ```bash
163
+ # 1. Bootstrap a spec from V3.19' templates
164
+ FEATURE=add-payment-retry
165
+ mkdir -p ".ai/specs/in-progress/${FEATURE}"
166
+ cp ~/.claude/templates/ai-spec/grilling.md ".ai/specs/in-progress/${FEATURE}/"
167
+ cp ~/.claude/templates/ai-spec/spec.md ".ai/specs/in-progress/${FEATURE}/"
168
+
169
+ # 2. Tell Claude Code (one prompt is enough)
170
+ # > "Please grill me on the spec for add-payment-retry feature, then fill EARS requirements."
171
+ # Hook auto-injects [vcos-spec] pointer; Claude runs the 8-field interview.
172
+
173
+ # 3. After grilling, set V3_TASK_ID per task focus
174
+ export V3_TASK_ID=T-01
175
+
176
+ # 4. Every subsequent tool call writes evidence linked to this spec.
177
+ # Check it:
178
+ jq -c '. | select(.spec_id != null)' .ai/evidence.jsonl | tail -3
179
+ ```
180
+
181
+ ## 4. Reading the Stop hook recap
182
+
183
+ After each rule-applied turn, you'll see an italic-gray line like:
184
+
185
+ ```
186
+ ⎿ Stop says: 🛡️ Scope rules V3 — Think-Before-Coding ✓, Deep-Diagnosis ✓, Surgical-Changes ✓, Karpathy ✓, Goal-Driven ✓
187
+ ```
188
+
189
+ **Interpret it as a positive ledger** — the more ✓'s, the more V3 rules engaged this turn. **Zero indicators** (no recap line) means a trivial turn that did not need rule enforcement (Karpathy Simplicity — no noise for typos / formatting / chat).
190
+
191
+ For project-name dynamic prefix:
192
+ - `🛡️ <basename(cwd)> V3` is emitted via `basename "$cwd"` so every project gets its own label
193
+
194
+ ## 5. Common-task playbooks
195
+
196
+ ### A. "Make Claude verify a fact before stating it"
197
+
198
+ Just include `verify` or `check` in your prompt. The hook injects the evidence-required scaffold. Claude must:
199
+ 1. Identify the exact claim
200
+ 2. Identify the source/tool that can verify it (curl/Read/WebFetch/`gh`/`npm view`)
201
+ 3. Run the tool
202
+ 4. Cite the raw output
203
+ 5. Only then state the claim
204
+
205
+ If Claude tries to assert without running the tool, the Stop gate (check 1 — fact firewall) **blocks the final answer**.
206
+
207
+ ### B. "Make Claude give a deep root-cause analysis, not a surface patch"
208
+
209
+ Include `debug`, `root cause`, `why`, or `为什么`. The Stop gate (check 5 — debug ladder) **requires L0–L4 structure** in the answer: Evidence / Symptom / Root cause / Mechanism gap / Prevention. Missing any → blocked.
210
+
211
+ ### C. "Make Claude refuse to claim completion without running tests"
212
+
213
+ The Stop gate (check 2 — completion claim) **blocks** any final answer containing `done` / `fixed` / `verified` / `working` / `tests passed` / `已完成` / `已修复` / `已验证` unless the evidence ledger contains a recent `claim_type:"test"` entry. You don't have to do anything — it's automatic.
214
+
215
+ ### D. "Make Claude avoid persona prompting"
216
+
217
+ Just don't write `"you are a senior engineer"`. V3.19' added a 1-line ban in `core.md §2` based on Wharton GAIL 2025-12. Use **role + authority + checklist + output schema** instead:
218
+
219
+ ```yaml
220
+ role: code-reviewer
221
+ authority: block merge on Blocking finding
222
+ checklist:
223
+ - No new untested branch in src/payments/**
224
+ - No public-API change without ADR link
225
+ output_schema: review-report-v1
226
+ ```
227
+
228
+ ### E. "Make Claude track failure categories in postmortems"
229
+
230
+ Reference the V3.19' R/Q/S taxonomy in L3 (mechanism gap):
231
+
232
+ ```
233
+ L3 Mechanism gap: QUALITY-MISSING-EDGE-CASE — autonomous-loop entry was not covered by the keyword router
234
+ L4 Prevention: add fallback `else echo "[no-match silent]"` + unit case '$PROMPT="" → silent'
235
+ ```
236
+
237
+ Full 14-class taxonomy (4 Reliability + 5 Quality + 5 Safety) lives in `~/.claude/rules/deep-diagnosis.md` appendix.
238
+
239
+ ## 6. Observe + measure your usage
240
+
241
+ ```bash
242
+ # Real-time routing stats (current session-style)
243
+ tail -100 ~/.claude/audit/user-prompt.log | awk -F'matched_index=' '{print $2}' | sort | uniq -c | sort -rn
244
+
245
+ # Which specs have evidence entries in this project?
246
+ jq -r 'select(.spec_id != null) | .spec_id' "$PWD/.ai/evidence.jsonl" | sort | uniq -c
247
+
248
+ # 7 / 30 / 90-day V3.19' usage report
249
+ bash ~/.claude/scripts/integration-usage-report.sh 7
250
+ bash ~/.claude/scripts/integration-usage-report.sh 30
251
+ bash ~/.claude/scripts/integration-usage-report.sh 90
252
+
253
+ # How often did R/Q/S taxonomy actually surface in conversations?
254
+ grep -rcE "RELIABILITY-|QUALITY-|SAFETY-" ~/.claude/sessions/*.jsonl 2>/dev/null | awk -F: '$2 > 0' | wc -l
255
+ ```
256
+
257
+ **Health baselines** (ADR-0013 soft 30-day gate):
258
+ - Week 4: `bash integration-usage-report.sh 30` → ≥3 invocations per component = KEEP; 0 = MONITOR / REMOVE
259
+ - Maintainer (you) decides; the script never auto-deletes
260
+
261
+ ## 7. Anti-patterns to avoid
262
+
263
+ | ❌ Anti-pattern | Why it hurts | ✅ Replacement |
264
+ |---|---|---|
265
+ | Saying "you are a senior X expert" | Wharton GAIL 2025-12: low-knowledge persona harms coding tasks | role + authority + checklist + output_schema |
266
+ | Asking Claude to fix without writing what's wrong | Stop hook check 5 will block surface fixes | include `debug`/`root cause` in prompt; let L0–L4 scaffold engage |
267
+ | Loading every component into every session | ETH 2602.11988: long always-on instructions degrade success rate | rely on keyword routing — components are signal-gated |
268
+ | Hardcoding `V3_SPEC_ID="S-some-spec"` in `.envrc` | Stale on feature rotation | use the `ls -dt` dynamic discovery template above |
269
+ | Tracking "looks good" without rubric | violates Karpathy Goal-Driven | translate to scorable rubric (see `~/.claude/templates/ai-spec/grilling.md` Step 3) |
270
+ | Running 30-day report every week | Noise, no signal | Week 4 / 8 / 12 (3 data points trend-suffice) |
271
+
272
+ ## 8. When *not* to use V3 signals
273
+
274
+ - Trivial typo / formatting fix → don't add any signal verb (hook stays silent, zero overhead)
275
+ - Conversational Q&A → no signal needed
276
+ - Reading code / exploration → no signal needed
277
+
278
+ V3 is designed to **disappear** for low-stakes work. The signals only fire when the prompt explicitly invites them.
279
+
280
+ ---
281
+
282
+ # 📖 Detailed usage guide
283
+
284
+ ## Architecture (11 layers, top-down)
285
+
286
+ | Layer | Purpose | Component |
287
+ |---|---|---|
288
+ | L0 | Shared policy source | `~/.ai-policies/core.md` |
289
+ | L1 | User-level entry | `~/.claude/CLAUDE.md` (≤ 120 lines) + 18 modular rules |
290
+ | L2 | Per-prompt context injection | `user-prompt-policy.sh` (8 trigger patterns, folded V3.19' routing) |
291
+ | L3 | Tool evidence ledger | `post-tool-evidence.sh` → `{cwd}/.ai/evidence.jsonl` (+ V3.19' spec_id/task_id/context_manifest_hash) |
292
+ | L4 | Final answer hard gate | `stop-quality-gate.sh` (7 numbered quality checks + spec archive guard + retired-recap drift guard; recap emitter is non-blocking transparency) |
293
+ | L5 | User-level skills | 5 skills with progressive disclosure |
294
+ | L6 | Config integrity guard | `config-integrity-guard.sh` + `config-change-audit.sh` |
295
+ | L7 | Managed policy (optional, enterprise) | `/Library/Application Support/ClaudeCode/managed-settings.d/` |
296
+ | L8 | Project H10-H13 gates (per-project) | `gates/H*.py` (deterministic UI semantic gates) |
297
+ | L9 | Spec-Driven external memory | `<project>/.ai/specs/{in-progress,plans-executed}/` + V3.19' templates |
298
+ | L10 | User-visible banner / Stop recap (V3.10 → V3.18.x) | `session-start-policy.sh` + JSON `systemMessage` field |
299
+ | L11 | Reference-driven debug methodology (V3.11) | ADR-0005 |
300
+
301
+ See [`EVIDENCE-FIRST-OS-COMPLETE-SPEC.md`](EVIDENCE-FIRST-OS-COMPLETE-SPEC.md) for the full 22-section spec including ETH 2026 research grounding, Karpathy-aligned rule integration, Matt Pocock skill mapping, the V3.2 → V3.11 9-iteration retrospective, and V3.18.x → V3.19' arbitration trails.
302
+
303
+ 🏛️ **Architecture governance track** (SoR spine, reverse-coverage gate, Wave-0 closure): see **[docs/governance/README.md](docs/governance/README.md)** — status board, read order, and how-to for new modules/docs.
304
+
305
+ ## Per-component walkthrough
306
+
307
+ ### V3 baseline (always-loaded)
308
+ - **Iron Law (L0)** — 5-step claim protocol, hedge-word firewall, L0–L4 diagnosis ladder, completion-claim gate, compaction resilience
309
+ - **Rules (L1)** — think-before-coding / simplicity-first / surgical-changes / deep-diagnosis / goal-driven / evidence-first / completion-gate / + others (coding-style, autonomous-mode, fail-loud, checkpoint-steps, etc.; V3.23 — testing/security/patterns process detail moved to on-demand playbooks; full list: `templates/claude/rules/`)
310
+
311
+ ### V3.19' VCOS-v2 selective import (signal-gated; cost only when invoked)
312
+
313
+ | ID | Component | Trigger | Effect |
314
+ |---|---|---|---|
315
+ | P1 | EARS requirements template | `spec` / `需求` / `requirements` | Hook emits pointer to `~/.claude/templates/ai-spec/spec.md` — 5 EARS patterns (Ubiquitous / Event-driven / State-driven / Unwanted / Optional) |
316
+ | P2 | Persona-ban | always-loaded (1 line in core.md §2) | Discourages "you are senior X" prompts; recommends role+authority+checklist |
317
+ | P3 | Ledger 3 fields | env-gated via `.envrc` | `spec_id` / `task_id` / `context_manifest_hash` appended to evidence.jsonl entries when env vars present |
318
+ | R1 | Grilling 8-field intake | `spec` / `grilling` (shares P1 trigger) | Hook points to `~/.claude/templates/ai-spec/grilling.md` — Goal/Context/Users/Non-goals/Risks/Constraints/Done-when/Success-metric |
319
+ | R2 | 14-class R/Q/S taxonomy | passive (in `deep-diagnosis.md` appendix) | 4 Reliability + 5 Quality + 5 Safety failure categories for L3 mechanism-gap classification |
320
+ | — | Soft 30-day gate | `bash ~/.claude/scripts/integration-usage-report.sh N` | Maintainer report; no runtime self-mutation |
321
+
322
+ See [docs/adr/0013-v3-19-vcos-v2-selective-import.md](docs/adr/0013-v3-19-vcos-v2-selective-import.md) for the 2-round 3-视角 arbitration trail.
323
+
324
+ ## Spec lifecycle (V3 §17)
325
+
326
+ ```
327
+ .ai/specs/
328
+ ├── in-progress/ # active work; .envrc auto-discovers most-recent
329
+ │ └── <feature>/
330
+ │ ├── grilling.md # 8-field intake (filled first)
331
+ │ ├── spec.md # EARS R-1...R-N + non-goals + success metrics
332
+ │ ├── plan.md # 9-section plan (per VCOS-v2 §3.2)
333
+ │ └── tasks.md # TDD red→green checklist
334
+ └── plans-executed/ # archived after ship; preserves provenance
335
+ └── <feature>/...
336
+ ```
337
+
338
+ Move spec on ship: `mv .ai/specs/in-progress/<feature> .ai/specs/plans-executed/`
339
+
340
+ ## Evidence ledger schema (V3.19')
341
+
342
+ Each `.ai/evidence.jsonl` line:
343
+
344
+ ```json
345
+ {
346
+ "ts": "2026-05-19T05:03:36Z",
347
+ "session_id": "abc-123",
348
+ "cwd": "/path/to/project",
349
+ "tool": "Bash",
350
+ "claim_type": "test", // auto: web|file|test|package|repo|unknown
351
+ "raw_ref": "toolu_xxx",
352
+ "spec_id": "v3-19-vcos-selective-import", // V3.19' P3 (optional)
353
+ "task_id": "T-06", // V3.19' P3 (optional)
354
+ "context_manifest_hash": "ff81667" // V3.19' P3 (optional; git short SHA)
355
+ }
356
+ ```
357
+
358
+ Last 3 fields appear only when env vars are set (via `.envrc` or manual export).
359
+
360
+ ---
361
+
362
+ # 🔍 Troubleshooting
363
+
364
+ | Symptom | Likely cause | Fix |
365
+ |---|---|---|
366
+ | No `Stop says:` recap line | No V3 rule indicator detected in your turn | Add a signal verb (see §1) or accept silent (trivial turn) |
367
+ | Stop hook blocks "done" without test | check 2 — completion gate | Run `npm test` / `bash verify.sh` first, then state the completion |
368
+ | `V3_SPEC_ID=unset` | `.ai/specs/in-progress/` is empty | Create one: `mkdir -p .ai/specs/in-progress/my-feature && source .envrc` |
369
+ | Project docs drift | README / ARCHITECTURE / CHANGELOG / banner / CI disagree with hook SoT | Run `bash scripts/doctor.sh`; it is also part of `bash verify.sh` |
370
+ | Banner not visible after `/clear` | Plugin hook order or claude-mem absent | `tail -10 ~/.claude/audit/session-start.log` — confirm hook fired |
371
+ | Audit log spam | Default — every prompt classification logs once | `truncate -s 0 ~/.claude/audit/user-prompt.log` |
372
+
373
+ ## Non-goals
374
+
375
+ - Not a new IDE, agent runtime, or autonomous coding product.
376
+ - Not a portable policy compiler until the Claude/Codex SoT is stable.
377
+ - Not compliance-grade claim/evidence attestation yet; the current ledger is a developer quality gate, not a regulated audit model.
378
+ - Not market-validated by public adoption while the repository remains private.
379
+
380
+ ---
381
+
382
+ # 📁 Project structure
383
+
384
+ ```
385
+ evidence-first-os/
386
+ ├── README.md # this file
387
+ ├── CLAUDE.md # project-level V3 pointer
388
+ ├── .envrc # P3 env auto-export (direnv-compatible)
389
+ ├── install.sh # one-click installer (merge-preserve default)
390
+ ├── uninstall.sh # rollback (preserves backups)
391
+ ├── verify.sh # §9 smoke test harness
392
+ ├── LICENSE # MIT
393
+ ├── CHANGELOG.md # V3.1 → current rollout history
394
+ ├── EVIDENCE-FIRST-OS-COMPLETE-SPEC.md # 22-section authoritative spec
395
+ ├── templates/
396
+ │ ├── ai-policies/core.md # L0 Iron Law (+ V3.19' persona ban)
397
+ │ ├── claude/
398
+ │ │ ├── CLAUDE.md # L1 user-level entry
399
+ │ │ ├── rules/ # 18 modular rules (+ V3.19' R/Q/S appendix)
400
+ │ │ ├── playbooks/ # V3.23 on-demand process manuals (+ profiles/ ×4)
401
+ │ │ ├── RULES-ARCHITECTURE.md # V3.23 layered rules architecture SSOT
402
+ │ │ ├── hooks/ # 8 Claude hook scripts (+ V3.19' folded routing)
403
+ │ │ ├── templates/
404
+ │ │ │ ├── banner-v3.txt # V3.10 banner content
405
+ │ │ │ └── ai-spec/ # V3.19' EARS + grilling templates
406
+ │ │ └── scripts/
407
+ │ │ └── integration-usage-report.sh # V3.19' 30-day soft gate
408
+ │ ├── codex/ # Codex parallel install (AGENTS.md + 3 hooks)
409
+ │ └── settings/ # claude-hooks.json / codex-hooks.json templates
410
+ ├── scripts/
411
+ │ └── merge-settings.py # idempotent jq-style settings merger
412
+ ├── docs/
413
+ │ ├── quickstart.md # copy-paste onboarding prompts
414
+ │ ├── ARCHITECTURE.md # detailed layer-by-layer walkthrough
415
+ │ ├── deployment-guide.md # platform-specific notes
416
+ │ ├── adr/ # ADR-0002 to ADR-0014 (architectural decisions)
417
+ │ └── archive/ # V1/V2 HTML + V3 banner retrospective (frozen)
418
+ ├── VCOS-v2-Release/ # VCOS v2.0 source-of-record bundle (per ADR-0013)
419
+ └── .github/workflows/ci.yml # GitHub Actions smoke test
420
+ ```
421
+
422
+ # Project status (2026-05-23)
423
+
424
+ - **V3.22.0** — banner trim + active-rule overview + integrity repair track
425
+ - **13 ADRs** capturing architectural decisions through ADR-0013
426
+ - **11-layer defense-in-depth** + **7 numbered quality checks + spec archive guard + retired-recap drift guard** active
427
+ - **Current product wedge**: completion-claim gate for Claude Code and Codex; other platform exports are deferred until the SoT is stable
428
+
429
+ # License
430
+
431
+ MIT — see [LICENSE](LICENSE). Cite the spec and ETH Zurich 2026 paper if you use this work academically.
432
+
433
+ # Acknowledgements
434
+
435
+ - ETH Zurich + LogicStar.ai 2026 (arXiv:2602.11988) — empirical foundation
436
+ - Karpathy's 4 LLM coding principles
437
+ - Matt Pocock's skills ecosystem (`mattpocock/skills`)
438
+ - obra-superpowers `systematic-debugging` skill (preserved via ADR-0004)
439
+ - claude-mem (thedotmack) — reference implementation that enabled V3.10 root cause via direct jsonl diff (ADR-0005)
440
+ - VCOS v2.0 spec authors — selective-import source-of-record for V3.19' (ADR-0013)
441
+ - Wharton GAIL 2025-12 (arXiv:2512.05858) — persona-stuffing empirical critique
442
+ - METR 2025-07 (arXiv:2507.09089) — AI productivity reality check (-19% measured)
443
+ - DORA 2025 — "AI is an amplifier, not an equalizer"