@staix/agent-hub 0.35.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +21 -4
- package/docs/agent-notes/README.md +60 -0
- package/docs/agent-notes/adapters.md +5 -2
- package/docs/agent-notes/bus.md +1 -0
- package/docs/agent-notes/daemon.md +5 -4
- package/docs/agent-notes/models.md +4 -3
- package/docs/agent-notes/tasks.md +8 -1
- package/docs/agent-notes/tests.md +1 -0
- package/docs/design/adapters.md +72 -0
- package/docs/design/agent-hub-architecture.md +1 -1
- package/docs/design/bus.md +8 -0
- package/docs/design/execution-reference.md +171 -11
- package/docs/design/guidance-experiments.md +438 -0
- package/docs/design/model-routes.md +628 -0
- package/docs/design/supervision.md +121 -0
- package/docs/design/task-board.md +111 -0
- package/docs/dogfood.md +15 -4
- package/docs/operations.md +291 -22
- package/docs/profiles.md +2 -2
- package/docs/quickstart.md +106 -1
- package/docs/research.md +4 -2
- package/docs/sdlc.md +108 -4
- package/docs/security.md +67 -5
- package/docs/specs/2026-09-19-agent-hub-design.md +5 -4
- package/docs/verification/2026-10-25-qwen-dual-output-t0.md +22 -0
- package/docs/verification/2026-11-09-qwen-0270-acp.md +181 -0
- package/docs/verification/2026-11-09-qwen-0270-model-setter-1317.md +46 -0
- package/docs/verification/2026-11-10-0.36.0.md +59 -0
- package/docs/verification/2026-11-10-claude-implementer-2.1.322.md +59 -0
- package/docs/verification/2026-11-10-qwen-0270-dual-output.md +367 -0
- package/docs/verification/2026-11-10-qwen-0271-dual-output.md +101 -0
- package/docs/verification/claude-shell-wrapper-native.py +1 -1
- package/docs/verified.json +27 -27
- package/package.json +1 -1
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/kimi-hook.js +1201 -368
- package/plugins/agent-hub/server.js +1682 -431
- package/src/adapters/claude-channel.ts +7 -4
- package/src/adapters/compat.ts +10 -10
- package/src/adapters/local-worker.ts +1 -1
- package/src/adapters/qwen-dual.ts +324 -44
- package/src/cli/guidance.ts +67 -0
- package/src/cli/help.ts +10 -3
- package/src/cli/identity.ts +10 -3
- package/src/cli/init-prompt.ts +15 -2
- package/src/cli/init-required-checks.ts +122 -0
- package/src/cli/init-settings.ts +10 -4
- package/src/cli/init.ts +39 -3
- package/src/cli/lineage.ts +78 -0
- package/src/cli/main.ts +111 -10
- package/src/cli/setup-research.ts +10 -0
- package/src/hub/autonomy-defaults.ts +20 -9
- package/src/hub/board.ts +346 -4
- package/src/hub/build-entry.ts +11 -0
- package/src/hub/bus.ts +12 -0
- package/src/hub/ci-watch.ts +4 -4
- package/src/hub/config-apply.ts +2 -1
- package/src/hub/config-trust.ts +1 -0
- package/src/hub/control-client.ts +1 -1
- package/src/hub/daemon.ts +342 -20
- package/src/hub/delivery-hints.ts +4 -2
- package/src/hub/delivery-journal.ts +50 -2
- package/src/hub/delivery-public.ts +51 -0
- package/src/hub/dogfood-profile.ts +8 -4
- package/src/hub/execution-lineage-owner.ts +272 -0
- package/src/hub/execution-lineage.ts +52 -8
- package/src/hub/execution-links.ts +85 -0
- package/src/hub/guidance-variants.ts +398 -0
- package/src/hub/handoff.ts +1 -0
- package/src/hub/hub-tools.ts +43 -2
- package/src/hub/manager.ts +44 -2
- package/src/hub/memory-policy.ts +2 -2
- package/src/hub/peers.ts +1 -1
- package/src/hub/planning.ts +1 -1
- package/src/hub/progress.ts +24 -7
- package/src/hub/restart.ts +13 -0
- package/src/hub/roles.ts +26 -0
- package/src/hub/routing.ts +4 -1
- package/src/hub/sdlc-merge.ts +39 -1
- package/src/hub/sdlc-release.ts +1 -1
- package/src/hub/sdlc.ts +62 -11
- package/src/hub/settings.ts +2 -0
- package/src/hub/supervision-proposals.ts +405 -0
- package/src/hub/supervision-rules.ts +388 -0
- package/src/hub/supervision.ts +2 -0
- package/src/hub/task-approval.ts +2 -2
- package/src/hub/task-repository.ts +5 -0
- package/src/hub/tasks.ts +603 -50
- package/src/memory/capture.ts +2 -2
- package/src/models/relay.ts +9 -2
- package/src/models/route/config.ts +27 -0
- package/src/models/route/decision.ts +87 -15
- package/src/models/route/relay-selector.ts +8 -7
- package/src/models/route/runtime.ts +22 -16
- package/src/models/route/stage-diagnostics.ts +22 -0
- package/src/models/route/stage-evidence.ts +55 -0
- package/src/models/route/stage-fallback.ts +58 -0
- package/src/models/route/stage-input.ts +155 -0
- package/src/models/route/stage.ts +5 -147
- package/src/ui/guidance-panel.ts +156 -0
- package/src/ui/guidance-view.ts +43 -0
- package/src/ui/lineage-view.ts +34 -0
- package/src/ui/plugin.ts +71 -7
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: model-routes
|
|
3
|
+
type: module
|
|
4
|
+
title: Hub Model Routes
|
|
5
|
+
status: draft
|
|
6
|
+
parent: agent-hub-architecture
|
|
7
|
+
paths:
|
|
8
|
+
- src/models/route/**
|
|
9
|
+
- src/models/relay.ts
|
|
10
|
+
- src/hub/progress.ts
|
|
11
|
+
- test/model-stage-input.test.ts
|
|
12
|
+
- test/model-stage-diagnostics.test.ts
|
|
13
|
+
- test/model-stage-evidence.test.ts
|
|
14
|
+
- test/model-stage-fallback.test.ts
|
|
15
|
+
- test/fixtures/model-stage-sizing-v1.json
|
|
16
|
+
- test/progress.test.ts
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# Hub Model Routes
|
|
20
|
+
|
|
21
|
+
This document defines agent-hub's replacement route design for issue #1352. Its
|
|
22
|
+
inputs are the project's configuration, operational contracts and nonported
|
|
23
|
+
consumers. It is a newly authored rewrite. R1 covers
|
|
24
|
+
stage evidence and deterministic fallback; R2 owns the remaining route decisions
|
|
25
|
+
and judge/prompt replacement; R3 owns notice and remnant cleanup.
|
|
26
|
+
|
|
27
|
+
**Review basis:** the recorded R1 contract review for issue #1352 accepted the
|
|
28
|
+
ownership split, packet bounds and numerical contract. The sizing
|
|
29
|
+
characterization and conservative arithmetic were approved, and the task path
|
|
30
|
+
plan was expanded before new unit/consumer/test edits. Source, test and spec
|
|
31
|
+
review preceded commits and remote checks. The four fresh units and approved
|
|
32
|
+
consumer wiring implement this contract; validation conclusions remain bound
|
|
33
|
+
to their exact-head receipts. Accepted design choices are not measurements of
|
|
34
|
+
implementation equivalence or runtime behavior.
|
|
35
|
+
|
|
36
|
+
## Decision ownership
|
|
37
|
+
|
|
38
|
+
| Question | Owner | R1 status |
|
|
39
|
+
| --- | --- | --- |
|
|
40
|
+
| Which eligible model and reasoning effort should serve a stage or plan/execute request? | adec's configured policy, candidate constraints, pins and decider | Existing optional consumer for `decision`; S2 asks the stage question only inside the ambiguity band (below); plan/execute choice stays future |
|
|
41
|
+
| Which model/effort should serve an optional judge choice? | adec where separately configured, with an in-house fallback | R2 question design and wiring; no R1 judge request |
|
|
42
|
+
| Whether to escalate, request an advisor review, or issue redo feedback | Hub route policy | Preserve the caller boundary; implementation replacement belongs to R2 |
|
|
43
|
+
| Whether a task is PII and which peer receives it | PII screen and pure `assign()` | Outside model-choice routing; no adec delegation |
|
|
44
|
+
| Which deterministic tier remains when no applicable service choice is applied? | Hub fallback | R1 pure, model-free implementation |
|
|
45
|
+
| Whether a turn may execute, use a tool, cross a privacy boundary or spend budget | Current host admission | A route score or service proposal grants no authority |
|
|
46
|
+
|
|
47
|
+
The active `decision` configuration supports `decision_backend = "adec"` and
|
|
48
|
+
`decision_mode = "off" | "shadow"`, default off. `enforce` remains a load-time
|
|
49
|
+
refusal naming the #554 follow-up. Shadow preserves the exact fallback model,
|
|
50
|
+
effort and forwarded conversation. This is separate from `stay_switch`, whose
|
|
51
|
+
existing off/shadow/enforce behavior remains supported. R1 adds no service-call
|
|
52
|
+
path, classifier option, gateway effort application, service launch or credential
|
|
53
|
+
reader. #554 S2 adds the opt-in stage classifier option and its ambiguity band
|
|
54
|
+
below; judge/plan-execute choice questions require later reviewed wiring (R2).
|
|
55
|
+
|
|
56
|
+
## Route contracts and compatibility
|
|
57
|
+
|
|
58
|
+
- `stage` produces stage evidence, a deterministic efficient/capable fallback and
|
|
59
|
+
the existing session-aware switch plan. With `classifier = "decision"` it may
|
|
60
|
+
also ask adec, and only when its own score sits in the ambiguity band; the
|
|
61
|
+
answer is recorded and never replaces the fallback tier.
|
|
62
|
+
- `decision` currently uses the same fallback while optionally recording an adec
|
|
63
|
+
proposal through the existing #813 consumer. A failed request, abstention,
|
|
64
|
+
`no_candidate`, invalid pair or unavailable service leaves that fallback.
|
|
65
|
+
- `plan_execute` retains its documented capable planning and efficient execution
|
|
66
|
+
boundary after the first mutation. Its replacement and optional adec question
|
|
67
|
+
belong to R2.
|
|
68
|
+
- `advisor` retains bounded APPROVE/REDO review of eligible no-tool answers;
|
|
69
|
+
`escalation` retains efficient start and same-category confirmation before a
|
|
70
|
+
capable latch. Their triggers, parsing, prompts and judge backoff belong to R2.
|
|
71
|
+
- Explicit model overrides and class fixed-model selections bypass routes as
|
|
72
|
+
before. A missing/retired route keeps the configured fixed-model fallback and
|
|
73
|
+
existing diagnostics. Loading configuration never rewrites operator files.
|
|
74
|
+
|
|
75
|
+
Keep the current configuration keys: route `type`, `efficient`, `capable`,
|
|
76
|
+
`judge`, `confidence_threshold`, `hold_turns`, advisor/escalation settings, the
|
|
77
|
+
existing adec endpoint/policy/candidate/timeout keys and the S2 stage
|
|
78
|
+
`classifier` / `ambiguous_band`. Default stage configuration
|
|
79
|
+
remains efficient `fast`, capable `coding`, confidence threshold 0.5 and hold 2.
|
|
80
|
+
Candidate aliases/efforts remain constrained by the existing route parser and
|
|
81
|
+
response allowlist; R1 does not create a new policy alias. Doctor and
|
|
82
|
+
`ahub route explain` keep their existing fields and pure peer-assignment meaning.
|
|
83
|
+
|
|
84
|
+
Existing owned relay, local-worker, decision-route and doctor integration
|
|
85
|
+
expectations remain acceptance evidence. A discovered observable difference is
|
|
86
|
+
reported for an explicit spec/CHANGELOG decision before implementation proceeds;
|
|
87
|
+
a new scoring formula alone is not proof of compatible tier decisions. Old
|
|
88
|
+
source-port vectors are not an implementation or test oracle for this rewrite.
|
|
89
|
+
|
|
90
|
+
## Two separate evidence payloads
|
|
91
|
+
|
|
92
|
+
### Generic decision evidence, unchanged
|
|
93
|
+
|
|
94
|
+
The existing `buildDecisionEvidence(messages, dimensions, publicText)` function
|
|
95
|
+
and its #813 tests remain unchanged. Its version-1 `routing-decision-evidence`
|
|
96
|
+
JSON retains four finite dimensions, bounded screened public user/assistant/tool
|
|
97
|
+
fragments and screened tool identifiers. Its 8 KiB total cap, whole-source
|
|
98
|
+
screen-before-cut rule, 64 KiB source ceiling, per-fragment caps and recent-tool
|
|
99
|
+
limits remain its own contract. It never includes full history, system/developer
|
|
100
|
+
instructions or tool arguments. R1 does not silently replace this payload or add
|
|
101
|
+
new stage fields to it.
|
|
102
|
+
|
|
103
|
+
### Stage evidence, newly authored
|
|
104
|
+
|
|
105
|
+
A separate pure builder produces `StageEvidence` for deterministic fallback and
|
|
106
|
+
future stage-specific adec questions. This packet contains only closed numeric,
|
|
107
|
+
boolean and categorical data. It contains no source fragments, transcript,
|
|
108
|
+
command, tool argument, path, tool name, diagnostic text or service error prose.
|
|
109
|
+
It is not sent through the generic decision route by this delivery.
|
|
110
|
+
|
|
111
|
+
Closed schema:
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
type StageTier = "efficient" | "capable";
|
|
115
|
+
type StageTurn = "user" | "tool_result" | "compaction" | "other";
|
|
116
|
+
type FaultClass = "none" | "reported" | "exception" | "critical";
|
|
117
|
+
interface StageEvidence {
|
|
118
|
+
schemaVersion: 1;
|
|
119
|
+
kind: "stage-route-evidence";
|
|
120
|
+
turn: StageTurn;
|
|
121
|
+
incomplete: boolean;
|
|
122
|
+
signals: {
|
|
123
|
+
results: number;
|
|
124
|
+
failures: number;
|
|
125
|
+
repeatedFailures: number;
|
|
126
|
+
reads: number;
|
|
127
|
+
mutations: number;
|
|
128
|
+
assistantTurns: number;
|
|
129
|
+
tests: "none" | "pass" | "fail" | "unknown";
|
|
130
|
+
fault: FaultClass;
|
|
131
|
+
};
|
|
132
|
+
dimensions: {
|
|
133
|
+
severity: number;
|
|
134
|
+
spinning: number;
|
|
135
|
+
exploring: number;
|
|
136
|
+
productionIntensity: number;
|
|
137
|
+
};
|
|
138
|
+
scores: { efficient: number; capable: number };
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
All dimensions/scores are finite numbers in [0, 1]. Counts describe only inspected
|
|
143
|
+
input, are nonnegative integers, and never imply a complete-history count.
|
|
144
|
+
The following inspection limits are accepted contract choices from review, not
|
|
145
|
+
implementation measurements or permission for an undocumented behavior change:
|
|
146
|
+
|
|
147
|
+
- Inspect the latest 64 messages and at most 16 completed tool results.
|
|
148
|
+
- Inspect at most 32 tool-call entries in total across that window, by bounded
|
|
149
|
+
array positions. A large `tool_calls` array does not permit a full traversal,
|
|
150
|
+
copy, reverse or sort before the cap is applied.
|
|
151
|
+
- Call/result identifiers are at most 128 UTF-8 bytes and tool-family names at
|
|
152
|
+
most 64 bytes. Match using a table of at most those 32 inspected calls and 16
|
|
153
|
+
results. Missing, duplicate, oversized or unrecognized associations remain
|
|
154
|
+
unassociated; no repeated search through older calls fills the gap.
|
|
155
|
+
- Text inspection has a 64 KiB aggregate UTF-8 budget across the capture and at
|
|
156
|
+
most 32 inspected text-part entries. Oversized/over-budget sources are omitted
|
|
157
|
+
before classification and mark the input incomplete. Neither nested content
|
|
158
|
+
arrays nor tool-call arrays can turn an output cap into unbounded inspection.
|
|
159
|
+
- A stage packet has at most 1024 serialized UTF-8 bytes. Counts reflect inspected
|
|
160
|
+
observations only. Malformed/over-cap input is incomplete or unavailable;
|
|
161
|
+
neither a source fragment nor an arbitrary property enters the packet.
|
|
162
|
+
|
|
163
|
+
The local input view is separate from provider transport. It captures supported
|
|
164
|
+
roles, call/result association, explicit outcome flags and bounded local text for
|
|
165
|
+
classification; it never mutates, trims, summarizes or replaces the forwarded
|
|
166
|
+
conversation. Tool arguments are opaque to the stage packet. Local-only
|
|
167
|
+
compatibility data needed by remaining R2 consumers is not part of this schema.
|
|
168
|
+
Local-only families include recognized reads, mutations, executions and unknown
|
|
169
|
+
actions. Execution recognizes only bounded names `bash` and `exec_command`; it
|
|
170
|
+
never inspects arguments. An associated result may carry its local assistant
|
|
171
|
+
frame index to count distinct assistant turns. Neither that index nor the
|
|
172
|
+
execution family adds a serialized StageEvidence field. The latest non-instruction
|
|
173
|
+
message fixes the current boundary: an assistant-only or invalid tail is `other`,
|
|
174
|
+
not an earlier tool result or user compaction. An invalid tail also marks input
|
|
175
|
+
incomplete; system/developer entries retain their instruction-skip semantics.
|
|
176
|
+
A diagnostic fingerprint may be used transiently to detect repetition; neither
|
|
177
|
+
its source text nor an unbounded fingerprint list is emitted. A later public
|
|
178
|
+
projection uses the closed packet above. A sensitive projection contains only
|
|
179
|
+
`schemaVersion`, `kind` and the four dimensions, with no turn category, counts,
|
|
180
|
+
scores or incomplete-history information; R1 creates no transport for either.
|
|
181
|
+
|
|
182
|
+
Reviewed classification contract:
|
|
183
|
+
|
|
184
|
+
- Count observations within the fixed recent-result window. Unknown tool
|
|
185
|
+
families remain unknown; source words are evidence, not authority.
|
|
186
|
+
- Explicit error outcomes and recognizable diagnostics determine a closed fault
|
|
187
|
+
class. Successful inspection output quoting an error does not by itself become
|
|
188
|
+
a critical failure. Execution results containing `segmentation fault` or
|
|
189
|
+
`out of memory` are critical even when the wire omits `is_error`. These phrases
|
|
190
|
+
do not turn an unflagged successful read into a failure; an explicitly flagged
|
|
191
|
+
read error remains a failure. Passing tests clear the corresponding current test-failure
|
|
192
|
+
evidence, while an unrelated failure is not erased. `signals.tests` is the test
|
|
193
|
+
outcome of the latest inspected completed result; a later ordinary read is
|
|
194
|
+
`none`. Chronological pass processing still clears retained test-category
|
|
195
|
+
failures at that position. A historical pass cannot reset a later compaction
|
|
196
|
+
hold.
|
|
197
|
+
- A repeated failure means at least two matching failed results in separate
|
|
198
|
+
observations. `repeatedFailures` is the largest matching group among retained
|
|
199
|
+
failures, including both observations, not every line of one diagnostic as a new
|
|
200
|
+
attempt. An unrelated success or a different failure does not erase that group;
|
|
201
|
+
a passing test clears only retained test-category failures. Retained groups
|
|
202
|
+
and `signals.fault` describe the inspected window, not a new failure on every
|
|
203
|
+
assessment. Failure-group spinning divides that largest group by the retained
|
|
204
|
+
failure count only while a failure is current at a tool-result boundary. A zero-failure pass summary stays successful unless an
|
|
205
|
+
explicit error outcome or a separate diagnostic establishes failure. Counted
|
|
206
|
+
zero-failure forms such as `0 tests failed` are excluded before fault detection.
|
|
207
|
+
An explicitly empty run (`0 passed, 0 failed`) is unknown test evidence, never
|
|
208
|
+
a passing recovery that clears retained failures. Recovery requires a positive
|
|
209
|
+
pass count, or an entire affirmative line matching `tests passed`,
|
|
210
|
+
`all tests pass` or `all tests passed` (singular `test` is also accepted), with only
|
|
211
|
+
surrounding horizontal whitespace and an optional final `.` or `!`. Substring
|
|
212
|
+
matches, negated statements and additional prose do not establish an
|
|
213
|
+
unqualified pass. This is a closed lexical grammar, not a language inference.
|
|
214
|
+
- Active severity maps the latest completed diagnostic to `0/0.3/0.7/1` at a
|
|
215
|
+
current tool-result boundary; user, compaction and other boundaries have no
|
|
216
|
+
newly completed failure. `signals.fault` remains the retained-window maximum.
|
|
217
|
+
Exploring and production intensity remain inspected read/mutation proportions;
|
|
218
|
+
empty denominators yield zero, not NaN.
|
|
219
|
+
- A consecutive streak of eight successful executions across at least eight
|
|
220
|
+
distinct associated assistant turns, without a read or mutation, contributes
|
|
221
|
+
ambiguous spinning 0.46 at a tool-result boundary. A genuine pass, failure,
|
|
222
|
+
read, mutation or unknown family breaks the streak. The local assistant-frame
|
|
223
|
+
count prevents one batched call from manufacturing eight turns. The calibration
|
|
224
|
+
values 0.46 and eight come from the owned benchmark note and corpus, not the
|
|
225
|
+
former implementation: owned #637 corpus rule
|
|
226
|
+
`stage-spinning-below-threshold-stays-efficient` and the
|
|
227
|
+
[model-routing promotion note](../agent-notes/benchmarks.md#model-routing-promotion-rule-637-part-2).
|
|
228
|
+
- The fallback risk score is `max(severity, spinning)`; capable score is
|
|
229
|
+
that value and efficient score is its complement. Read/mutation dimensions are
|
|
230
|
+
retained as evidence for future adec questions, not a second hidden tier picker.
|
|
231
|
+
|
|
232
|
+
Review accepted the bound and score contract above. If retaining an owned
|
|
233
|
+
integration expectation requires a different rule, the contract records that
|
|
234
|
+
choice before code/tests are authored; no undocumented recalibration is accepted
|
|
235
|
+
as an implementation detail.
|
|
236
|
+
|
|
237
|
+
## Deterministic fallback and session switching
|
|
238
|
+
|
|
239
|
+
Pure API, with state explicit and no I/O:
|
|
240
|
+
|
|
241
|
+
```ts
|
|
242
|
+
interface FallbackStagePolicy {
|
|
243
|
+
confidenceThreshold?: number;
|
|
244
|
+
holdTurns?: number;
|
|
245
|
+
ambiguousBand?: number;
|
|
246
|
+
}
|
|
247
|
+
interface FallbackStageState { recoveryHoldRemaining: number }
|
|
248
|
+
interface FallbackStageResult {
|
|
249
|
+
tier: StageTier;
|
|
250
|
+
source: "default" | "dimensions" | "override" | "hold";
|
|
251
|
+
score: number;
|
|
252
|
+
state: FallbackStageState;
|
|
253
|
+
}
|
|
254
|
+
captureStageInput(source: unknown): StageInput | undefined;
|
|
255
|
+
buildStageEvidence(input: StageInput): StageEvidence;
|
|
256
|
+
selectFallbackStage(
|
|
257
|
+
evidence: StageEvidence,
|
|
258
|
+
policy?: FallbackStagePolicy,
|
|
259
|
+
state?: FallbackStageState,
|
|
260
|
+
): FallbackStageResult;
|
|
261
|
+
ambiguousStage(
|
|
262
|
+
result: FallbackStageResult,
|
|
263
|
+
policy?: FallbackStagePolicy,
|
|
264
|
+
): boolean;
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Omitted fallback policy fields use the existing confidence 0.5 and hold 2
|
|
268
|
+
defaults; an omitted policy is the same convenience. This changes no serialized
|
|
269
|
+
evidence field or configuration grammar. `ambiguousBand` belongs to the
|
|
270
|
+
question trigger below, not to the tier picker.
|
|
271
|
+
|
|
272
|
+
`StageInput` is a local-only bounded view, not a service DTO. Capture accepts the
|
|
273
|
+
existing message-array and relay-body-with-messages forms; unsupported source
|
|
274
|
+
shapes return unavailable without mutating them. The `confidence_threshold` and
|
|
275
|
+
`hold_turns` configuration keys map to the new policy names. An omitted state
|
|
276
|
+
starts with zero residual recovery hold. The source category is translated only to the
|
|
277
|
+
existing route-event categories above. Secondary exports for token estimation
|
|
278
|
+
and stay/switch planning retain the argument/return boundary exercised by their
|
|
279
|
+
nonported consumers, with newly authored internals; their compatibility
|
|
280
|
+
facade and wiring were pinned in the plan after contract review.
|
|
281
|
+
|
|
282
|
+
The result carries the tier, finite scalar score, a closed reason/source and a new
|
|
283
|
+
state. The builder/selector call no model, service, clock, process, file or global
|
|
284
|
+
session store. A caller retains state per route/session/configuration; another
|
|
285
|
+
session cannot inherit a hold, and a configuration change resets that state.
|
|
286
|
+
|
|
287
|
+
Fallback priority is explicit compaction, a current critical failure or an
|
|
288
|
+
active retained repeated-failure group, then residual configured recovery hold,
|
|
289
|
+
then a score above `confidence_threshold`, then an efficient default. A clean
|
|
290
|
+
step consumes residual hold rather than rearming an old group. Only a genuine
|
|
291
|
+
pass at the current tool-result boundary releases residual hold; retained
|
|
292
|
+
unrelated diagnostics remain, and a historical pass on a user, compaction or
|
|
293
|
+
other boundary never releases it. Equality/insufficient evidence uses the
|
|
294
|
+
declared default; no classifier runs inside the selector. Invalid input cannot
|
|
295
|
+
invent an alias or defeat the host's ordinary fixed fallback.
|
|
296
|
+
|
|
297
|
+
The effective enforced hold has a user-turn boundary floor: recovery remains
|
|
298
|
+
pinned through the tool loop until the next user boundary, and `hold_turns` can
|
|
299
|
+
extend it past that boundary. It is not a promise of exactly two following model
|
|
300
|
+
calls. The fallback's residual hold and the switch planner's session pin remain
|
|
301
|
+
separate; off/shadow preserve the owned recorded fallback decisions even when
|
|
302
|
+
the shadow plan would stay. Passing-test recovery and session isolation keep
|
|
303
|
+
their owned consumer expectations. This preserves the distinction between a
|
|
304
|
+
fallback proposal and the effective enforced backend.
|
|
305
|
+
|
|
306
|
+
Keep the existing switch contract: off and shadow do not change the fallback
|
|
307
|
+
choice; shadow adds only a proposed trace. Enforced stay/switch permits recovery
|
|
308
|
+
at once, holds a tool-result loop on its pinned tier, and considers other tier
|
|
309
|
+
changes at a user/compaction boundary. A downgrade over the configured prefill
|
|
310
|
+
bound stays pinned. A tier whose backend cannot fit the whole conversation is
|
|
311
|
+
not selected. The existing default prefill limit remains 32000. Sensitive turns
|
|
312
|
+
have no text-size-based switch bound and omit `prefillTokens` from events.
|
|
313
|
+
|
|
314
|
+
The input-token estimate remains an estimate used by existing context admission,
|
|
315
|
+
not a tokenizer claim. It covers the whole forwarded conversation and tool
|
|
316
|
+
schemas; the bounded recent stage view is never substituted as a full-context
|
|
317
|
+
size. An incomplete inspection cannot masquerade as a smaller complete input.
|
|
318
|
+
Its compatibility behavior and supported message/tool shapes must be pinned from
|
|
319
|
+
owned caller expectations before replacement; no route gains permission to trim
|
|
320
|
+
input or silently reduce output headroom.
|
|
321
|
+
|
|
322
|
+
### Ambiguity band, the question trigger (S2)
|
|
323
|
+
|
|
324
|
+
`ambiguousStage` answers one question: may this stage route ask the service at
|
|
325
|
+
all? It is `abs(score - confidenceThreshold) <= band`, with
|
|
326
|
+
`confidenceThreshold` defaulting to 0.5 and `AMBIGUOUS_BAND_DEFAULT` 0.05
|
|
327
|
+
(`AMBIGUOUS_BAND_MAX` 0.5 for the `ambiguous_band` key). At the default
|
|
328
|
+
threshold the owned repeated-execution reading 0.46 lies four hundredths inside
|
|
329
|
+
the band, while a reported failure 0.3 and an exception or critical failure 0.7
|
|
330
|
+
and 1 lie two tenths or more outside, so the default asks only for the
|
|
331
|
+
indecisive middle. A band outside `[0, 0.5]` and a non-finite threshold or band
|
|
332
|
+
are never ambiguous: an invalid value can only reduce asking, never invent one.
|
|
333
|
+
`ambiguous_band = 0` asks nothing, and `0.5` covers the whole score range at the
|
|
334
|
+
default threshold.
|
|
335
|
+
|
|
336
|
+
Membership is the whole of the band's effect. It never changes the fallback
|
|
337
|
+
tier, the fallback state or the source category, and the answer is recorded as
|
|
338
|
+
the route event's decision fields while the heuristic's model, effort and
|
|
339
|
+
forwarded conversation stand. The key is accepted only with
|
|
340
|
+
`classifier = "decision"`, whose one value is `"decision"`; a `stage` route
|
|
341
|
+
without it has no classifier and builds no service payload. The question offers
|
|
342
|
+
exactly the route's two tiers, since a tier carries no effort: `efficient` and
|
|
343
|
+
`capable` with effort `none`, the heuristic's own tier sent as `current`. One
|
|
344
|
+
question is asked per user turn, reused through the tool loop and dropped at the
|
|
345
|
+
turn's end.
|
|
346
|
+
|
|
347
|
+
The question carries R1's own closed `stage-route-evidence` packet
|
|
348
|
+
(`schemaVersion`, `kind`, `turn`, `incomplete`, `signals`, `dimensions`,
|
|
349
|
+
`scores`), never the generic `routing-decision-evidence` v1 projection, whose
|
|
350
|
+
quoted conversation fragments that contract does not allow; a PII or private
|
|
351
|
+
turn carries the `sensitiveStageEvidence` view of `schemaVersion`, `kind` and
|
|
352
|
+
`dimensions` only. The per-turn reuse keeps the privacy and observer facts an
|
|
353
|
+
answer was computed under: a later call republishes the held answer only while
|
|
354
|
+
those facts still hold, drops it when they change, and lets an unreadable
|
|
355
|
+
authority read propagate as `DecisionPolicyChangedError`.
|
|
356
|
+
|
|
357
|
+
### Secondary API pins
|
|
358
|
+
|
|
359
|
+
The new units define the public compatibility types/functions; `stage.ts` becomes
|
|
360
|
+
a freshly authored re-export facade, containing no former implementation body.
|
|
361
|
+
In particular `CodingAgentDimensions` is defined in `stage-evidence.ts` with the
|
|
362
|
+
four existing numeric fields, and `estimateInputTokens` is an export of the new
|
|
363
|
+
input-sizing unit. The generic v1 builder/test imports keep their existing path
|
|
364
|
+
and behavior until R3 retires that compatibility boundary.
|
|
365
|
+
|
|
366
|
+
```ts
|
|
367
|
+
type StaySwitchMode = "off" | "shadow" | "enforce";
|
|
368
|
+
interface StaySwitchPolicy {
|
|
369
|
+
stay_switch: StaySwitchMode;
|
|
370
|
+
max_switch_prefill_tokens: number;
|
|
371
|
+
}
|
|
372
|
+
type StageSwitchReason = "new_pin" | "compaction" | "context_fit" |
|
|
373
|
+
"same_tier" | "override" | "tool_loop" | "prefill_bound" | "user_turn";
|
|
374
|
+
interface StageSwitchTrace {
|
|
375
|
+
turnType?: Exclude<StageTurn, "other">;
|
|
376
|
+
prefillTokens?: number;
|
|
377
|
+
staySwitch?: "shadow" | "enforce";
|
|
378
|
+
plan?: "stay" | "switch";
|
|
379
|
+
reason?: StageSwitchReason;
|
|
380
|
+
}
|
|
381
|
+
interface StageSwitchResult {
|
|
382
|
+
tier: StageTier;
|
|
383
|
+
pin: StageTier | undefined;
|
|
384
|
+
trace: StageSwitchTrace;
|
|
385
|
+
}
|
|
386
|
+
estimateStageInputTokens(
|
|
387
|
+
messages: readonly unknown[], tools?: readonly unknown[],
|
|
388
|
+
): number | undefined;
|
|
389
|
+
planStageSwitch(
|
|
390
|
+
policy: StaySwitchPolicy | undefined,
|
|
391
|
+
pin: StageTier | undefined,
|
|
392
|
+
fallback: FallbackStageResult,
|
|
393
|
+
turn: StageTurn,
|
|
394
|
+
admission: { inputTokens?: number; fits(tier: StageTier): boolean },
|
|
395
|
+
): StageSwitchResult;
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
`DEFAULT_STAY_SWITCH` remains shadow with a 32000 prefill bound. Configuration
|
|
399
|
+
continues to reject unknown modes, nonpositive bounds and misplaced nested
|
|
400
|
+
keys. The eight reasons and five trace keys above are enumerated by
|
|
401
|
+
`docs/events.md`; no additional public reason is invented. Off emits turn type
|
|
402
|
+
and applicable public prefill only, omitting staySwitch/plan/reason. Shadow emits
|
|
403
|
+
the proposed trace without applying its tier. Enforce applies the existing
|
|
404
|
+
recovery/tool-loop/user-boundary rules. Fit remains the host's predicate; a fit
|
|
405
|
+
constraint can prevent an otherwise proposed tier. Unknown input does not gain a
|
|
406
|
+
new legacy trace turn category merely because the stage packet permits `other`.
|
|
407
|
+
|
|
408
|
+
The initial `new_pin` establishes the current tier and records `plan: "stay"`,
|
|
409
|
+
including sensitive routes; it is not a switch from an earlier tier.
|
|
410
|
+
The owned relay/runtime assertions pin initial `new_pin`, recovery `override`,
|
|
411
|
+
compaction, tool-loop stay, prefill-bound stay and user-turn switch. The event
|
|
412
|
+
contract additionally retains `same_tier` and `context_fit`; this audit does not
|
|
413
|
+
claim a new runtime observation of those branches. Relay/local traces share the
|
|
414
|
+
same estimator and planner. Sensitive planning omits input size and the prefill policy bound; local
|
|
415
|
+
capacity admission remains independent. Neither helper selects an alias, moves a
|
|
416
|
+
backend for load, applies effort or changes permission authority.
|
|
417
|
+
|
|
418
|
+
The sizing alias must use exactly the same computation for the supported owned
|
|
419
|
+
relay/context/decision shapes. Supported inputs include complete ChatMessage
|
|
420
|
+
arrays (string/null content and function-call/result metadata) and the published
|
|
421
|
+
JSON tool schemas. It returns a finite nonnegative integer for an available
|
|
422
|
+
estimate, covers the whole input, and never reports a partial recent-window
|
|
423
|
+
count. Unpinned shapes round up or conservatively overestimate. Overflow or an
|
|
424
|
+
unrepresentable input is explicitly unavailable, not zero, NaN or another small
|
|
425
|
+
count; a numeric compatibility call reports a closed sizing-unavailable failure
|
|
426
|
+
so the host can refuse capacity admission without disclosing source text.
|
|
427
|
+
|
|
428
|
+
The read-only helper audit found no independent nonported input-token forecast
|
|
429
|
+
in the examined OmniRoute client/usage, relay/MLX/Ollama, local and hub context/
|
|
430
|
+
usage helpers. `normalizeUsage` is post-request accounting and `contextHeadroom`
|
|
431
|
+
uses native occupancy; neither replaces an input forecast. Reuse the existing
|
|
432
|
+
`AutoRouteSelector` fit predicate, relay input-plus-requested-output admission
|
|
433
|
+
and `validateOllamaOptions` limits instead of duplicating their headroom policy.
|
|
434
|
+
|
|
435
|
+
### Whole-wire sizing arithmetic
|
|
436
|
+
|
|
437
|
+
Root accepted the single public-API observation and this newly authored,
|
|
438
|
+
conservative sizing rule under `41435398`:
|
|
439
|
+
|
|
440
|
+
- Form a local description containing the complete messages argument and, only
|
|
441
|
+
when provided, the complete tools argument. An undefined tools argument has no
|
|
442
|
+
tools field; an empty list remains present.
|
|
443
|
+
- Use ordinary compact JSON escaping for that description and count the UTF-8
|
|
444
|
+
bytes of the whole representation. Count all message/call/result and schema
|
|
445
|
+
data needed by that representation, not the bounded recent StageInput view.
|
|
446
|
+
- One forecast unit covers four encoded bytes; any remainder rounds upward.
|
|
447
|
+
This is a conservative input estimate, not provider tokenization or billable
|
|
448
|
+
usage. The same function supplies relay, context and decision callers.
|
|
449
|
+
- Supported inputs are plain JSON-compatible message/tool data. Cycles,
|
|
450
|
+
executable accessors/custom serialization, unsupported values, unsafe counts
|
|
451
|
+
or resource/serialization overflow are unavailable. Never return a small
|
|
452
|
+
partial count. The physical sizer uses the existing relay's 2,000,000-byte wire
|
|
453
|
+
ceiling as an overflow bound, independently of the 64 KiB stage-feature cap.
|
|
454
|
+
- `estimateStageInputTokens` returns a finite nonnegative integer or unavailable;
|
|
455
|
+
its numeric `estimateInputTokens` compatibility export reports a closed
|
|
456
|
+
sizing-unavailable failure instead of passing a fabricated number into an
|
|
457
|
+
unchanged consumer. Existing host fit/output-headroom guards stay authoritative.
|
|
458
|
+
|
|
459
|
+
On the 24 newly authored fixtures, this rule equals 23 observed scalars and gives
|
|
460
|
+
39 for the Unicode fixture whose former public API returned 27. Every result is
|
|
461
|
+
at least the observed value. This Unicode conservatism is intentional: capacity
|
|
462
|
+
fallback/refusal or a prefill-bound stay may happen earlier than with the former
|
|
463
|
+
approximation, without dropping or modifying input. Record that difference in
|
|
464
|
+
CHANGELOG. No unique absolute-count pin was found in the inspected owned caller
|
|
465
|
+
assertions; their fit outcomes and relay/local equality still remain authority.
|
|
466
|
+
A later discovered owned absolute pin must be preserved explicitly.
|
|
467
|
+
|
|
468
|
+
## Native progress projection, separate from stage selection
|
|
469
|
+
|
|
470
|
+
The nonported progress observer has a different public calibration from stage
|
|
471
|
+
routing. Its newly authored `progressDimensions(observations)` accepts the
|
|
472
|
+
observer's bounded native observations, not legacy ToolSignals or StageEvidence.
|
|
473
|
+
It inspects at most the existing latest 28 observations and bounded name/result/
|
|
474
|
+
native-turn fields; it does not inspect commands or tool arguments. It emits only
|
|
475
|
+
`severity`, `spinning`, `exploring` and `production`.
|
|
476
|
+
|
|
477
|
+
- An observed error has severity 0.7, including an AssertionError that stage
|
|
478
|
+
fallback treats as a reported failure. Stage scores do not recalibrate this
|
|
479
|
+
observer.
|
|
480
|
+
- Recognized reads and mutations contribute their proportions among inspected
|
|
481
|
+
observations. A completed Codex `fileChange` is mutation/production evidence.
|
|
482
|
+
- Spinning becomes 1 only after at least eight distinct known native turn IDs
|
|
483
|
+
with no observed mutation in the retained window; otherwise it is zero.
|
|
484
|
+
Missing IDs and repeated tool observations within one turn do not manufacture
|
|
485
|
+
separate attempts. Productive file changes do not become a spinning trigger.
|
|
486
|
+
- The existing repeated-failure-across-native-turns predicate remains separate.
|
|
487
|
+
Current privacy, open-task/owner, in-flight generation, latest-frame,
|
|
488
|
+
attempted-turn deduplication and judge/latch fences remain unchanged. A progress
|
|
489
|
+
dimension grants no execution, reassignment or model-routing authority.
|
|
490
|
+
|
|
491
|
+
This replacement removes the observer's dependency on the former stage helper.
|
|
492
|
+
Generic decision evidence v1 and remaining legacy route signal/judge code are
|
|
493
|
+
unchanged. The existing owned progress tests remain acceptance authority.
|
|
494
|
+
|
|
495
|
+
## Privacy, authority and events
|
|
496
|
+
|
|
497
|
+
Off mode builds no service payload and sends no request. Local fallback features
|
|
498
|
+
may still be computed. Before any future stage service payload is built or sent,
|
|
499
|
+
the host must apply the current privacy/observer admission. Review-observer
|
|
500
|
+
exclusion and remote turns skip the service. PII/private evidence requires
|
|
501
|
+
positive `onCampus()` and remains dimensions only even on campus. The decider's
|
|
502
|
+
payload/constraints redact context size to zero and expose no stage counts or
|
|
503
|
+
text-size feature. That zero is a decider-payload privacy rule, not permission to
|
|
504
|
+
bypass existing local/backend context or requested-output headroom checks.
|
|
505
|
+
Physical fit admission still considers the whole actual input under its existing
|
|
506
|
+
host limits; neither the redacted zero nor a stage-window count is used to admit
|
|
507
|
+
an oversized request. The switch planner still omits the sensitive prefill-based
|
|
508
|
+
policy bound and trace as described above. Unknown/changed facts
|
|
509
|
+
refuse the stale turn, rather than becoming a service failure fallback. Recheck
|
|
510
|
+
admission, campus, request and metadata-emission awaits and the original turn
|
|
511
|
+
binding. A proposed pick grants no execution or release authority.
|
|
512
|
+
|
|
513
|
+
Keep current route-event keys and value categories: `route`, `tier`, `source`,
|
|
514
|
+
`score`, `ms`; optional decision/turn/task/PII linkage; four numeric dimensions;
|
|
515
|
+
existing stay/switch trace; existing decision-mode/alias/effort/margin/latency and
|
|
516
|
+
screened decider fields. `source` keeps its current override/dimensions/hold/
|
|
517
|
+
classifier/default/decision categories (relay reorder sources remain owned by
|
|
518
|
+
the relay). Add no text, arguments, prompt, credential, server error prose or new
|
|
519
|
+
unbounded diagnostic field. Labels and telemetry remain optional and cannot
|
|
520
|
+
change a route or turn through a sink failure.
|
|
521
|
+
|
|
522
|
+
The S2 stage question uses those fields and adds none. `source` already carries
|
|
523
|
+
the escalation judge's reclassification under `classifier`, so a stage answer
|
|
524
|
+
never sets it: the fallback's own category stands and the answer rides the
|
|
525
|
+
decision mode, alias, effort, margin, latency, reason and screened decider
|
|
526
|
+
fields. Shadow records and changes no tier; abstain, `no_candidate`, a transport
|
|
527
|
+
failure or timeout, `decision_mode = off` and an off-campus decider for a
|
|
528
|
+
PII/private turn each keep the fallback tier and record a closed reason. An
|
|
529
|
+
optional question cannot refuse a turn by itself: a service failure or an ended
|
|
530
|
+
turn records nothing to apply. Changed or unavailable privacy or observer
|
|
531
|
+
authority is not a service failure, so it keeps refusing the stale turn exactly
|
|
532
|
+
as on a `decision` route, never as a model fallback around that refusal.
|
|
533
|
+
|
|
534
|
+
## Bounded public sizing characterization
|
|
535
|
+
|
|
536
|
+
Conductor decision `41435398` permits one bounded, model-free, network-free and
|
|
537
|
+
account-free characterization of the public `estimateInputTokens` API. Inputs
|
|
538
|
+
are newly authored synthetic fixtures shaped by owned caller contracts; outputs
|
|
539
|
+
are scalar estimates only, including finite nonnegative fractional baseline
|
|
540
|
+
values. Integer/round-up requirements apply to the new estimator; a valid older
|
|
541
|
+
fraction is not discarded to make that requirement appear already satisfied.
|
|
542
|
+
The former implementation body, function text,
|
|
543
|
+
upstream vectors and error stacks are not inspected. This is public-API
|
|
544
|
+
observation for compatibility; it does not authorize reconstructing expressions
|
|
545
|
+
from source.
|
|
546
|
+
|
|
547
|
+
The reviewed preparation is under workspace-relative
|
|
548
|
+
`scratchpad/temp/task855/sizing-v1`. Root approved its corrected fixed command
|
|
549
|
+
before the one invocation. The baseline is committed code
|
|
550
|
+
at `2219e9dbd5861d87bc4bddbe857b3bbfd7a9a07c`, identified separately by its Git
|
|
551
|
+
tree/module blob. The new private driver, fixture and command have their own
|
|
552
|
+
hashes; the untracked contract document and private probe are not labelled as
|
|
553
|
+
verified code from that commit. No dependency installation is included.
|
|
554
|
+
|
|
555
|
+
The characterization used 24 fixtures (78803 JSON bytes, under a 128 KiB
|
|
556
|
+
bound), with an 8-second worker wall bound, 3-second CPU bound and 16 KiB closed
|
|
557
|
+
scalar-output bound. A private HOME/cache/cwd, empty npm configuration, no-auto-
|
|
558
|
+
install flag, kernel no-network/credential restrictions and transport/process/
|
|
559
|
+
output guards surround the import. An owned synthetic read-open canary is used;
|
|
560
|
+
no real credential file is read. Arbitrary stdout and all stderr/stacks are
|
|
561
|
+
excluded from the retained scalar record. The worker is addressed only through
|
|
562
|
+
its own created process handle, with bounded stop and source-binding checks.
|
|
563
|
+
Only the driver's own closed failure phase and optional authored fixture id
|
|
564
|
+
survive an unsuccessful response; error objects, prose and stacks do not.
|
|
565
|
+
The single invocation completed with exit 0, owned stop and drained output,
|
|
566
|
+
with all 24 finite nonnegative scalars accepted (fractional values were allowed).
|
|
567
|
+
Baseline/component bindings passed before and after. Observed baseline effect
|
|
568
|
+
counters were zero; guard and owned-canary controls passed. The result SHA-256 is
|
|
569
|
+
`d551376c2959c948792f34985c44fca5bb4c602c56062f6a1321919b5ee953e9`.
|
|
570
|
+
This is scalar API compatibility evidence, not routing-gain, model or account
|
|
571
|
+
proof.
|
|
572
|
+
|
|
573
|
+
This is a 24-scalar CPU-bounded probe, not a heavy gate. The Mac placement reason
|
|
574
|
+
is the Seatbelt no-network/real-home fence, with ordinary successful work expected
|
|
575
|
+
below the roughly four-second remote synchronization cost; that expectation is
|
|
576
|
+
not a timing measurement. If preparation indicates greater normal cost, a remote
|
|
577
|
+
alternative needs approval rather than an implicit local fallback. Actual local
|
|
578
|
+
invocation requires fresh complete resource/thermal/ownership admission.
|
|
579
|
+
|
|
580
|
+
The new estimator must be at least each observed scalar on every authored
|
|
581
|
+
fixture and exactly satisfy values pinned by owned tests. Unsupported/unpinned shapes round up or conservatively overestimate;
|
|
582
|
+
overflow remains unavailable. The arithmetic was written in our own words
|
|
583
|
+
before production implementation. The authored inputs and expected scalars are
|
|
584
|
+
committed as our fixture at `test/fixtures/model-stage-sizing-v1.json`. The PR
|
|
585
|
+
records that the former function was observed only through its public API.
|
|
586
|
+
No second characterization, model request or quiet/no-op follow-up is implied.
|
|
587
|
+
|
|
588
|
+
## Implementation and consumer map
|
|
589
|
+
|
|
590
|
+
Fresh stage-only units were added under the reviewed task plan:
|
|
591
|
+
|
|
592
|
+
| Unit | Responsibility |
|
|
593
|
+
| --- | --- |
|
|
594
|
+
| `src/models/route/stage-input.ts` | Bounded local input capture, turn kind and token-estimate compatibility |
|
|
595
|
+
| `src/models/route/stage-diagnostics.ts` | Own diagnostic classification and transient repetition keys |
|
|
596
|
+
| `src/models/route/stage-evidence.ts` | Closed StageEvidence builder/validation and public numeric projection |
|
|
597
|
+
| `src/models/route/stage-fallback.ts` | Pure fallback state and stay/switch planning |
|
|
598
|
+
|
|
599
|
+
The following API map comes from nonported consumer source, not the replaced
|
|
600
|
+
implementations:
|
|
601
|
+
|
|
602
|
+
| Consumer | Existing boundary to preserve |
|
|
603
|
+
| --- | --- |
|
|
604
|
+
| `src/models/route/runtime.ts` | Stage state, tier/default/hold source, dimensions, token estimate and stay/switch result; R2 normalize/signal/review branches remain separately owned |
|
|
605
|
+
| `src/models/route/relay-selector.ts` | Stage result, session pin, fit predicate, source mapping and switch trace; backend override/reorder remains outside fallback |
|
|
606
|
+
| `src/models/relay.ts` | Token estimate and StaySwitchPolicy type; context/output headroom and fixed alias order remain unchanged |
|
|
607
|
+
| `src/hub/routing.ts` | DEFAULT_STAY_SWITCH and StaySwitchMode imports; `assign()` and config grammar remain unchanged |
|
|
608
|
+
| `src/adapters/local-worker.ts` | StaySwitchPolicy import; generic ToolObservation/research callback remains outside stage evidence |
|
|
609
|
+
| `src/models/route/decision.ts` | Four dimensions and token estimate; generic #813 evidence/transport/privacy fences remain unchanged |
|
|
610
|
+
| `src/models/route/decision-evidence.ts` | Four-dimension type dependency only; its function, payload and tests stay unchanged |
|
|
611
|
+
| `src/models/route/labels.ts` / `src/hub/inference.ts` | Remaining generic normalization/signal/fingerprint or Conversation consumers; migration/compatibility needs separate path approval |
|
|
612
|
+
|
|
613
|
+
`parseAdvisorVerdict` and legacy `text.ts` remain R2. Generic normalization,
|
|
614
|
+
signal/observation and outcome-label consumers still exist; R1 does not remove
|
|
615
|
+
those bodies by assuming the stage route was their only consumer. A small newly
|
|
616
|
+
authored compatibility facade may retain an existing type/import boundary where
|
|
617
|
+
required by unchanged consumers. A replaced stage-function file with no remaining
|
|
618
|
+
consumer is removed without reading its removed body. The PR lists retained
|
|
619
|
+
R2/R3 source-port files; R1 does not remove licenses/notices or upstream tooling.
|
|
620
|
+
|
|
621
|
+
The precise new exports, compatibility facade and consumer wiring paths were
|
|
622
|
+
pinned in the board plan before production edits. The own unit tests are
|
|
623
|
+
`test/model-stage-input.test.ts`, `test/model-stage-diagnostics.test.ts`,
|
|
624
|
+
`test/model-stage-evidence.test.ts` and `test/model-stage-fallback.test.ts`, with
|
|
625
|
+
independently authored cases from this contract. Existing relay/local-worker/decision/doctor tests remain authority;
|
|
626
|
+
no source-port golden cases are read or copied. Seed review uses id/path/test
|
|
627
|
+
metadata only. Current route-directory seed count is zero; any consumer anchor
|
|
628
|
+
that wiring touches is reviewed/rebound without weakening its named guard.
|