token-offload: adhoc json reshaping (inference-arbitrage:offload-analyst) #24
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Measured cost. 849.5k weighted tokens over 26 invocations (2026-07-29T18:42:20Z -> 2026-07-30T14:40:05Z), 40% of this plugin's audited spend.
Evidence strength.
measured— 26 invocations, 208 attributed turns.Boundary position. llm-over-script-digest — confidence high.
Determinism tests: T1 ✓ T2 ✓ T3 ✓ T4 ✓ T5 ✓
Proposed signature.
candidate_digest(inv: PluginInventory, scan: OffloadScan) -> list[CandidateRow]Examples.
When a human would overrule this. A row crosses every mechanical threshold (share, mtr, read-amplification, recurring ngram) yet the recurring shape turns out to be this audit's own necessary two-pass discipline (read the static inventory, then the dynamic scan, then reshape both into a working set) rather than a genuinely wasteful loop. The digest can only see token/turn shape, not intent, so a human analyst still has to look at the actual command sequence before deciding candidate vs necessary-overhead. This is why the cut is position 3 (a digest that feeds analyst judgment), not position 1 (an auto-filed script).
Escalation path. The digest flags a row when it crosses the already-codified static thresholds (same constants boundary-classify already uses: MIN_INVOCATIONS, MIN_ATTRIBUTED_TURNS, MIN_SHARE_OF_SPEND) or shows a dominant recurring n-gram with judgment_density below a documented cutoff. A flagged row is not auto-graded: the analyst reads the actual ngram/tool-call shape, applies the judgment_density brake, and only rows the analyst confirms as genuine candidates proceed into a judgments.json entry for boundary-classify.
What crosses the boundary. {'row_kind': 'skill | agent', 'name': 'str', 'share_of_spend': 'float', 'mtr': 'float', 'judgment_density': 'float', 'read_amplification': 'float', 'retry_density': 'float', 'fanout_multiplier': 'float', 'dominant_ngram_recurrences': 'int | null', 'has_bin_script': 'bool', 'flags': 'list[str]'}
This is a proposal from an audit, not an accepted design. It is deliberately
falsifiable: if the overrule case above is common, the cut belongs earlier in
the pipeline than proposed, and this issue should be reshaped rather than
implemented. Closing this as
wontfixis a useful outcome and is tracked as acalibration signal.
Audit:
Audits/inference-arbitrage/2026-07-30on the kotkan/claude-plugin-inference-arbitrage wiki. Rubric v1.0.0.Root cause confirmed as diagnosed.
agents/offload-analyst.md§2 ("Gather candidates from three distinct sources") told the analyst to readinv.jsonandscan.jsonand reshape them into a candidate table by hand, every audit run — nobin/script existed for that join.skills/offload-audit/SKILL.mdstep 3 had the same gap.Fix: kotkan/claude-plugin-inference-arbitrage#28 (branch
fix/issue-24-candidate-digest, PR open intomain).Added
bin/candidate-digest inv.json scan.json --json, implementingcandidate_digest(inv, scan) -> list[CandidateRow]exactly to the signature proposed in this issue. Design choices, with evidence:MIN_INVOCATIONS/MIN_ATTRIBUTED_TURNSfrombin/boundary-classifyandMIN_SHARE_OF_SPENDfrombin/ia_store.py— no new share/invocation constants.JUDGMENT_DENSITY_BRAKE = 0.3constant (no existing catalog threshold covered this axis). Verified against both worked examples from this issue's body:tests/candidate-digest.test.sh, examples 2 and 3/EDGE — both pass)plugin-inventory'scommand_blocks(a skill whose own documented procedure already invokesbin/...). For agent rows this is conservativelyFalse—plugin-inventory's JSON carries no agent body/command-block text at all, only skills do, so the script genuinely cannot see this for agents. Documented inline as a real limitation, not a shortcut.flagsis documented (in the script's own docstring and in bothSKILL.md/offload-analyst.md) as advisory input to the analyst's own read of the actual n-gram/tool-call shape — never a verdict.bin/boundary-classifyremains the only place a verdict is computed;candidate-digesthas no filing gate of its own and is never called from the filing chain.Real-data verification (not just synthetic fixtures), against a matched
inv.json/scan.jsonpair from a prioranxiousaudit left in/tmp:Output is correctly sorted by
share_of_spend, flags only fire on rows that clear every gate,has_bin_scriptisfalseeverywhere (noanxiousskill's command blocks referencebin/, which matches its actual layout).Wiring:
skills/offload-audit/SKILL.mdstep 3 andagents/offload-analyst.md§2 both now callbin/candidate-digestand explicitly state the flag semantics (advisory, brake-suppressed, never a filing trigger).Tests:
tests/candidate-digest.test.sh(new, auto-discovered bytests/run-all.sh) covers all three worked examples plus a below-MIN_SHARE_OF_SPENDcase and a fullCandidateRowschema check. Full suite run:No
FAIL/MISSING/Tracebackanywhere in the log.Issue body assessment: not stale — read correctly, matches current repo state (
agents/offload-analyst.md,skills/offload-audit/SKILL.md,bin/boundary-classify,bin/ia_store.pyall confirmed by direct read before implementing). No misdiagnosis found.PR: kotkan/claude-plugin-inference-arbitrage#28 (not merged — leaving that to whoever reviews).
Fixed and merged via PR #28, commit
0482278(merged onto main after a trivial version-field conflict with #27, resolved as 0.8.1). Closing.