[rebase w2] src/rune/token_optimizer.py::main #769

Closed
opened 2026-09-29 08:07:24 +01:00 by conductor · 3 comments
Owner

Identity (from the Wave 0 inventory — machine-generated)

  • File: src/rune/token_optimizer.py
  • Unit: main
  • Signature: def main() (async: False)
  • Line range: 312–357
  • Decorators: none
  • Internal call edges (callers/callees inside the repo, from inventory):
    • get_optimizer (line 322)

Current behaviour

One honest paragraph from READING THE CODE at the line range above — what it
actually does, not what the docstring promises. Write this at disposition
time; the factory does not fabricate it.

The three questions — each answered WITH EVIDENCE

  1. IMPROVE? Can the unit be improved within its scope? Evidence or "no — because …".
    (Bounded to unit scope; larger findings spawn NEW issues, never expand this one.)
  2. FIX? Is it broken, buggy, or failing its expected outcome? Evidence: a failing
    test, a reproduced fault, or a code-level defect citation. A "no" needs evidence too.
  3. MISSING CONNECTORS? Are there expected outcomes this unit should connect to but
    doesn't (unwired events, dead parameters, promised-but-absent calls)? Evidence required.

A silent skip on any question is a factory bug — answer all three.

Language verdict (per tranche R1 §6 rubric — evidence beats instinct)

Choose exactly one, with the evidence line:

  • KEEP-PYTHON — one sentence of justification.
  • RECODE- — rubric scores (all 7 dimensions) + benchmark-gate plan: the compiled
    replacement must beat the Python original on the MEASURED hot path, or the recode is
    rejected and recorded. No win, no recode.
  • MERGE-into: — name the target and why.
  • DEPRECATE — name the caller that no longer needs it.

Go is NOT pre-decided. Python is not pre-decided. The rubric decides.

Constraint context

  • henxels structural contract: this unit's module ≤ 1,200 lines (or on the debt table's
    exception list — check before adding lines).
  • Spine: any module-surface change requires store/spine/current.json regen with the code
    change (test_manifest_maps_every_module is the arbiter for new top-level modules).
  • Debt table: docs/structural-contract.md.

Pipeline plan

  1. Branch issue-<N> from current master (existing issue-N convention).
  2. Scaffolding activation for any construction (construction_mode/decision per unit change).
  3. Research rounds are MANDATORY for any RECODE verdict (research-stage-headless; ≥2
    live-verified external sources per claim; per-source lessons; kill test per candidate).
  4. Implementation behind the interop contract (R1 §5): compiled units are standalone
    binaries — argv in, JSON on stdout, non-zero exit on failure, --version mandatory;
    Python wraps in a thin adapter; store stays the shared truth.
  5. Local gates: pytest + ruff + spine-store regen (if surface changed) + henxels.
  6. PR → pipeline-gate + ci + required checks → merge-robot → auto-version.

Verification

  • The specific test proving this unit's change: (write at disposition).
  • The keep-green set it must not break: full suite must stay green; named
    keep-green tests for this unit's callers.

Provenance

  • Tranche: tranche R1 language rebase (2026-09-29), ~/.config/opencode/tranches/2026-09-29-language-rebase-tranche-R1.md
  • Wave: 2 (leaf utilities & canaries)
  • Inventory: docs/rebase-inventory.json (regenerate with scripts/rebase_inventory.py — never hand-edit)
  • Factory: scripts/rebase_issue_factory.py
## Identity (from the Wave 0 inventory — machine-generated) - **File**: `src/rune/token_optimizer.py` - **Unit**: `main` - **Signature**: `def main()` (async: False) - **Line range**: 312–357 - **Decorators**: none - **Internal call edges** (callers/callees inside the repo, from inventory): - `get_optimizer` (line 322) ## Current behaviour One honest paragraph from READING THE CODE at the line range above — what it actually does, not what the docstring promises. Write this at disposition time; the factory does not fabricate it. ## The three questions — each answered WITH EVIDENCE 1. **IMPROVE?** Can the unit be improved within its scope? Evidence or "no — because …". (Bounded to unit scope; larger findings spawn NEW issues, never expand this one.) 2. **FIX?** Is it broken, buggy, or failing its expected outcome? Evidence: a failing test, a reproduced fault, or a code-level defect citation. A "no" needs evidence too. 3. **MISSING CONNECTORS?** Are there expected outcomes this unit should connect to but doesn't (unwired events, dead parameters, promised-but-absent calls)? Evidence required. A silent skip on any question is a factory bug — answer all three. ## Language verdict (per tranche R1 §6 rubric — evidence beats instinct) Choose exactly one, with the evidence line: - **KEEP-PYTHON** — one sentence of justification. - **RECODE-<lang>** — rubric scores (all 7 dimensions) + benchmark-gate plan: the compiled replacement must beat the Python original on the MEASURED hot path, or the recode is rejected and recorded. No win, no recode. - **MERGE-into:<module>** — name the target and why. - **DEPRECATE** — name the caller that no longer needs it. Go is NOT pre-decided. Python is not pre-decided. The rubric decides. ## Constraint context - henxels structural contract: this unit's module ≤ 1,200 lines (or on the debt table's exception list — check before adding lines). - Spine: any module-surface change requires `store/spine/current.json` regen with the code change (`test_manifest_maps_every_module` is the arbiter for new top-level modules). - Debt table: docs/structural-contract.md. ## Pipeline plan 1. Branch `issue-<N>` from current master (existing issue-N convention). 2. Scaffolding activation for any construction (construction_mode/decision per unit change). 3. Research rounds are MANDATORY for any RECODE verdict (research-stage-headless; ≥2 live-verified external sources per claim; per-source lessons; kill test per candidate). 4. Implementation behind the interop contract (R1 §5): compiled units are standalone binaries — argv in, JSON on stdout, non-zero exit on failure, `--version` mandatory; Python wraps in a thin adapter; store stays the shared truth. 5. Local gates: pytest + ruff + spine-store regen (if surface changed) + henxels. 6. PR → pipeline-gate + ci + required checks → merge-robot → auto-version. ## Verification - The specific test proving this unit's change: (write at disposition). - The keep-green set it must not break: full suite must stay green; named keep-green tests for this unit's callers. ## Provenance - Tranche: tranche R1 language rebase (2026-09-29), ~/.config/opencode/tranches/2026-09-29-language-rebase-tranche-R1.md - Wave: 2 (leaf utilities & canaries) - Inventory: docs/rebase-inventory.json (regenerate with scripts/rebase_inventory.py — never hand-edit) - Factory: scripts/rebase_issue_factory.py

⚠️ Priority gate: this issue has no priority. Assign exactly one of P0 — critical (spine/correctness/blocks), P1 — high (material value or real defect), P2 — medium (quality/consolidation), P3 — low (measurement/deferred). An issue without a priority is not filed.

⚠️ **Priority gate:** this issue has no priority. Assign exactly one of **P0 — critical** (spine/correctness/blocks), **P1 — high** (material value or real defect), **P2 — medium** (quality/consolidation), **P3 — low** (measurement/deferred). An issue without a priority is not filed.
gitea-actions Bot added the bugcustodiangrowthidentityinfrastructurememory labels 2026-09-29 08:21:33 +01:00
Author
Owner

Disposition — main (CLI entry point, 318–363)

Current behaviour (from code read): argv router for three commands (status, cache, optimize <text>), each printing human-readable lines from the corresponding API surface, with usage text on no/unknown command. Critically, it ends with opt.flush() (line 363) — the CLI's writes are durably persisted on every invocation, which is what makes the write-batching thresholds safe for short-lived processes.

  1. IMPROVE? No — for its scope (a diagnostic CLI) the flat if/elif router is the right shape; argparse would add surface without adding capability.
  2. FIX? No — exercised this session: status, cache, and unknown-command paths all read correct against the code. The roundtrip defect surfaced through this CLI's persistence path, but the defect was #770's, fixed separately.
  3. MISSING CONNECTORS? No — all three commands connect to their backing methods; flush() closes the write path. No promised-but-absent command (docstring usage block matches implemented commands exactly).

Language verdict (rebase R1 §6 rubric): KEEP-PYTHON. The wave's heaviest work in this module is 2 re.sub per turn (rubric :280) — no hot loop exists here; every candidate compiled crossing costs ~658 µs (14,000× the cost of the work it would replace), and this unit is already on the CPython 3.11+ PEP 659 shape the rubric awards (rubric :282). No benchmark gate is owed: no measured hot path exists to beat. Zero RECODE.

## Disposition — `main` (CLI entry point, 318–363) **Current behaviour (from code read):** argv router for three commands (`status`, `cache`, `optimize <text>`), each printing human-readable lines from the corresponding API surface, with usage text on no/unknown command. Critically, it ends with `opt.flush()` (line 363) — the CLI's writes are durably persisted on every invocation, which is what makes the write-batching thresholds safe for short-lived processes. 1. **IMPROVE?** No — for its scope (a diagnostic CLI) the flat if/elif router is the right shape; argparse would add surface without adding capability. 2. **FIX?** No — exercised this session: `status`, `cache`, and unknown-command paths all read correct against the code. The roundtrip defect surfaced *through* this CLI's persistence path, but the defect was #770's, fixed separately. 3. **MISSING CONNECTORS?** No — all three commands connect to their backing methods; `flush()` closes the write path. No promised-but-absent command (docstring usage block matches implemented commands exactly). **Language verdict (rebase R1 §6 rubric): KEEP-PYTHON.** The wave's heaviest work in this module is 2 `re.sub` per turn (rubric `:280`) — no hot loop exists here; every candidate compiled crossing costs ~658 µs (14,000× the cost of the work it would replace), and this unit is already on the CPython 3.11+ PEP 659 shape the rubric awards (rubric `:282`). No benchmark gate is owed: no measured hot path exists to beat. Zero RECODE.
Author
Owner

Folded into epic #2303 — per-file epic for src/rune/token_optimizer.py (w2). Absorbed child; closing as absorbed (content preserved, reversible by reopen).

Folded into epic #2303 — per-file epic for `src/rune/token_optimizer.py` (w2). Absorbed child; closing as absorbed (content preserved, reversible by reopen).
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: conductor/rune#769