Skip to content

builder loop/20260425T233756Z 091233479/w1/4 4.a deepseek kimi cross provider reasoning isolation - #91

Merged
XelHaku merged 9 commits into
mainfrom
builder-loop/20260425T233756Z-091233479/w1/4-4.a-deepseek-kimi-cross-provider-reasoning-isolation
Apr 25, 2026
Merged

builder loop/20260425T233756Z 091233479/w1/4 4.a deepseek kimi cross provider reasoning isolation#91
XelHaku merged 9 commits into
mainfrom
builder-loop/20260425T233756Z-091233479/w1/4-4.a-deepseek-kimi-cross-provider-reasoning-isolation

Conversation

@XelHaku

@XelHaku XelHaku commented Apr 25, 2026

Copy link
Copy Markdown
Collaborator
  • feat(cmd-loops): per-subcommand --help and planner-loop trigger verb
  • feat(cmd-loops): doctor diagnoses drift; table-driven progress write
  • refactor(builder-loop): collapse progress write to table-driven loop
  • refactor(cmd-loops): cliDeps struct replaces package-level test seams
  • feat(cmd-loops): --format json on doctor and progress validate
  • feat(cmd): cmd/progress and cmd/repoctl as standalone binaries
  • feat(cmd-loops): finish exit codes (feat: add lineage-aware session search hits #12) and --format json (Add durable subagent job ledger #13)
  • chore(loop): stabilize production planner-builder run
  • fix(provider): isolate deepseek kimi reasoning replay

XelHaku and others added 9 commits April 25, 2026 13:28
Implements items #5 and #8 from docs/cmd-loops-improvements.md.

#5 — Per-subcommand --help:
  * Added subUsage map per binary keyed by subcommand path
    ("run", "progress validate", "service install", etc.).
  * --help/-h on any subcommand now prints just that verb's usage to
    stdout (exit 0) instead of dumping the full top-level surface.
  * Top-level `--help` / `-h` / `help` still prints the global usage.
  * Parser/dispatch errors keep wrapping errParse so they exit 2 via
    the shared mapping.

#8 — planner-loop trigger <reason>:
  * New subcommand appends a manual TriggerEvent (Source="manual",
    Kind="manual", Reason=<reason>) to PLANNER_TRIGGERS_PATH so the
    .path systemd unit fires a planner run shortly after.
  * Replaces the previous "touch the file" workflow operators were
    using; reason gets surfaced in the next planner prompt's trigger
    label so scheduled vs operator-asked vs impl_change are
    distinguishable downstream.
  * Multi-word reasons are joined with single spaces.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Implements items #6 and #10 from docs/cmd-loops-improvements.md.

#6 — Doctor actually diagnoses drift:
  * planner-loop doctor now also: parses+validates progress.json,
    verifies PLANNER_TRIGGERS_PATH is writable, and emits an advisory
    warning when the latest health_updated event is older than
    2× PLANNER_INTERVAL (planner ledger) or 1h (builder ledger).
  * builder-loop doctor introduced (was absent) with the same
    progress.json + triggers writability + builder-loop drift checks.
  * Drift warnings are advisory (exit 0) so doctor remains
    automation-safe; only hard preconditions (missing progress, parse
    failure, unwritable triggers path) fail the check.

#10 — Table-driven progress write:
  * Replaced the nine near-identical rewriteProgressMarker blocks with
    a []progressMarker table driven by one loop. Adding a new marker
    is now appending one struct entry instead of editing four
    boilerplate lines.

Helper extraction:
  * latestLedgerEventTime + driftWarning + triggerPathWritable are
    duplicated in both binaries for now (no internal/cmdcommon yet).
    Item #11 will collapse them once the cliDeps refactor lands.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Completes item #10 from docs/cmd-loops-improvements.md. The previous
commit's diff for this file silently dropped because the prepared
old_string referenced the pre-rename autoloopHandoff field name; the
intent was always to refactor here.

Replaced the nine near-identical rewriteProgressMarker blocks with a
[]progressMarker table driven by one loop. Adding a new generated
marker is now appending one struct entry instead of editing four
boilerplate lines.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Implements item #11 from docs/cmd-loops-improvements.md.

Both binaries now define a cliDeps struct (stdout, stderr, runner) and
a defaultDeps() constructor. main() builds the production deps and
passes them through run(); helper functions (printRunSummary,
printStatus, doctor, runTrigger, runService, installService, etc.)
take cliDeps explicitly.

The package-level commandStdout / serviceRunner / commandRunner globals
are gone. Tests construct their own deps and pass them to run() —
removing the t.Cleanup(func() { commandStdout = oldStdout }) dance and
the implicit shared mutable state that prevented t.Parallel().

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Implements item #13 from docs/cmd-loops-improvements.md, partially.

Both `doctor` subcommands and `progress validate` now accept
--format text|json. JSON shapes:

  doctor:           {"ok":true,"warnings":[...]}
  progress validate: {"ok":true,"phases":N}

This is enough to gate CI on doctor-clean / progress-clean without
parsing human prose.

Deferred (documented inline in the improvements doc): digest, audit,
and status. Their underlying internal helpers (DigestLedger,
WriteAuditReport, RenderStatus) return strings rather than structured
data, so a JSON variant requires refactoring the internal API. Worth
doing when an external consumer actually needs it; not worth doing
speculatively.

A new shared parseFormat helper is duplicated in both binaries; item
#11 already established the pattern of duplicating small CLI helpers
until an internal/cmdcommon package is justified.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Implements item #9 from docs/cmd-loops-improvements.md.

* New internal/progressctl package owns the regeneration logic for the
  building-gormes progress control plane: Validate(stdout, root, format)
  and Write(stdout, root). The marker table moves with it.
* New cmd/progress is a thin top-level binary calling the package
  directly. Supports --repo-root, --format text|json, and the validate
  / write verbs.
* New cmd/repoctl wraps the existing internal/repoctl package the same
  way: --repo-root, plus `benchmark record` and `readme update`.
* cmd/builder-loop/progress.go shrinks to a 30-line dispatcher that
  forwards to internal/progressctl, so the existing
  `builder-loop progress …` and `builder-loop repo …` paths keep
  working for back-compat. cmd/builder-loop's binary still imports
  internal/progress and internal/repoctl transitively, but the shared
  surface area is now structured to support clean removal once
  operators have migrated.

Operators can now type:
  go run ./cmd/progress validate --format json
  go run ./cmd/repoctl readme update
instead of the longer builder-loop forms.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
#12 — Structured exit codes (now full delivery):
  * New ErrPostPromotionVerifyFailed sentinel in internal/builderloop;
    runPostPromotionVerifyAndRepair joins it with the underlying error
    on terminal verify failure so cmd/ can errors.Is detect it.
  * classifyExit helper in both binaries maps:
      errParse                              → 2 (parse / config)
      builderloop.ErrPostPromotionVerifyFailed → 30 (builder-loop only)
      context.DeadlineExceeded / Canceled   → 20 (backend timeout)
      anything else                         → 1 (internal)
  * "no-work=10" intentionally NOT emitted: a 0-candidates idle tick is
    normal, and systemd Restart=on-failure would flap. Documented in
    the improvements doc.

#13 — --format json (now full delivery):
  * digest: builderloop.DigestLedgerCounts(path) added as the
    structured companion to DigestLedger; cmd emits the full event ->
    count map as JSON.
  * audit: cmd emits {"summary":"<text>"}; structured audit ledger
    already exists at <auditDir>/report.ndjson + report.csv, so the
    wrapper just gives scripts a stable JSON object.
  * status: cmd emits {"status":"<text>"}; structured planner state
    lives in planner_state.json.
  * digest gets a --format flag in addition to the existing
    --output/--force, with a JSON-also-respects-clobber-guard path.

Tests cover classifyExit for all four cases per binary.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@XelHaku
XelHaku merged commit 9e66606 into main Apr 25, 2026
@XelHaku
XelHaku deleted the builder-loop/20260425T233756Z-091233479/w1/4-4.a-deepseek-kimi-cross-provider-reasoning-isolation branch April 25, 2026 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant