Skip to content

feat(routing)!: autorouting with policy-derived tiers, preset layer removed - #4543

Draft
Yeachan-Heo wants to merge 44 commits into
devfrom
feat/autorouting
Draft

feat(routing)!: autorouting with policy-derived tiers, preset layer removed#4543
Yeachan-Heo wants to merge 44 commits into
devfrom
feat/autorouting

Conversation

@Yeachan-Heo

@Yeachan-Heo Yeachan-Heo commented Aug 14, 2026

Copy link
Copy Markdown
Owner

gajae.pr-review-verdict.v1 needs-human sha256:288ef0b4b70db0ba4eb6aa9a3c9651f171e548ac7801eed5fdca48083d4db7de reviewer:human reviewer-id:pending evidence:exact-head-e7b95a4ce957c00d36d532eae62a959ee9295c1b-current-dev-cd51365cc270e27dceccfc2c184fadc9c1ddbe18-owner-controlled-draft-fix-forward-owner-readiness-required

Supersedes #3764, which was closed without merge because exact-head Dev CI was red across unrelated current-dev surfaces. This is the same reviewed branch, rebased onto a much newer dev (271 commits of drift), with the preset layer now removed.

What

Opt-in sub-agent model autorouting for the Task tool, with tier chains derived from the provider-selection policy rather than a hardcoded preset table.

  • task.autorouting.enabled (default false) activates the fixed fast/balanced/strong tier vocabulary. Tiers come from task.autorouting.tiers; an omitted tier on a Task item routes as balanced; an autorouting pin overrides the manual model chain.
  • Selectors stay exact provider-qualified provider/modelId strings with an optional thinking suffix. Globs and prefixes are rejected.
  • /routing opens the smart-routing panel directly; /routing on|off toggles enablement; /routing status reports settings-derived state.

Preset-source unification

task.autorouting.preset and the whole preset layer are removed, not deprecated — there is no compatibility shim, per the repo's no-backward-compatibility rule.

  • projectProviderOrder is extracted as the single implementation of "configured modelProviderOrder first, then first-wins catalog order", and createProviderSelectionPolicy is rewritten on top of it.
  • ModelRegistry.autoroutingProviderOrder() takes no session and bypasses the policy builder entirely, so no effectiveAuth map is assembled: auth-independence is structural, not conventional. Auth-aware banding stays private to rank().
  • Comparison uses normalized ids while persistence keeps catalog spelling, because the generator matches provider prefixes case-sensitively — a lowercased CustomRouter would silently empty that provider's tiers.
  • Configured providers absent from the catalog are dropped before reaching setup.providers, so a dead declaration cannot pollute declarationFingerprint.
  • The panel seeds from derived priority with no hardcoded provider fallback and refuses entry when no providers are available. Refresh reseeds a recorded declaration and refuses to persist an empty result.

Breaking changes

  • task.autorouting.preset is gone. A preset-only configuration routes manually until tiers are generated.
  • Public TypeScript contracts drop AutoroutingEffective.source, RoutingOutcome.source, AUTOROUTING_PRESETS, AutoroutingPresetId, and resolveTierMap from ./config/*, plus TaskRoutingEvidence.source from ./task/*. The union collapsed to one value, so keeping it would have published a meaningless required field on a durable receipt.
  • Receipt and summary routing note values change format to tier/fallback/resume components only.
  • /routing status relabels settings-derived tiers, with malformed provenance failing closed as hand-authored instead of reporting generated.

Inactive-autorouting warning

Enabling autorouting without usable tiers previously failed silently. The host now decides once, where settings are already available, and reports through one shared uninterpolated constant on all three surfaces:

  • interactive and print read session.configWarnings;
  • ACP receives it through the existing SDK event replay ring. SessionEventStream retains frames, so a notice published at host start() reaches a client that attaches later; ACP captures it onto the session record without early render and republishes once during deferred bootstrap beside the auth-failure branch.

No new public query, no getSdkConfigItems/config.list expansion, no general configWarnings exposure, and no new event kind. The internal flag lives in a package-private module that is null-mapped in the package exports, with a guard test asserting it is unreachable from any published type.

Rebase notes

Rebased onto dev at f0453b6ab1. Two commits were dropped as genuinely obsolete rather than force-fitted:

Substantive conflict resolutions: dev removed its #writeTerminalBreadcrumb wrapper and the staged-publication/terminalBreadcrumbs fields, so those callsites were converted to dev's direct free-function form rather than reintroducing a wrapper; the /theme and /routing slash-command test blocks were unioned with correct closers.

Verification

  • check:types clean; repo-wide biome check exits 0.
  • Focused suites on the rebased tree: 98 pass across the autorouting contract/generator/tier-map/boundary suites, 113 pass across the task-routing, panel-integration, slash-command and ACP-notice suites, 336 pass across the session-staging and SDK/ACP suites.
  • AC10b is proven on a real lifecycle path: a real AcpAgent driven through newSession against a fixture broker observes exactly one [warning:autorouting] chunk, which only holds because the notice survives late-attach replay. Disabling the host emission fails it while the zero-notice case still passes.
  • Regressions added in this branch were negative-control verified — removing the spelling restore, the catalog-append branch, the host emission, or the export-map guard each fails the test that names it.
  • Mandatory computer-use red-team suite passes all seven cases (required because the change set touches config/settings-schema.ts).

bun run check currently fails on two gates that fail identically on a pristine origin/dev worktree at f0453b6ab1, measured on the same machine with shared node_modules:

  • the telegram baseline manifest reports the same five missing commands on both sides;
  • verify-gjc-sdk-canonicalization reports 27 violations on both sides, and the sorted violation sets diff empty. Every chain is rooted at the dev-owned session-state-sidecar.ts -> tools/descriptors.ts edge, and this branch touches none of the chain roots.

Opened as a draft because #3764's closure standard requires green current CI, and those dev-side surfaces are still red at this base.

@Yeachan-Heo

Copy link
Copy Markdown
Owner Author

Draft hold — reconciliation evidence vs current dev and #4561

Recorded heads before any action (exact-head discipline): this draft PR head 874c59f949ea7ec5331da4a13142e7458ce836e9 (30 commits), merge-base with dev 3d9c8f2331, current dev 64c15281691280be7854dac04baeb05188328ef4. PR #4561 head 74156c1580cfb13ea9f5b11ec1195fc2b027f782 (5 commits, APPROVED, MERGEABLE, not merged into dev as of this check).

Reconciliation findings

1. Absorption by dev: none. 0 of the 30 PR commit patch-ids appear in dev since the base; dev contains no autorouting files at all. Nothing here was independently landed.

2. Textual conflicts vs current dev: exactly 1 file, mechanical. A real trial merge of this PR head into dev 64c1528 conflicts only in scripts/telegram-daemon-generation-manifest.json — a single digest hunk for sdk/bus/index.ts:createNotificationsExtension (dev 32faaf97… vs PR ba9b4354…). Cause: dev landed the notification-bus series (6e7c87a769, 5e25bde5b4, 153c73da00) after this PR's last rebase (46 dev commits since). Resolution is regenerating the digest, exactly what 874c59f949 did after the previous rebase. The 3 other both-sides files (sdk/bus/index.ts, sdk/host/session-runtime.ts, CHANGELOG.md) auto-merge cleanly.

3. Overlap with #4561 (oMLX presets): 4 files, 1 real conflict. Trial merge of #4561 onto this PR's head conflicts only in packages/coding-agent/src/task/executor.ts (~line 1713): this PR keeps the explicitThinkingLevel destructure; #4561's 8626a51bab removes it and replaces the effective-thinking gate with resolvedThinkingLevel ?? thinkingLevel for models without thinking config (oMLX). The other 3 overlap files (model-registry.ts, model-selector.ts, task/index.ts) auto-merge.

4. Not supersession — disjoint preset layers. The breaking removal here (5438dd6d2f) deletes only the autorouting preset tier-map layer (AUTOROUTING_PRESETS, AUTOROUTING_PRESET_IDS, AutoroutingPresetId, resolveTierMap, the task.autorouting.preset setting). It does not touch model-profiles.ts. #4561 builds model-profile presets (profile("omlx-qwen36-…"), groupModelProfilesForPresetLanding) plus oMLX provider plumbing (oauth/omlx.ts, port 8000, sentinel filtering) — none of which this PR removes. ModelSelectorViewMode on this head still includes "presets". The two coexist at the product layer: tiers route, profiles stay the manual-selection surface.

5. Residual semantic risk. #4561's thinking-level fallback changes the same resolution path this PR's routed :effort selectors depend on (AUTOROUTING_SELECTOR_PATTERN suffix → resolveModelOverrideWithAuthFallbackexplicitThinkingLeveleffectiveThinkingLevel at executor.ts:1786). Dev's model-resolver.ts:905 already carries the resolveThinkingLevelForModel(...) ?? resolved.thinkingLevel fallback, so the contracts converge — but the executor hunk must be hand-re-resolved when rebasing over 8626a51bab.

Owner decision (blocking)

  • (a) Rebase onto post-feat(ai,config): add oMLX hybrid role-optimized presets #4561 dev — evidence supports this cleanly: 1 mechanical manifest-digest regeneration + 1 hand-re-resolved executor.ts thinking hunk; no supersession.
  • (b) Hold as competing direction — the breaking task.autorouting.preset removal is a product default this lane must not choose.
  • (c) Close as supersedednot supported by evidence (disjoint layers, zero absorption).

This lane stays an explicitly owned draft hold: not marked ready, not pushed, not merged, not closed. All merge trials ran in throwaway worktrees and were aborted; no branch or ref was mutated.

— gaebal-gajae

@Yeachan-Heo

Copy link
Copy Markdown
Owner Author

Evidence refresh — dev advanced to 96e718a2, #4561 head moved

Following exact-head discipline: the previous reconciliation comment was bound to dev 64c1528 and #4561 head 74156c158; both moved, so the trial-merge evidence was recomputed from scratch. Both trial merges ran in throwaway worktrees and were aborted; no ref was mutated.

Recomputed state (live REST/API):

Recomputed trial merge, this PR → dev 96e718a2: still exactly 1 conflict filescripts/telegram-daemon-generation-manifest.json, same single digest hunk (createNotificationsExtension: dev 32faaf97… vs this PR ba9b4354…). #4540's session-runtime.ts edits and this PR's edits there auto-merge cleanly (overlap files: CHANGELOG.md, session-runtime.ts only).

Recomputed trial merge, #4561 49e790f4f8 → this PR head: now 2 conflict filestask/executor.ts (same explicitThinkingLevel hunk at ~1713; bb1403448b removes it) and scripts/telegram-daemon-generation-manifest.json (new conflict: #4561's rebase onto dev brought manifest edits). File overlap grew to 5 (added CHANGELOG.md).

Unchanged conclusions, now bound to exact 96e718a2 + 49e790f4f8: absorption still 0/30 (no autorouting files/symbols on dev), preset layers still disjoint (this PR removes only the autorouting tier-map preset symbols and task.autorouting.preset; #4561 builds model-profiles()/oMLX plumbing untouched here). Verdict: partial overlap, not supersession.

Owner decision (blocking, unchanged): (a) rebase onto post-#4561 dev — now 1 mechanical digest regeneration + 1 hand-re-resolved executor.ts hunk + CHANGELOG.md; (b) hold as competing direction; (c) close as superseded — still unsupported. Lane remains an explicitly owned draft hold: not ready, not pushed, not merged, not closed.

— gaebal-gajae

@Yeachan-Heo

Copy link
Copy Markdown
Owner Author

OWNER-CONTROLLED DRAFT HOLD — verdict + evidence update (needs-human)

Verdict: NEEDS-HUMAN — owner decision required. Bound to the submitted PR digest via ls-remote (not a local trial): PR head refs/pull/4543/head = 874c59f949ea7ec5331da4a13142e7458ce836e9, recorded base 0f8624d177560461f3da4f02e459bc3d7624c031 (base branch dev), merge-base with dev 3d9c8f2331, 30 commits. Current refs/heads/dev = 96e718a2b0f2a46cad4876bf922886966c6fd0e3 (advanced from 64c1528 via #4540). PR #4561 current head refs/pull/4561/head = 49e790f4f8e6b2a8335a9f568ea46b9662c8e214 (force-moved from 74156c1580, rebased onto 64c1528; open, not draft, not merged into dev).

Conflict / supersession matrix (recomputed against exact 96e718a2 + 49e790f4f8)

Surface Result
Absorption of this PR by dev 0 of 30 commit patch-ids in dev since base; 0 autorouting files/symbols anywhere on 96e718a2
This PR → dev 96e718a2 trial merge 1 conflict file: scripts/telegram-daemon-generation-manifest.json (single digest hunk, createNotificationsExtension: dev 32faaf97… vs PR ba9b4354…); mechanical — regenerate digest as commit 874c59f949 did before. #4540's session-runtime.ts/CHANGELOG.md edits auto-merge with this PR's
#4561 (49e790f4f8) → this PR head trial merge 2 conflict files: task/executor.ts (~line 1713 explicitThinkingLevel hunk; #4561 commit bb1403448b removes it and switches to resolvedThinkingLevel ?? thinkingLevel) and telegram-daemon-generation-manifest.json (new: #4561's rebase brought manifest edits). Overlap set: model-registry.ts, model-selector.ts, executor.ts, task/index.ts, CHANGELOG.md
Supersession None. Preset layers are disjoint: this PR removes only AUTOROUTING_PRESETS, AUTOROUTING_PRESET_IDS, AutoroutingPresetId, resolveTierMap, task.autorouting.preset; #4561 never touches those symbols (0 matches) and builds model-profiles() presets + oMLX provider plumbing, untouched here. Partial overlap, not replacement
Residual semantic risk #4561's thinking-level fallback changes the same resolution path this PR's routed :effort selectors depend on (AUTOROUTING_SELECTOR_PATTERNexplicitThinkingLeveleffectiveThinkingLevel at executor.ts:1786) — the executor hunk must be hand-re-resolved at rebase time

Exact owner choices (pick one)

Lane state (unchanged by this update)

Draft, open, head 874c59f949, not pushed, not marked ready, not merged, not closed. Local worktree fast-forwarded to 96e718a2 (read-only bookkeeping; no push). All trial merges ran in throwaway worktrees, aborted and removed. Resumption of this lane requires fresh owner direction; the agent must not pick (a)/(b)/(c) on its own — choosing is a product-default decision reserved to the owner.

— gaebal-gajae

@Yeachan-Heo

Copy link
Copy Markdown
Owner Author

Correction (exact-head discipline): #4561 head moved again after the hold comment posted. Current refs/pull/4561/head = c1b8e021273f553f14ba832ae1feb185e5309ff2 (was 49e790f4f8), now rebased onto dev 96e718a2 (merge-base verified). Trial merge of c1b8e0212 → this PR head recomputed: conflict surface unchanged — same 2 files (task/executor.ts explicitThinkingLevel hunk, telegram-daemon-generation-manifest.json), same 5-file overlap set. #4561 still open and unmerged, so option (a)'s "post-#4561 dev" still does not exist. Every other matrix row and the owner choices stand as posted. Any future resumption of this lane must re-verify #4561's head again before relying on these numbers.

— gaebal-gajae

@Yeachan-Heo

Copy link
Copy Markdown
Owner Author

Rebased onto dev at 290b31c110 (101 commits of drift, including the fix(ci) exact-head PR-gate series). Head is now 4b9fea8f4f, behind_dev=0 at push time.

Rebase: 29 of 30 commits replayed with no conflicts. The only conflict was the regenerable telegram digest commit, which was skipped and regenerated against the new base instead of hand-merged.

Two adaptations dev forced:

  • 44 new catalog keys arrived with dev, so check:autorouting-map failed closed on uncurated coverage. They are recorded as baseline skips with an explicit rationale rather than given invented tier/rank data. Gate now passes at 4264 in-scope keys.
  • A stray blank line from the earlier #writeTerminalBreadcrumb conflict resolution reappeared. Last cycle I had folded that formatting fix into the telegram digest commit; skipping that commit this cycle discarded the fix with it, so it is now its own commit and will survive future rebases.

Focused verification on this base: check:types clean, repo-wide biome check exits 0, and 222 tests pass with 0 failures — 98 across the autorouting contract/generator/tier-map/boundary/private-seam suites, 124 across task-routing, preflight, red-team, panel integration, slash-command, ACP notice, tool-catalog, session-staging and SDK/ACP production-path.

Pre-existing dev failures (unchanged conclusion, re-measured against a pristine origin/dev worktree at 290b31c110, same machine, shared node_modules):

  • scripts/telegram-daemon-generation-guard.test.ts fails with ENOENT on packages/coding-agent/test/notifications-topic-registry.test.ts — identical failure on pristine dev.
  • The telegram baseline manifest reports 8 missing commands on both sides (was 5 at the previous base).
  • verify-gjc-sdk-canonicalization reports 27 violations on both sides with an empty sorted diff; every chain is rooted at the dev-owned session-state-sidecar.ts -> tools/descriptors.ts edge, and this branch touches none of the chain roots.

Still a draft for the reason #3764 was closed: the MERGE_READY bar wants green current CI, and those surfaces are red at this base independent of this branch.

@Yeachan-Heo

Copy link
Copy Markdown
Owner Author

Draft CI classification at exact head 4b9fea8f4f

This PR remains an owner-controlled Draft at head 4b9fea8f4f0dbdb2025886c97510db4dbf6f55b9, based on current dev 290b31c110889f375c7713b3f64bd10c6338093e. Run 31869555814 is still in progress; current failures classify as follows:

  1. Inherited current-dev failure — not PR-induced

  2. CI transport failure — not a product-test failure

    • shard-5 job 94976620842
    • tests reached completion, but actions/upload-artifact failed during FinalizeArtifact with ECONNRESET
  3. Genuine feat(routing)!: autorouting with policy-derived tiers, preset layer removed #4543 Draft blocker

    • Telegram generation guard job 94976007494
    • packages/coding-agent/src/sdk/bus/index.ts:createNotificationsExtension changes protected Telegram lifecycle behavior without the required strictly higher DAEMON_GENERATION
    • this must be corrected atomically with the repository generation tool before the Draft can become Ready
  4. Expected Draft merge gate

    • bootstrap is closed because this Draft has no merge-approved exact-head contract. It is not merge-ready.

No merge-ready claim is made. No duplicate browser fix belongs in this Draft. Preserve the owner-controlled Draft state; before any Ready transition, reconcile onto green dev after #4575, apply the required Telegram generation bump, rerun exact-head product CI, and obtain fresh review.


[repo owner's gaebal-gajae (clawdbot) 🦞]

@Yeachan-Heo

Copy link
Copy Markdown
Owner Author

CI repair pushed to feat/autorouting at d28445e7b9507cd8b27d2966a17f511ea346742e, rebased on current dev 1cc986422ae335bc155740b1060f6be10cfee4b4. Live API and origin/feat/autorouting both confirm that exact head; PR remains Draft.

Fixed product blockers:

  • Telegram lifecycle guard: canonical --fix-generations advanced DAEMON_GENERATION 168→169, updated the topic-registry pin and semantic manifest.
  • Managed OpenAI Responses replay sanitation now removes stale metadata in memory without appending entry_patch records.
  • Presetless model selector accepts minimal settings adapters while preserving the provider-order listener when available; provider onboarding offline refresh/config notification/selector visibility pass.
  • ACP autorouting fixture now registers, awaits, and closes its owned ACP session before broker-root teardown; repeated fresh Bun processes pass without root-recreation cleanup evidence.

Validation on the rebased head:

  • bun --cwd=packages/coding-agent run check
  • generation authority/current-tree validation plus scripts/telegram-daemon-generation-guard.test.ts and topic registry: 135 pass
  • replay + provider onboarding + ACP notice: 33 pass
  • session-storage cohort: 179 pass, 20 skipped
  • autorouting/model-selector cohort: 105 pass
  • ACP notice repeated in three independent Bun processes: 2 pass each.

Run 31869555814 is terminal and stale relative to this head. Classification retained: shard-1 browser default-root is inherited current-dev #4574 / PR #4575; shard-5 is GitHub FinalizeArtifact ECONNRESET; bootstrap is expected for this Draft; evidence-producer and aggregate failures are downstream of the repaired shard/guard failures.


[repo owner’s gaebal-gajae (clawdbot) 🦞]

@Yeachan-Heo

Copy link
Copy Markdown
Owner Author

Additional local fresh-process evidence: bun scripts/run-bun-test-files.ts --root=packages/coding-agent --shard=2/8 --timeout=30000 --file-timeout=120000 --concurrency=3 reran 177 files after rebase. The assigned OpenAI replay regression passed. The harness still reported autorouting-boundary-redteam.test.ts, task-autorouting-preflight.test.ts, and a timeout after successful exit for sdk-adapter-dispositions-daemon-cli.test.ts; these were not terminal blockers identified in run 31869555814 and were left unchanged to avoid broadening this owner-controlled CI repair.


[repo owner’s gaebal-gajae (clawdbot) 🦞]

@Yeachan-Heo

Copy link
Copy Markdown
Owner Author

A queued affected-path regression exposed an additional PR-scope staging bug before its job terminalized. Fixed and pushed 4ead72d19399cc34d0999910dcb2373fd4752918 to feat/autorouting; live PR API and remote ref agree on that exact Draft head, still based on dev 1cc986422ae335bc155740b1060f6be10cfee4b4.

SessionManager.openStaged() no longer publishes a terminal --continue breadcrumb for an unpublished candidate. The breadcrumb is deferred until staged commit finalization, restoring the no-discovery-residue boundary. The durable C2 boundary test now has its required 30s window so it cannot leak timed-out async work into C3.

Validation: autorouting-boundary-redteam.test.ts 40 pass; task-autorouting-preflight.test.ts 21 pass; bun --cwd=packages/coding-agent run check pass. The prior replacement run 31871546786 is stale for this new head; its completed Telegram guard, Windows Telegram safety, and Windows session-path jobs were green. Bootstrap remains the expected Draft gate.


[repo owner’s gaebal-gajae (clawdbot) 🦞]

@Yeachan-Heo

Copy link
Copy Markdown
Owner Author

Terminal Dev CI classification for exact Draft head 4ead72d19399cc34d0999910dcb2373fd4752918 on dev 1cc986422ae335bc155740b1060f6be10cfee4b4: run 31872052977 completed with 74/74 jobs terminal.

Green repaired surfaces include Telegram generation guard (94983909330), Windows Telegram safety (94983909359), Windows session-path regression (94983909355), and all affected autorouting/session/model/ACP targeted jobs.

Failures are classified as:

Explicit owner-controlled Draft dependency hold: #4575 (9af837e5e017bcd2f5a2a802574853fab3c10a09) remains open and unmerged. Rebase #4543 only after it lands and dev advances green; then replacement CI must terminalize on that exact new base. PR remains Draft; no Ready or merge action taken.


[repo owner’s gaebal-gajae (clawdbot) 🦞]

@Yeachan-Heo

Copy link
Copy Markdown
Owner Author

Rebased the owner-controlled Draft onto exact dev 2e3ccb5895568ffec709b3adba25bc919d6d248b (#4577) and force-with-lease pushed exact head c9b6e0ef5cf007d866858e5ad06a5f460504a8fe to feat/autorouting. Live PR API and remote ref agree; Draft state remains unchanged. Replacement Dev CI is 31874899362.

#4577 overlap review: Command Code GOAT is retained as its own bundled model profile/provider recommendation and preset. Autorouting remains policy-tier derived and does not restore the removed preset layer; no duplicate profile removal or selector collision was introduced.

Focused validation: routing/model/ACP cohort 117 pass; replay/staging/Telegram cohort 162 pass; Command Code GOAT profile catalog 16 pass; provider onboarding 28 pass; coding-agent check and generation authority/current-tree validation pass.

model-registry.test.ts independently exposes five pre-existing shared-provider/environment cache assertions unrelated to the new GOAT profile mappings; replacement CI is the authority for final classification. Browser dependency hold on #4575 remains in force; no browser code was changed.


[repo owner’s gaebal-gajae (clawdbot) 🦞]

@Yeachan-Heo

Copy link
Copy Markdown
Owner Author

Terminal replacement CI classification: run 31874899362 completed 74/74 jobs for exact Draft head c9b6e0ef5cf007d866858e5ad06a5f460504a8fe on dev 2e3ccb5895568ffec709b3adba25bc919d6d248b.

Only product failure is shard-1 94989620493: 176/177 files green; browser-chrome-profile.test.ts default-root refusal is the byte-identical inherited #4574 regression. No autorouting, model-profile, ACP, replay, staging, or Telegram failure is present.

94989061182 bootstrap is the expected Draft gate. Evidence producer 94991903454 and aggregate 94991926255 are downstream only. #4575 remains open pending final merge; this owner-controlled Draft is explicitly held on that dependency. No Ready or merge action taken.


[repo owner’s gaebal-gajae (clawdbot) 🦞]

@Yeachan-Heo

Copy link
Copy Markdown
Owner Author

Freshness reset completed after #4575 merged. PR #4543 is rebased onto current dev 45885ea28793b0ace3523272b41f7ad07b1e88e5; exact Draft head is 15f657cd0f8d9fa09388814f121664bf1c93577e, verified by live API and origin/feat/autorouting. Canonical binary diff SHA-256: 33bccfab5c612225a4c734f3ac8afc4b4a10e8a35e7d240b7719c355e3562408.

Semantic overlap review retained #4575 Chrome default-root repair and later detached-managed snapshot work from dev; #4543 preserves policy-derived autorouting tiers and does not restore the removed preset layer. Protected Telegram lifecycle changes were regenerated atomically at generation 170.

Current evidence: routing/model/ACP/staging cohort 83 pass; replay/Telegram/browser cohort 190 pass; coding-agent check, binary build, guard authority/current-tree validation, and affected planner passed. Replacement Dev CI 31880204542 is running.

Honest Draft needs-human verdict: code and local verification are current, but readiness remains owner-controlled and CI must terminalize before any completion assessment. The obsolete #4575 dependency hold is removed; the live Ultragoal G001 ledger records this current-dev hold. Draft remains Draft: no Ready, approval request, merge, close, release, or tag action.


[repo owner’s gaebal-gajae (clawdbot) 🦞]

@Yeachan-Heo

Copy link
Copy Markdown
Owner Author

Current exact-head terminal classification for owner-controlled Draft #4543:

  • Base/head: 804314081fe9d3f4d34014d1385f09d8d49a7116 / 4dadf96f1fa6174168b68d8140452d5043f266bb
  • Canonical binary full-index digest: a7b7de3ff1b5e9103954c521381b15d778ae1cc52ba90ced5e6c0b4651b42b68
  • Dev CI: 31885466467 is terminal. Its 72 product/platform jobs succeeded and one platform job was skipped. The sole failure is PR contract bootstrap, expected because the current exact-head verdict is intentionally needs-human; it is not a product failure.
  • Local exact CI-scrubbed root-check replay passed. The final worktree is clean, git diff --check is clean, and the PR verdict preflight validated the current digest.

This remains a Draft, owner-controlled readiness hold. No review, ready transition, merge, close, release, or tag action was taken.


[repo owner's gaebal-gajae (clawdbot) 🦞]

Yeachan-Heo and others added 7 commits August 15, 2026 13:53
Adds a fixed fast/balanced/strong tier vocabulary for Task-tool spawns,
gated behind `task.autorouting.enabled` (default false). Tiers come from
`task.autorouting.tiers` or one of the locked presets (anthropic,
openai-codex, google, xai); explicit tiers win over a preset and an
omitted item tier routes as balanced. An autorouting pin overrides the
manual model chain, unmatched tiers fall back to manual resolution per
item with a bounded reason, and routing evidence propagates to the task
result, receipt, renderer, and task-summary prompt.

Selectors must be exact provider-qualified `provider/modelId` strings
with an optional thinking suffix; globs, bare ids, and `pi/<role>`
aliases are rejected by the generated config schema. With autorouting
disabled the model-resolution path is unchanged.
Turn sub-agent autorouting from a hand-authored tier map into a
declare-your-providers flow: pick the providers you have, in priority
order, and gjc materializes deterministic fast/balanced/strong
cross-provider fallback chains for you.

Curation and generation:
- Add a curated per-model tier-label map in packages/coding-agent,
  seeded 1:1 from the shipped presets, with a skip list and a version
  fingerprint. Only current models carry labels, so "newest only" is a
  curation discipline rather than recency-filter code.
- Add a pure, clock-free generator over the full model catalog. Given a
  declaration it emits byte-identical chains: declaration order, then
  curation rank, then a stable tie-break, deduped. Credentials and
  disabled providers are routing-time facts and never generation
  inputs, so adding an API key cannot silently change routing.
- A provider that lacks a label for a tier contributes nothing to it.
  Unfillable tiers stay absent and fall through to the existing manual
  fallback rather than being padded with a model that was never
  labeled for that tier.
- Add a CI forcing gate, wired into both required root checks, that
  fails when a new current catalog model is neither labeled nor
  skip-listed.

Settings and TUI:
- Add typed task.autorouting.setup and .provenance behind a narrow
  optional-object setting kind, wired through the schema, validation,
  reconciliation and JSON-schema generation. Both default to absent, so
  untouched configs round-trip byte-identically and the disabled path
  is unchanged.
- Add a smart-routing panel reachable from the /model presets landing.
  It edits provider order and an optional model allowlist, previews the
  generated chains, and commits tiers + setup + provenance in one
  atomic batch, so what you previewed is exactly what is written.
  Refresh regenerates from the recorded declaration, Clear removes the
  generated keys while preserving preset and enabled, and the toggle
  writes only enabled. Hand-edited tiers are detected by fingerprint
  and never overwritten without explicit confirmation.

Runtime:
- Add an autorouting preflight mode for initial routed tasks: a bounded
  ledger of at most three unique candidates spanning throwaway probes
  and the durable attempt. Only typed transient pre-start failures
  advance; anything unclassified is terminal, and nothing switches once
  the request fence is crossed, so there is still no mid-run failover.
- Publish failed attempts nowhere. Staged sessions suppress breadcrumbs
  and session-list registration until a single commit point, staged
  paths are excluded from every discovery reader, and artifacts are
  attempt-scoped with a serialized reservation and a frozen id map that
  is applied before the transcript becomes visible.
- Record why routing did what it did: bounded skip evidence that
  distinguishes disabled providers from missing snapshot entries and
  missing credentials, a phase-tagged attempt ledger, and terminal
  outcomes that survive even when no candidate ever executes.

The declaration is the only priority channel; the optional model list
filters eligibility and never reorders. Manual tiers and presets remain
as the power-user escape hatch.
The current artifact manager reserves numeric IDs with hidden claim files, and the landed catalog includes selector-invalid model IDs. Preserve claim authority during staged publication, exclude unrouteable catalog keys, and align managed identity and residue assertions with the current storage contract.

Tested: 130 autorouting tests across 11 files; coding-agent biome and type checks; schema sync; CHANGELOG history guard.
Preserve dev session authority while staging autorouting attempts, gate transient breadcrumbs, and refresh tier-map baseline coverage for newly declared providers.

Lore-id: pr-3764-repair
Tested: autorouting preflight and boundary red-team contracts; coding-agent typecheck and schema/tier-map gates
Confidence: high
Scope-risk: targeted
Reversibility: revertable
The smart-routing panel was reachable only from the /model preset
landing. A session with zero model profiles skips that landing on open
and has no way back to it, so autorouting setup was unreachable for
exactly the users who had not configured presets yet.

/routing mounts the panel directly (cancel closes the selector instead
of falling back to the landing), and /routing on|off|status manages
task.autorouting.enabled without a TUI round trip.

Also canonicalizes the gen8 red-team temp roots so the managed-store
boundary tests stop failing on macOS symlinked tmpdirs.
The task tool description reads settings.getEffectiveAutorouting(), which
the tool-catalog generator's hand-rolled settings stub does not implement,
so `bun run prepack` died with TOOL_CATALOG_GENERATION_FAILED and the
generated catalog never picked up the new `tier` parameter. The stub now
reports the default (autorouting off) and the catalog is regenerated.

docs/tools/task.md gains the `tier` field and an Autorouting section.

Also binds the models-schema selector assertion to
ProfileModelSelectorPattern instead of a hardcoded copy. The provider-
agnostic preset work changed the pattern without updating the test; it
only surfaces on branches whose affected paths schedule that test.
Two review findings on /routing:

The selector grammar rejects whitespace but not ESC/BEL, so a hand-edited
task.autorouting.tiers entry could smuggle terminal control sequences into
the status text rendered in the chat container. Status lines now run through
validateDisplayLine + replaceTabs and are width-bounded, matching the
renderer sanitization contract.

/routing on|off wrote task.autorouting.enabled directly, bypassing the
scoped-session and durable-config guards the smart-routing panel enforces.
The TUI path now delegates to SelectorController.setAutoroutingEnabled.
Yeachan-Heo and others added 20 commits August 15, 2026 13:53
session-runtime only threads the internal boolean; the host owns the emission,
so importing the constant here was dead and failed check:tools.

Lore-id: e6b104f7
Confidence: high
Scope-risk: narrow
Reversibility: clean
Tested: biome check across 3653 files exits 0; check:types clean
The bootstrap cleared record.routingInactiveNotice before awaiting the publish,
which broke two things the auth-failure precedent gets right: a later
loadSession or resumeSession legitimately re-announces the condition and would
now stay silent, and a rejected publish lost the warning outright because the
enclosing bootstrap task swallows failures. Read without consuming, exactly like
authFailure; one emission per bootstrap already follows from bootstrap running
once per attach.

Also covers the accessor contract directly rather than only its pure projection:
catalog spelling is preserved for the case-sensitive generator, catalog-absent
declarations are dropped, configured priority leads, and duplicate spellings
collapse to the first occurrence.

Lore-id: 7b90e2ac
Constraint: a diagnostic must survive a failed publish and re-announce on resume
Confidence: high
Scope-risk: narrow
Reversibility: clean
Tested: acp-autorouting-notice and acp-lazy-startup 3 pass; autorouting-provider-order 12 pass; check:types clean
sdk/index.ts re-exports the host namespace and ./sdk is a published entry, so
adding autoroutingInactive to SessionSdkHostOptions let any consumer inject the
internal diagnostic through a public API. The approved plan forbids growing the
public surface for this warning.

The state now travels through a package-private module keyed by the object the
session factory already owns, and that module is explicitly mapped to null in
the package exports so it cannot be imported from outside. The field and its
layer-by-layer threading are gone from the host, runtime, and bus option types;
behaviour is unchanged.

Lore-id: c082da4b
Constraint: an internal diagnostic must not be settable through a published type
Confidence: high
Scope-risk: narrow
Reversibility: clean
Tested: 44 pass across acp-autorouting-notice, acp-lazy-startup, acp-event-mapper and sdk-acp-production-path; AC10b still fails when the host emission is disabled, proving behaviour survived the seam change; check:types clean
The flag was publicly settable once; nothing stopped it regressing. Asserts the
two null export-map entries that block the internal module, that the host barrel
does not re-export it, and that no published option type declares the field.

Lore-id: 1d4f6b70
Confidence: high
Scope-risk: narrow
Reversibility: clean
Tested: 4 pass; removing the export-map null entry fails the guard
AC13/D7 asked for a golden that actually runs the provider-order derivation. The
four existing fixtures hand the generator an already-sorted setup, so they only
ever proved that declaration order dominates tier order; none of them touch the
projection. This one starts from configured order plus catalog, runs the real
projection, and pins the resulting bytes.

It also pins the two behaviours that motivated the accessor: a configured
provider missing from the catalog is dropped before it can reach setup.providers
and pollute declarationFingerprint, and catalog order supplies the remainder.

Lore-id: 5ec1f0d3
Confidence: high
Scope-risk: narrow
Reversibility: clean
Tested: autorouting-generator 8 pass; removing the catalog-append branch from projectProviderOrder fails this fixture
Three gaps, all real. The selector check claimed to validate "every generated
tier selector" but tested three hardcoded strings and never touched
CURATED_TIER_MAP or the generator, so deleting the preset exhaustive loop
silently lost that coverage. It now walks every curated key and every selector
the generator actually emits from that catalog, with a negative control for
unfit selectors and an explicit note that a colon is legal inside a model id.

The accessor tests reimplemented the accessor body, so they could not catch a
regression inside it. The spelling-restore logic moved into
projectCatalogProviderOrder, which autoroutingProviderOrder now simply calls, and
the tests exercise that function directly. Real-instance tests remain for the
properties observable without global settings: no parameters, catalog-only
output, first-wins order, credential invariance, determinism.

Also proved the model-registry baseline claim instead of inheriting it: the same
four failures appear at HEAD and at pristine dev 178fc26, so they are
pre-existing and unrelated to autorouting.

Lore-id: 4f8ba7c1
Constraint: a test must fail when the behaviour it names is removed
Confidence: high
Scope-risk: narrow
Reversibility: clean
Tested: 57 pass across autorouting-provider-order, task-autorouting-redteam, autorouting-generator and smart-routing integration; removing the spelling restore fails 4 of them; model-registry failures diffed identical against pristine dev
…settings

The cleaner lane caught me repeating the exact mistake the terminal critic had
just corrected: the policy-derived golden rebuilt the catalog, spelling map, and
projection inline instead of calling projectCatalogProviderOrder, so it could not
fail if that function broke. It now calls the shipped function, which is what
ModelRegistry.autoroutingProviderOrder delegates to.

The real-registry suite also only assumed the global settings singleton was
uninitialized. A prior test setting modelProviderOrder would have silently
reordered the expected catalog projection and made those assertions accidental,
so the precondition is now reset around each test and asserted outright.

Lore-id: 6a4c0e93
Constraint: a golden must exercise shipped code, never a copy of it
Confidence: high
Scope-risk: narrow
Reversibility: clean
Tested: autorouting-generator 8 pass, autorouting-provider-order 19 pass; removing the spelling restore now fails 5 across both files where it previously failed 4, proving the golden is bound to the real function
…t rebase

Rebasing onto the current dev tip pulled in 44 new catalog keys the autorouting
tier map has never seen, so check:autorouting-map failed closed on uncurated
coverage. Record them as baseline skips with an explicit rationale rather than
inventing tier/rank data nobody reviewed.

Lore-id: 9d1f6b3a
Constraint: an uncurated catalog key is a skip with a rationale, never a guessed tier
Confidence: high
Scope-risk: narrow
Reversibility: clean
Tested: check-autorouting-tier-map gate passed (4264 in-scope keys); autorouting suites 98 pass
…lution

Removing the #writeTerminalBreadcrumb wrapper during the dev rebase left a double
blank line that check:tools rejects. Kept as its own commit rather than folded
into the regenerable telegram digest commit, which a later rebase skips and would
have discarded this fix with it.

Lore-id: 4e7a2b81
Confidence: high
Scope-risk: narrow
Reversibility: clean
Tested: biome check across 3714 files exits 0
Managed session opens must sanitize stale OpenAI Responses metadata in memory without appending durable patches. The autorouting selector must also tolerate minimal settings adapters while retaining its provider-order listener when available.\n\nLore-id: 4543-ci-fixforward-0647\nConstraint: preserve replay safety without rewriting managed transcripts on open\nTested: focused replay, onboarding, session-storage, model-selector, and daemon guard suites\nConfidence: high\nScope-risk: narrow\nReversibility: simple
The autorouting ACP fixture closed only its connection signal, leaving its session adapter alive while broker-root cleanup removed the fixture. Register and await the owned ACP session teardown before releasing the broker lease.\n\nLore-id: 4543-ci-fixforward-0647\nConstraint: fixture roots must remain absent after teardown\nTested: repeated fresh Bun ACP notice regression\nConfidence: high\nScope-risk: narrow\nReversibility: simple
Unpublished autorouting candidates must not replace the terminal continuation breadcrumb. Publish it only when a staged candidate is finalized; give the durable staged regression its required bounded test window.\n\nLore-id: 4543-ci-fixforward-0647\nConstraint: failed candidates leave no durable discovery residue\nTested: autorouting boundary and preflight regressions; coding-agent check\nConfidence: high\nScope-risk: narrow\nReversibility: simple
Current dev now includes the prior generation boundary, while autorouting still changes protected notification lifecycle code. Regenerate the complete guard-owned authority set atomically.\n\nLore-id: 4543-ci-fixforward-0647\nTested: telegram guard, topic registry, and focused routing/session suites\nConfidence: high\nScope-risk: narrow\nReversibility: simple
SDK patches and config CLI writes could bypass nested autorouting validation, while task creation prefiltered credential failures as recoverable absences.\n\nValidate typed autorouting objects at every mutation ingress and leave credential classification to executor preflight so unexpected lookup faults fail closed.\n\nLore-id: pr4543-fixforward\nConstraint: preserve owner-controlled Draft state\nConfidence: high\nScope-risk: focused\nReversibility: revertable\nTested: focused autorouting ingress and preflight suites
Autorouting preflight resolved exact keys against the execution session instead of the distinct credential session.\n\nUse the propagated credential session identity so managed credentials remain available to pinned candidates.\n\nLore-id: pr4543-credential-scope\nConstraint: preserve fail-closed autorouting preflight\nConfidence: high\nScope-risk: focused\nReversibility: revertable\nTested: task-autorouting-preflight
Reject malformed autorouting tier maps before SDK config.patch persists them.\n\nTested: autorouting-settings-contract
Keep truthful missing-credential skips while propagating unexpected lookup errors and using the credential session scope.\n\nTested: autorouting boundary and preflight suites
Defer unexpected TaskTool credential probe failures to executor preflight so routing receipts remain fail-closed and auditable.\n\nTested: autorouting preflight, integration, boundary suites
Root TypeScript validation requires the optional credential session argument to exclude null.\n\nTested: ci-dev-affected root-check
Carry TaskTool credential lookup exceptions into the authoritative preflight ledger instead of retrying and losing one-shot failures.\n\nTested: routing preflight, integration, and boundary suites
Yeachan Heo added 2 commits August 15, 2026 14:07
Ensure TaskTool transfers an observed credential lookup fault into executor preflight without retrying it.\n\nTested: routing preflight, integration, boundary suites
Use Map presence rather than value truthiness so every captured JavaScript throw reaches terminal preflight evidence.\n\nTested: routing preflight, integration, boundary suites
@Yeachan-Heo

Copy link
Copy Markdown
Owner Author

Current-head CI failure classification for Draft #4543 (e7b95a4ce957c00d36d532eae62a959ee9295c1b, base cd51365cc270e27dceccfc2c184fadc9c1ddbe18):

  • Canonical affected-plan artifact dev-affected-plan-31889283833 confirms the exact shard command: bun scripts/run-bun-test-files.ts --root=packages/coding-agent --shard=N/8 --timeout=30000 --file-timeout=300000 --concurrency=1.
  • Shard 4 is a success control. Failed shard logs show ReferenceError: Cannot access 'END_PATCH_MARKER' before initialization in packages/coding-agent/src/edit/streaming.ts:85 in shards 1, 2, 3, 6, 7, and 8. The same focused test fails locally at the PR head (bun test packages/coding-agent/test/core/apply-patch.test.ts), and the PR delta does not touch streaming.ts; this is inherited shared module-initialization failure, not an autorouting repair target.
  • Additional inherited shared scraper TDZ traces are present: handleDockerHub in shard 2 and handleYouTube in shard 5, both in packages/coding-agent/src/web/scrapers/index.ts. These files are likewise outside the PR delta.
  • The dedicated shared edit repair is PR fix(coordinator): tolerate unsupported Windows directory sync #4459; it is not merged. Current dev is d332b7890ed95ff71d1a80e00bd4d31809558e69, and its Dev CI 31890215548 is terminal failure, so feat(routing)!: autorouting with policy-derived tiers, preset layer removed #4543 will not copy or substitute that repair. The unchanged autorouting delta must be reconstructed only after an authoritative repaired dev is available.

PR #4543 remains an owner-controlled Draft with needs-human; no readiness, review, merge, close, release, or tag action was taken.


[repo owner's gaebal-gajae (clawdbot) 🦞]

@Yeachan-Heo

Copy link
Copy Markdown
Owner Author

Verdict: Request changes

Blocking findings:

  • P1 — packages/coding-agent/src/task/executor.ts, runSubagent() preflight setup and ManagedTaskPersistence.openStagedSession() (~330, ~1740–1780): both paths adopt staged artifact managers, leaving the first attempt root unreachable. Managed autorouting retries can orphan staging roots and leave durable filesystem residue. Centralize manager creation or make generic adoption conditional on !options.managedPersistence; add a lifecycle assertion that exactly one attempt root is used through commit/discard.
  • P2 — packages/coding-agent/scripts/check-autorouting-tier-map.ts, getAutoroutingTierMapGateReport() / checkAutoroutingTierMap(): skip-list rationale, duplicate, malformed, and out-of-scope entries are not validated. Future catalog entries can bypass curation with empty or stale skip entries. Enforce selector grammar, catalog scope, uniqueness, and non-empty rationale.

No tests or gates were run as part of this review.

@Yeachan-Heo

Copy link
Copy Markdown
Owner Author

Correction / superseding verdict

The earlier review comment on this PR was based on an incorrect diff scope and is superseded.

A subsequent exact-head review of e7b95a4ce957c00d36d532eae62a9599d3f4d34014d1385f09d8d49a7116 found only the Map.has preflight-fault classification change in packages/coding-agent/src/task/executor.ts plus regression coverage. The change correctly preserves thrown undefined values from the caller's error-transfer path instead of treating them as absent credentials and retrying the candidate. Existing absent-key and non-undefined behavior remains unchanged.

Corrected verdict: Approve / no actionable findings.

No tests or gates were run as part of the read-only review.

@Yeachan-Heo

Copy link
Copy Markdown
Owner Author

Final correction / superseding verdict

The previous approval correction was also based on an incomplete/local diff inspection and is superseded. The live PR has 44 commits and 71 changed files at the exact head.

Corrected verdict: Request changes.

  • P1 — packages/coding-agent/src/config/autorouting-generator.ts:164–166: setup provider IDs are accepted with arbitrary casing and provider ordering is case-insensitive, but tier generation matches provider prefixes and catalog keys case-sensitively. A valid setup such as providers: ["OpenAI"] against openai/... catalog keys produces empty fast/balanced/strong tiers.
    • Impact: autorouting can be enabled while silently falling back to manual model resolution for every Task item.
    • Fix: normalize provider IDs consistently at setup/generator/catalog boundaries, or reject non-canonical casing; add a mixed-case regression test covering generated tiers and fingerprints.

No tests or gates were run as part of this read-only review.

@Yeachan-Heo

Copy link
Copy Markdown
Owner Author

Additional exact-head finding

  • P2 — packages/coding-agent/src/task/autorouting-contract.ts:48–53: AUTOROUTING_SELECTOR_PATTERN / isValidAutoroutingSelector accept arbitrarily long model IDs, while assertRoutingEvidenceInvariant rejects a non-terminal effectiveModel longer than 256 characters.
    • Impact: a routed custom/provider model ID longer than 256 characters can execute successfully and then fail during routing-evidence finalization, turning a successful task into an error.
    • Fix: enforce the same maximum length in selector grammar/validation, or revise the invariant so accepted selectors cannot be rejected after execution.

This supplements the existing P1 provider-ID case-normalization finding. Overall verdict remains Request changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant