Repository navigation
Commit 822c2f8
fix(core): raise on an unconfigured environment reader, wire every real entry point
Addresses ZETETIC-REVIEW: REQUEST_CHANGES on PR #568 (024fe55).
Critical fix: core/environment.read_environment_variable used to return
None when no reader was configured -- a silent fallback CLAUDE.md
forbids. benchmarks/lib/ablation_runner.py sets CORTEX_ABLATE_<NAME>=1
in-process and calls a benchmark's run_benchmark() directly, never
importing mcp_server/__main__.py, scripts/launcher.py, or
tests_py/conftest.py. With the silent None default, every ablation
measurement on this branch silently scored the un-ablated system,
invalidating the published E1/E2 evidence the ablation results cite.
Same class of exposure for every other benchmarks/**/run_*.py and
scripts/ entry that reads a CORTEX_*_BETA / CORTEX_DECAY_* /
CORTEX_RERANKER_OFFLINE flag.
Fix: read_environment_variable now raises RuntimeError when no reader
was ever configured (an explicitly-wired reader returning None for one
specific variable is still a legitimate "unset" answer -- only the
never-configured case is a bug). Then wired every real composition root,
enumerated mechanically rather than guessed:
- scripts/launcher.py: the one process bootstrap shared by the
plugin-installed server AND every hook (ADR-0742, `.claude-plugin/
plugin.json`'s hooks all route through `launcher.py mcp_server.hooks.
<name>`) -- wiring it here once covers all of them without touching
mcp_server/hooks/__init__.py (which would break capture_dispatch/
capture_worker's "must never import mcp_server.core" lazy-load
invariant, tests_py/hooks/test_capture_dispatch.py). Verified this
reasoning against the actual test: it does a bare `-c` import that
never touches launcher.py at all, so wiring launcher.py cannot affect
it either way -- confirmed capture_dispatch's 8 tests still pass.
- Every one of the 14 hook scripts with `if __name__ == "__main__":`
ALSO gets the wiring directly in that block (redundant with
launcher.py, not with each other) -- this covers the one entry point
launcher.py cannot reach: scripts/measure_pipeline_hook.py spawns
`python -m mcp_server.hooks.pipeline_impact_bump` directly (bypassing
launcher.py) while setting CORTEX_RERANKER_OFFLINE=1 to measure hook
latency. Verified the fix on that exact invocation shape (runpy.
run_module with run_name="__main__", matching what `-m` does).
- benchmarks/lib/_composition_root_wiring.py: one new bootstrap
(environment + the existing reranker seam) that every
benchmarks/**/run_*.py, ablation_runner.py, and any benchmarks/lib
module reaching core now imports. Six run_*.py already got this
transitively via bench_db.py or retriever.py (both updated to the
unified bootstrap); the other eleven needed an explicit import, added
after each file's own sys.path setup so import order does not break.
benchmarks/lib/run_e1_v3_lme.py and run_e1_v3_locomo.py were audited
and excluded: they only orchestrate subprocesses of the already-wired
run_benchmark.py scripts, never import core in-process.
- mcp_server/doctor.py's ensure_reranker_ready() already self-wired its
own seam (from the prior review round); unaffected by this change.
New test tests_py/benchmarks/test_ablation_runner_wiring.py drives the
literal ablation_runner.py entry path in a bare subprocess (no pytest
conftest wiring) and proves CORTEX_ABLATE_ADAPTIVE_DECAY=1 actually
disables the mechanism, plus proves an unwired bare script raises
instead of silently reporting every mechanism enabled.
Also: tests_py/test_doctor.py::TestEnsureRerankerReady::
test_self_wires_and_loads_even_when_the_seam_was_reset asserted
`status.state == "loaded"`, which needs the FlashRank model on disk and
failed in the SQLite CI job (does not preload it). Now asserts the
seam is configured and reranker_cache_dir() does not raise, not that a
model downloaded -- extracted the reset/restore logic into two helpers
to stay under the 40-line method cap.
Verified: scripts/check_craftsmanship.py --base origin/main returns OK;
ruff check/format are clean; pyright mcp_server/ reports 0 errors; full
pytest reports 8433+ passed, 0 failed (re-run after these changes);
`CORTEX_ABLATE_ADAPTIVE_DECAY=1 python -c "..."` through
scripts/launcher.py and through a bare runpy.run_module both confirmed
disabling the mechanism; `python -c "from mcp_server.core.ablation
import ...; is_mechanism_disabled(...)"` with no composition root
confirmed raising RuntimeError.
benchmarks/reproduce.sh --no-regression: Docker is available and the
script is running against real data (LongMemEval-S downloaded and
checksum-verified, locomo10.json present); the longmemeval-s benchmark
stage is still executing after 35+ minutes of CPU time at the time of
this commit. A full --no-regression run covers at least three benchmark
suites (longmemeval-s, locomo, beam-100K) plus decision-ids and does
not support --quick/--limit, so it cannot complete within one review
turn. Reporting this honestly rather than claiming a result I do not
have; the run continues and its output will be reported once available.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>1 parent 024fe55 commit 822c2f8
31 files changed
Lines changed: 301 additions & 42 deletions
File tree
- benchmarks
- active_forgetting
- decision_ids
- energy
- entity_dedup
- forgetting_curve
- lib
- mcp_server
- core
- hooks
- scripts
- tests_py
- benchmarks
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
0 commit comments