Commit 6391bdf
committed
feat(observability): commit 3 — gate diagnostics wiring + docs
**FINAL** commit of the Phase 4h.2 Part 1 3-commit cluster (issue
#116). Populates the ``osap_gate_diagnostics`` field landed in
commit 1's schema delta + docs the full Part-1 surface so reviewers
+ future maintainers see the schema and observability contract in
one place.
**`compute/main.py` wiring** (+23 LOC):
1. Import added to ``from compute.output.schemas import (...)``:
``OsapGateDiagnostic`` inserted alphabetically between ``Metadata``
and ``PillarScores`` (schemas import already used at this site,
no new module touched).
2. Variable initialized BEFORE the OSAP try block:
``osap_gate_diagnostics: dict[str, OsapGateDiagnostic] = {}``.
3. Populated inside the try after
``gate_results = gate_osap_signals(osap_ls, requested_signals=
config.OSAP_SIGNALS_100)`` and BEFORE
``filter_accepted_signals`` — captures EVERY signal that reached
the gate (both accepted and rejected). Accepted carry
``rejection_reason=None``; rejected carry one of the canonical
taxonomy values (``high_pbo`` / ``low_dsr`` / ``insufficient_data``
/ ``gate_failed``) per
``compute/validation/osap_validation.py::GateResult``.
4. Reset to ``{}`` in the OSAP-pipeline-failed ``except`` branch so
graceful degradation continues to leave every osap_* field at
``None``.
5. Wired into the ``Metadata(...)`` constructor with the established
``or None`` idiom:
```python
osap_gate_diagnostics=osap_gate_diagnostics or None,
```
**Tests** (``tests/test_output/test_schema_phase4h2.py``, +55 LOC, 2
new offline appended to commit 1's suite):
1. ``test_metadata_gate_diagnostics_round_trip_with_production_cohort_shape``
— simulates the production observation from #116 (22 signals
reach the gate, all rejected with a mix of rejection_reason
values across the canonical 4-value taxonomy); asserts the
dict-of-OsapGateDiagnostic structure survives ``model_validate``
→ ``model_dump`` → ``model_validate`` round-trip.
2. ``test_metadata_gate_diagnostics_accepted_signal_has_null_rejection_reason``
— locks the ``rejection_reason=None`` semantics for accepted
signals (Pydantic preserves None rather than coercing to a
sentinel string).
**Docs** (atomic with the wiring):
- ``CLAUDE.md`` ``## Phase status`` — schema line updated to
``0.9.1-phase4h.2`` with the PATCH-bump framing; preserved the
prior MINOR-bump history (`0.8.0-phase4.5f` → `0.9.0-phase4h` via
PR #112).
- ``PHASE_STATUS.md`` row 4 — Phase 4h.2 Part 1 sub-status added;
describes both new fields, the Part-1 / Part-2 split rationale
("Part 2 opens after ≥1 week of production diagnostic data
accumulates"), and the "no new veto / no rank change" invariant.
- ``SKILL.md`` schema-versions table — new row for
``0.9.1-phase4h.2`` inserted above the ``0.9.0-phase4h`` row;
cites the SKILL.md L305 PATCH-bump quote verbatim, locks the
``OsapGateDiagnostic`` "all 4 fields explicit = None" refinement
in writing, and documents the set-diff helper placement decision
(``compute/features/osap_replicate.py::signals_in_dataframe``
per refinement #4).
- ``WORKFLOW.md`` — unchanged; no "Open items" checkbox list for
Phase 4h.2 yet (would be created when Part 2 is scoped).
**Verification ladder** (steps 1-5 complete):
- ``ruff check .`` → clean ✅
- ``pytest tests/ -m "not network"`` → **924 passed** (911 baseline
+ 13 new across the 3-commit cluster: 7 schema + 4 helper + 2
gate-diagnostic) ✅
- ``python -m compute.output.schema_check`` → in-sync (no new
schema delta this commit; the snapshot already captured both
fields + ``OsapGateDiagnostic`` from commit 1's regen) ✅
- ``python -c "from compute.main import run_weekly_compute;
from compute.output.schemas import OsapGateDiagnostic; ..."``
→ OK ✅
Steps 6-8 next: ``git push`` → open Draft PR → ``subscribe_pr_activity``
+ STOP for user audit + Mark-Ready authorization.
**Defense layer**: unchanged at 17. **Top-5 rotation**: unchanged.
**Schema version**: ``0.9.1-phase4h.2`` (locked from commit 1).
**Cluster summary**:
| # | SHA | LOC | Tests added |
|---|---|---|---|
| 1 — schema delta | ``428729ad`` | 231 | +7 (round-trip + backward-compat) |
| 2 — silent-drop wiring | ``c7949403`` | 116 | +4 (helper unit tests) |
| 3 — gate diagnostics + docs (this) | TBD | ~86 | +2 (gate-diag round-trip) |
| **Total** | — | ~433 | **+13** |
Within the Option-β diagnostic-first scope (~250-350 LOC budget; +
docs); under the original plan's ~300 LOC estimate.
https://claude.ai/code/session_01T8FE3MAnmk6hcjvH4SgYNU1 parent c794940 commit 6391bdf
5 files changed
Lines changed: 86 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
160 | 162 | | |
161 | 163 | | |
162 | 164 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
| 307 | + | |
307 | 308 | | |
308 | 309 | | |
309 | 310 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
962 | 963 | | |
963 | 964 | | |
964 | 965 | | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
965 | 970 | | |
966 | 971 | | |
967 | 972 | | |
| |||
1001 | 1006 | | |
1002 | 1007 | | |
1003 | 1008 | | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
1004 | 1025 | | |
1005 | 1026 | | |
1006 | 1027 | | |
| |||
1065 | 1086 | | |
1066 | 1087 | | |
1067 | 1088 | | |
| 1089 | + | |
1068 | 1090 | | |
1069 | 1091 | | |
1070 | 1092 | | |
| |||
1419 | 1441 | | |
1420 | 1442 | | |
1421 | 1443 | | |
| 1444 | + | |
1422 | 1445 | | |
1423 | 1446 | | |
1424 | 1447 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
129 | 184 | | |
130 | 185 | | |
131 | 186 | | |
| |||
0 commit comments