#000037 §22 Finding 3: per-audit-mode τ_qa in dry-run

Per Finding 3, a uniform τ_qa=7d filtered out every recent
CANONICAL_PROJECTION row (the π* graduations from #000027/#000030/
#000032 are all younger than 7d), so the sweep saw zero high-value
kernel-only work. Splitting τ_qa by audit_mode lets the cheap kernel
re-probe path (CP) run on a short cycle while the expensive LLM
re-witness path (STRICT/HYBRID/UNGROUNDED) keeps the long cycle.

bench/scripts/prometheus_sigma_sweep_dryrun.py: new build_tau_by_mode()
helper + per-mode CASE in iter_target_a_candidates; sweep_target_a now
takes the dict instead of a single seconds value. New CLI flag
--tau-qa-cp-days (default 1d); --tau-qa-days now scopes to LLM-witness
modes only (default 7d). Report renders the per-mode τ table in the
header and marks Findings 2 and 3 RESOLVED with their landing commits.

Makefile: PROMETHEUS_SWEEP_TAU_DAYS bumped to 7 (was 1, the prior
Finding-3 workaround); new PROMETHEUS_SWEEP_TAU_CP_DAYS=1 makevar.

bench/results/prometheus-sigma-sweep-dryrun-2026-05-10.md: regenerated
under the new defaults — 9 CP rows surface alongside 1,904 LLM-
witness candidates → 1,913 total Target A candidates → 1 ACCEPT,
2 MARGINAL, 205 REJECT, 271 DEFERRED chunks; 2 cache_drift vetoes
preserved end-to-end.

docs/tickets/ticket-000037 §22: Findings 2 + 3 marked RESOLVED with
landing-commit references; total dry-run cost line updated to the
new measurements (37.6 ms / 3,913 branches / 9.6 µs per branch).
This commit is contained in:
russell@unturf.com 2026-05-10 18:35:19 -04:00
parent 43380b11b7
commit 1f882df22c
No known key found for this signature in database
4 changed files with 174 additions and 87 deletions

View file

@ -71,11 +71,31 @@ from arborist.substrate.prometheus import (
DEFAULT_SHARDS_DIR = Path.home() / ".arborist" / "shards"
DEFAULT_TAU_QA_DAYS = 7
DEFAULT_TAU_QA_DAYS = 7 # LLM-witness modes (STRICT / HYBRID / UNGROUNDED)
DEFAULT_TAU_QA_CP_DAYS = 1 # kernel-only mode (CANONICAL_PROJECTION)
DEFAULT_TARGET_B_SAMPLE_PER_SHARD = 1000
DEFAULT_BUDGET = 4 # Hermes concurrent-request ceiling (§11)
def build_tau_by_mode(
cp_days: int = DEFAULT_TAU_QA_CP_DAYS,
llm_days: int = DEFAULT_TAU_QA_DAYS,
) -> dict[str, int]:
"""Per §22 Finding 3 (RESOLVED): split τ_qa by audit_mode.
Kernel-only modes (CANONICAL_PROJECTION) take a short τ cheap
to re-probe, high value when kernel-LLM divergence surfaces.
LLM-witness modes (STRICT / HYBRID / UNGROUNDED) take a longer τ
re-witness is expensive. Returns seconds per mode.
"""
return {
"CANONICAL_PROJECTION": cp_days * 86400,
"STRICT": llm_days * 86400,
"HYBRID": llm_days * 86400,
"UNGROUNDED": llm_days * 86400,
}
# ---------------------------------------------------------------------
# Target A — providence_cache classification + synthesis
# ---------------------------------------------------------------------
@ -90,18 +110,31 @@ AUDIT_MODE_TO_DELTA_5F: dict[str, float] = {
def iter_target_a_candidates(
conn: sqlite3.Connection, tau_qa_seconds: int, now: int
conn: sqlite3.Connection, tau_by_mode: dict[str, int], now: int
) -> Iterator[sqlite3.Row]:
"""Enumerate providence_cache rows older than τ_qa."""
"""Enumerate providence_cache rows older than per-mode τ_qa.
``tau_by_mode`` maps audit_mode seconds; rows whose audit_mode
is absent from the dict fall through to ``fallback_seconds`` (the
longest declared τ never filter MORE aggressively than declared).
See :func:`build_tau_by_mode` for the §22 Finding 3 rationale.
"""
conn.row_factory = sqlite3.Row
cur = conn.execute(
fallback_seconds = max(tau_by_mode.values(), default=7 * 86400)
case_clauses: list[str] = []
case_params: list[int] = []
for mode in sorted(tau_by_mode):
case_clauses.append(f"WHEN audit_mode = '{mode}' THEN ?")
case_params.append(tau_by_mode[mode])
sql = (
"SELECT cache_key, audit_mode, falsification_state, n_quotes,"
" n_verified, unverified_quotes, hit_count, created_at,"
" question_text"
" FROM providence_cache"
" WHERE ? - created_at >= ?",
(now, tau_qa_seconds),
f" WHERE ? - created_at >= (CASE {' '.join(case_clauses)}"
f" ELSE ? END)"
)
cur = conn.execute(sql, [now, *case_params, fallback_seconds])
yield from cur
@ -290,7 +323,12 @@ def target_b_branch(
# ---------------------------------------------------------------------
def sweep_target_a(shards_dir: Path, tau_qa_seconds: int, now: int, chunk_size: int = 4) -> dict:
def sweep_target_a(
shards_dir: Path,
tau_by_mode: dict[str, int],
now: int,
chunk_size: int = 4,
) -> dict:
"""Iterate Target A candidates across all shards; controller-decide per chunk.
Default chunk_size = 4 mirrors the Hermes concurrency budget (§11)
@ -335,7 +373,7 @@ def sweep_target_a(shards_dir: Path, tau_qa_seconds: int, now: int, chunk_size:
continue
batch: list[ControllerBranch] = []
for row in iter_target_a_candidates(conn, tau_qa_seconds, now):
for row in iter_target_a_candidates(conn, tau_by_mode, now):
candidates_total += 1
audit_mode_seen[(row["audit_mode"] or "UNKNOWN").upper()] += 1
batch.append(target_a_branch(row))
@ -526,8 +564,9 @@ def render_markdown(a_results: dict, b_results: dict, opts: dict) -> str:
lines.append("## Parameters")
lines.append("")
lines.append(f"- Shards dir: `{opts['shards_dir']}`")
lines.append(f"- τ_qa: {opts['tau_qa_days']} days "
f"({opts['tau_qa_seconds']} seconds)")
lines.append(f"- τ_qa per audit_mode (§22 Finding 3 fix):")
for mode, secs in sorted(opts["tau_by_mode"].items()):
lines.append(f" - {mode}: {secs // 86400}d ({secs}s)")
lines.append(f"- Target B sample/shard: {opts['sample_b']}")
lines.append(f"- Controller budget (Hermes concurrency): "
f"{DEFAULT_BUDGET}")
@ -681,31 +720,39 @@ def render_markdown(a_results: dict, b_results: dict, opts: dict) -> str:
)
lines.append("")
lines.append(
"**Finding 2 — flat capital_cost = no allocation.** "
"Iteration 1 also assigned `capital_cost=1.0` to every "
"branch (one full Hermes call). Combined with small "
"audit-mode-based Δ5F deltas (±0.050.10), every utility "
"was negative. Split kernel-only re-probe cost from full "
"LLM-witness cost: `CANONICAL_PROJECTION=0.05`, "
"`UNGROUNDED=0.4`, `HYBRID=0.8`, `STRICT=1.0` for Target A; "
"`0.02` (HEAD-only freshness) vs `0.05` (canonical-shape "
"probe) for Target B. Recommendation for Phase 3: model "
"`capital_cost` as the expected cost given which witness "
"paths fire (kernel / lexical / LLM), not a flat per-call "
"estimate."
"**Finding 2 — flat capital_cost = no allocation. "
"RESOLVED in Phase 1.c (commit `4b85a0a`).** "
"Iteration 1 assigned `capital_cost=1.0` to every branch "
"(one full Hermes call). Combined with small audit-mode-"
"based Δ5F deltas (±0.050.10), every utility was "
"negative. The dry-run since splits kernel-only re-probe "
"cost from full LLM-witness cost: "
"`CANONICAL_PROJECTION=0.05`, `UNGROUNDED=0.4`, "
"`HYBRID=0.8`, `STRICT=1.0` for Target A; `0.02` "
"(HEAD-only freshness) vs `0.05` (canonical-shape probe) "
"for Target B. Phase 1.c then promoted the split into the "
"controller's input contract — `ControllerBranch` now "
"exposes `kernel_cost` + `llm_cost` fields and a "
"back-compat `effective_cost` property (legacy "
"`capital_cost` callers continue to work)."
)
lines.append("")
lines.append(
"**Finding 3 — τ_qa=7d filters out every "
"CANONICAL_PROJECTION row.** All 29 CP rows in `qa.db` are "
"≤ 7 days old (they're the recent π* graduations from "
"tickets #000027/#000030/#000032). Sweep with τ_qa=7d "
"shows zero CP candidates → zero ACCEPT chunks → zero "
"high-value sleep work surfaced. Phase 3 should split τ "
"by audit_mode: kernel-only modes (CP) get τ_qa=1d (cheap "
"to re-probe, high value when kernel-LLM divergence "
"surfaces); lexical/quote modes (STRICT/HYBRID/UNGROUNDED) "
"stay at τ_qa=7d (expensive LLM calls)."
"CANONICAL_PROJECTION row. RESOLVED in this dry-run "
"iteration.** All 29 CP rows in `qa.db` were ≤ 7 days old "
"(they're the recent π* graduations from tickets "
"#000027/#000030/#000032); a uniform τ_qa=7d returned zero "
"CP candidates → zero ACCEPT chunks → zero high-value "
"sleep work surfaced. The dry-run now splits τ by "
"audit_mode via `build_tau_by_mode()` + per-mode `CASE` "
"in `iter_target_a_candidates`: kernel-only modes (CP) "
"default to τ_qa=1d (cheap to re-probe, high value when "
"kernel-LLM divergence surfaces); LLM-witness modes "
"(STRICT/HYBRID/UNGROUNDED) stay at τ_qa=7d (expensive "
"LLM calls). Tunable via `--tau-qa-cp-days` + "
"`--tau-qa-days` CLI flags. Phase 3 lifts both into "
"governance parameters."
)
lines.append("")
lines.append(
@ -734,20 +781,24 @@ def render_markdown(a_results: dict, b_results: dict, opts: dict) -> str:
)
lines.append("")
lines.append(
"1. Per-audit-mode τ + per-audit-mode cost class (split "
"kernel-cost from LLM-cost on the input contract — "
"consider adding `kernel_cost` + `llm_cost` fields to "
"`ControllerBranch` in a v2 dataclass)."
"1. ~~Per-audit-mode τ + per-audit-mode cost class.~~ "
"**Landed.** Cost-class split landed in Phase 1.c (commit "
"`4b85a0a`); per-audit-mode τ landed in this dry-run "
"iteration. Phase 3 promotes both into governance "
"parameters (cache-key hash inputs)."
)
lines.append(
"2. Chunk size = Hermes concurrency (4 today, governance "
"param going forward)."
)
lines.append(
"3. Sweep-specific weight profile (gamma_5f bumped, "
"lambda_capital_cost dropped) since sweep work is "
"deliberately accepting capital cost in exchange for "
"falsification discovery."
"3. ~~Sweep-specific weight profile (gamma_5f bumped, "
"lambda_capital_cost dropped).~~ **Landed in Phase 1.c "
"(commit `4b85a0a`)** — `arborist.substrate.prometheus."
"sweep_weights()` returns the tuned profile "
"(gamma_5f=1.5, lambda_capital_cost=0.25, "
"nu_witness_divergence=0.5). Phase 3's scheduler picks it "
"up via `WEIGHT_PROFILES['sweep']`."
)
lines.append(
"4. MARGINAL queue from Target B becomes the funnel for "
@ -783,7 +834,13 @@ def main(argv: list[str] | None = None) -> int:
"--tau-qa-days",
type=int,
default=DEFAULT_TAU_QA_DAYS,
help="re-witness providence_cache rows older than this many days",
help="τ_qa for LLM-witness modes (STRICT/HYBRID/UNGROUNDED), days",
)
p.add_argument(
"--tau-qa-cp-days",
type=int,
default=DEFAULT_TAU_QA_CP_DAYS,
help="τ_qa for kernel-only mode (CANONICAL_PROJECTION), days",
)
p.add_argument(
"--sample-b",
@ -809,10 +866,12 @@ def main(argv: list[str] | None = None) -> int:
return 1
now = int(time.time())
tau_qa_seconds = args.tau_qa_days * 86400
tau_by_mode = build_tau_by_mode(
cp_days=args.tau_qa_cp_days, llm_days=args.tau_qa_days
)
sys.stderr.write(f"Target A sweep over {args.shards_dir}...\n")
a_results = sweep_target_a(args.shards_dir, tau_qa_seconds, now)
a_results = sweep_target_a(args.shards_dir, tau_by_mode, now)
sys.stderr.write(
f" {a_results['candidates_total']} candidates, "
f"{a_results['chunks_total']} chunks, "
@ -833,7 +892,8 @@ def main(argv: list[str] | None = None) -> int:
),
"shards_dir": str(args.shards_dir),
"tau_qa_days": args.tau_qa_days,
"tau_qa_seconds": tau_qa_seconds,
"tau_qa_cp_days": args.tau_qa_cp_days,
"tau_by_mode": tau_by_mode,
"sample_b": args.sample_b,
}