python-observability-fallback-visibility
The solution is complete and verified. Here's a summary of what I produced:
~/TR-025-fallback-visibility.md — the full self-contained writeup (root-cause, fix, verification).
~/resolve.py — the working drop-in reference implementation used to verify it.
registry.json fell back to builtin defaults with no source/fallback_used/warning surfaced, so degraded data looked identical to healthy data.load_json(path, default={}) returned {} both for empty and deleted health-state.json; an empty dict fails-open → a deleted file looked "all healthy."_load_registry_with_meta() → returns (tables, source, fallback_used, warnings); resolve() emits all three so falls back are never invisible._present() (os.path.isfile) per state file feeds gates_loaded{health, circuit, quota, ledger_rows} — a deleted file is now a reported gap (present: false + ABSENT warning), never fabricated into healthy.ROUTER_STATE_DIR env with a single DEFAULT_STATE_DIR anchor; no hardcoded call-site paths.Ran a 15-assert harness across 5 scenarios (healthy / corrupt / missing-registry / missing-health / all-gates-missing) against the real module — ALL_CHECKS_OK (15/15). Notably:
- corrupt registry → fallback_used: true, source: builtin_defaults, corruption warning, while gates still load (non-blocking).
- deleted health-state.json → gates_loaded.health: false + ABSENT warning, other gates true.
- healthy → source: registry, no warnings, all gates true.
# Evidence - Problem class: python-observability-fallback-visibility - Model: openrouter/deepseek/deepseek-v4-flash-0731 - Solved: 2026-08-28T05:37:19.331Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "task-router TR-025: silent registry fallback (corrupt registry.json -> data/tables with exit 0, no source field) and silent gate-state absence (load_json default={} made deleted health-state.json look like all-healthy). Fix pattern: _load_registry_with_meta() returns (tables, source, fallback_used, warning) so resolve output gains source/fallback_used/warnings; explicit os.path.isfile presence checks (_present()) per state file feed gates_loaded{health,circuit,quota,ledger_rows}. Pure VISIBILITY layer \u2014 gate behavior and fail-open untouched (missing file = reported gap, never fabricated default, never a blocker). Data>code: state dir from ROUTER_STATE_DIR/default; no hardcoded paths.", "environment": "", "language": "", "model": "openrouter/deepseek/deepseek-v4-flash-0731", "problem_class": "python-observability-fallback-visibility", "provider": "openrouter", "solved_at": "2026-08-28T05:37:19.331Z", "version": ""}The solution is complete and verified. Here's a summary of what I produced:
~/TR-025-fallback-visibility.md — the full self-contained writeup (root-cause, fix, verification).
~/resolve.py — the working drop-in reference implementation used to verify it.
registry.json fell back to builtin defaults with no source/fallback_used/warning surfaced, so degraded data looked identical to healthy data.load_json(path, default={}) returned {} both for empty and deleted health-state.json; an empty dict fails-open → a deleted file looked "all healthy."_load_registry_with_meta() → returns (tables, source, fallback_used, warnings); resolve() emits all three so falls back are never invisible._present() (os.path.isfile) per state file feeds gates_loaded{health, circuit, quota, ledger_rows} — a deleted file is now a reported gap (present: false + ABSENT warning), never fabricated into healthy.ROUTER_STATE_DIR env with a single DEFAULT_STATE_DIR anchor; no hardcoded call-site paths.Ran a 15-assert harness across 5 scenarios (healthy / corrupt / missing-registry / missing-health / all-gates-missing) against the real module — ALL_CHECKS_OK (15/15). Notably:
- corrupt registry → fallback_used: true, source: builtin_defaults, corruption warning, while gates still load (non-blocking).
- deleted health-state.json → gates_loaded.health: false + ABSENT warning, other gates true.
- healthy → source: registry, no warnings, all gates true.
# Evidence - Problem class: python-observability-fallback-visibility - Model: openrouter/deepseek/deepseek-v4-flash-0731 - Solved: 2026-08-28T05:37:19.331Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "task-router TR-025: silent registry fallback (corrupt registry.json -> data/tables with exit 0, no source field) and silent gate-state absence (load_json default={} made deleted health-state.json look like all-healthy). Fix pattern: _load_registry_with_meta() returns (tables, source, fallback_used, warning) so resolve output gains source/fallback_used/warnings; explicit os.path.isfile presence checks (_present()) per state file feed gates_loaded{health,circuit,quota,ledger_rows}. Pure VISIBILITY layer \u2014 gate behavior and fail-open untouched (missing file = reported gap, never fabricated default, never a blocker). Data>code: state dir from ROUTER_STATE_DIR/default; no hardcoded paths.", "environment": "", "language": "", "model": "openrouter/deepseek/deepseek-v4-flash-0731", "problem_class": "python-observability-fallback-visibility", "provider": "openrouter", "solved_at": "2026-08-28T05:37:19.331Z", "version": ""}