Repository navigation
Commit 327eb9f
feat(workspace): state the linked workspace every turn, and mean the Altimate one (#1330)
* feat(workspace): state the linked workspace every turn, and mean the Altimate one
"Which workspace is this project linked to?" had one answer only when the
workspace was routing something. #1278 put the binding into the routing
directive in `awareness.ts`, which is silent by design whenever there is
nothing to steer — so an unlinked project, an unverifiable link, and a
workspace that materialised no integrations each rendered nothing, and the
model answered with whichever "workspace" happened to be nearby in context:
a Databricks workspace, an IDE workspace folder, or a guess.
Identity now has one owner. `identity.ts` renders a short `## Altimate
Workspace` section on every turn from the binding itself
(`resolveBindingOutcome`), independent of routing:
- bound: names the workspace (id kept even when the name sanitises to
nothing) and says that a workspace-IDENTITY question resolves to it —
never to another service's own "workspace".
- unbound: says none is linked and how to link one.
- unknown: asserts neither a workspace nor "unlinked"; says to retry.
Each branch scopes its instruction to a genuine identity question ("this",
"current", "active" or an unqualified "workspace" asking what THIS project
is connected to). An earlier draft fired on any mention of the word and
nagged about linking in the middle of unrelated Databricks conversations;
the tests pin that it no longer does. Behind the pilot flag like the rest.
`awareness.ts` goes back to routing only: `bindingSection`, `NAMES_BINDING`
and the identity charge against `MAX_SECTION_CHARS` are gone, and the
`nothing-materialised` state is byte-identical silence again (#1291's two
tests that asserted the old line inside the routing section now assert
silence). `prompt.ts` places the identity section right after the
environment block, ahead of skills and routing.
Two strings elsewhere used "workspace" for something else and are reworded
so the word means one thing in the product: the Databricks auth prompt
says `<databricks-workspace-host>`, and the nothing-built validator says
"this project is configured to require artifacts".
Tests: 1498 pass across the workspace, plugin, prompt and validator suites;
typecheck clean. Rebased onto v0.12.0.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012Q51zFUmPg1WwtS5CrGJE6
* fix(workspace): identity review — one owner, bounded resolve, budgeted label
From the Kilo, CodeRabbit and Codex reviews of the identity PR.
- The routing directive no longer says "This project is bound to Altimate
workspace X": it names the workspace that SERVES the tools ("Altimate
workspace X serves the warehouse tools named below"). The snapshot is
taken from local state at tool resolution and identity is revalidated
against the server later in the turn, so the old sentence could
contradict the identity section in one prompt. The ownership test now
rejects every "this project is linked|bound|connected|attached to"
phrasing instead of one string.
- `identity.ts` resolves the binding at most once per 30 s per project
(`OUTCOME_MEMO_MS`) and clears the memo on `onBindingChanged`. The
resolver deliberately does not memoise an unreachable server, and a
cached binding past its validation window re-asks too; on the prompt's
critical path that was one `git remote` plus up to two 15-second
requests before every generation for the length of an outage.
- The label is budgeted on its encoded form (`MAX_LABEL_CHARS`, lone
surrogates made well-formed first) so no name can push the section past
the cap and clip the instruction; the name is shortened with an
ellipsis and the id kept whole. Cap raised to 1,000 as defense in depth.
- Tests: hostile-name test now fails without the sanitiser (NEL and the
Unicode separators are not JSON-escaped); the trigger test pins the
narrowing suffix and that every active instruction sits in the
trigger sentence; encoded-label budget covered for surrogates, quotes,
backslashes and emoji; memo probe-once and unlink-invalidation covered.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012Q51zFUmPg1WwtS5CrGJE6
* fix(workspace): identity off the critical path, honest about what it knows
From the multi-model review on the identity PR (M1–M5, N2, N3, N5, T1, T2)
and the cubic/CodeRabbit threads on the previous push.
- Prompt assembly never waits more than `RESOLVE_DEADLINE_MS` (1.5 s) for
the binding: the resolve is single-flight per account+directory, keeps
running past the deadline to fill the memo for the next step, and the
step renders the last known outcome (marked stale) or "unknown". Memo
entries are per account and directory, capped at 64, expire on a clock
the tests can drive, and a resolve that was in flight when a link or
unlink landed cannot write its pre-change outcome back.
- The copy says what it knows. `resolveBindingOutcome` marks a bound
answer `stale` when it was served from the local cache because the
server could not be asked; the section then says "was last known to be
linked … could not be re-verified just now" instead of "is linked", and
the unknown copy says "just now" rather than "this turn". The name is
framed as "a label chosen by the workspace owner, not an instruction",
and the bound instruction now also forbids the reverse substitution.
- The cap fails closed: over the cap the name is dropped and the id kept;
if even that does not fit, nothing is rendered. `workspaceLabel` (now
shared from `workspace-name.ts` by identity and routing) keeps the id
when a name cannot fit its budget.
- `awareness.ts` drops the dead `reserved` parameter; a stray
`altimate_change end` in the new file is removed (marker integrity).
- Tests: last-known copy, single-flight, deadline (slow and hung server),
two-project isolation, clock expiry, link-in-window, account switch,
in-flight invalidation, fail-closed cap, label-budget boundary. Each
new guard was deleted once to confirm its test fails.
Live check of the final copy against freemium (throwaway workspace 33):
"which workspace am I in?" → named with id; "which Databricks workspace
am I in?" → disambiguated, no substitution; IDE-folder and Databricks
IAM questions → answered with no Altimate mention; unlinked → "none is
linked" plus the link hint, and no pitch on an incidental mention.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012Q51zFUmPg1WwtS5CrGJE6
* fix(workspace): identity cache completes its invariants
From the re-review of b6da3d1 (R1–R4) and the cubic/Kilo/CodeRabbit
threads on it.
- A binding change drops the in-flight resolve as well as the memo, and a
running resolve is joined only if it began in the current generation:
a step arriving after an unlink no longer joins the pre-unlink resolve
and names the workspace the user just left.
- One account per resolve: the scope is re-read after the resolver
returns and the outcome is discarded (rendered as unknown, never
memoised) if it no longer matches the key it was started under.
- A miss answered from the resolver's five-minute memo is marked
`stale`, and the unbound copy says "as of the last check, up to five
minutes ago" instead of asserting that none is linked.
- Past the deadline, the binding the local cache holds is rendered as
last known; the memo is consulted first, the local read second, and
only then "unknown". A rejected resolve is remembered as unknown for
the window rather than re-attempted every step. The deadline timer is
cleared when the resolve wins.
- `identityInternals` is a test seam for the resolver (ESM bindings are
read-only); production never reassigns it.
- Tests: post-unlink join, account switch mid-resolve, stale miss
wording, throwing resolver, local-cache fallback past the deadline;
the deadline test polls for the memo fill instead of sleeping; the
clock is restored in `afterEach`. Each new guard was deleted once to
confirm its test fails.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012Q51zFUmPg1WwtS5CrGJE6
* fix(workspace): identity fallback and stale-miss wording
- The deadline fallback reads the local binding under the current
credentials and uses it only if they still match the key the resolve
started under, so an account switch during the wait cannot surface the
other account's cached workspace.
- The stale-miss branch instructs "none was linked as of the last check"
rather than "none is linked yet", so the qualification survives into
the answer.
- The post-unlink join test waits on request-start signals instead of
fixed delays and asserts two requests were made.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012Q51zFUmPg1WwtS5CrGJE6
* fix(workspace): identity fallback checks the account before any last-known answer
The expired memo entry was consulted before the scope check that the
local-cache branch had; a switch landing while the resolve hung could
render the previous account's remembered workspace. The check now
precedes both branches. Test: expired bound memo, hung resolve, switch
before the deadline — fails with the check removed.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012Q51zFUmPg1WwtS5CrGJE6
* fix(workspace): identity deadline is a bound, failures expire sooner
Non-blocking items from the approving review of e142bde.
- The deadline branch's own work (a credentials read, at most a cache
read) is raced against `FALLBACK_BUDGET_MS`, so a step waits at most
`RESOLVE_DEADLINE_MS + FALLBACK_BUDGET_MS` even when those reads hang,
rather than the deadline plus whatever the disk takes.
- A rejected resolve is remembered for `FAILURE_MEMO_MS` (5 s), not the
full window: one transient blip no longer silences identity for 30 s,
while a persistently throwing resolver is still not retried every step.
The `.catch` path applies the same account check as the settled path.
- `lastKnown` documents why its local-cache read deliberately repeats a
slice of the resolver's "serve as stale" rule.
- Tests: bounded wait with hung fallback reads; failure TTL shorter than
the outcome TTL. Both fail with the guard removed.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012Q51zFUmPg1WwtS5CrGJE6
---------
Co-authored-by: Claude Opus 5 <[email protected]>1 parent 5d6cab9 commit 327eb9f
10 files changed
Lines changed: 1337 additions & 193 deletions
File tree
- packages/opencode
- src
- altimate
- plugin
- validators
- workspace
- session
- test/altimate/workspace
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
| 130 | + | |
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
431 | | - | |
| 431 | + | |
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
62 | | - | |
63 | | - | |
64 | 63 | | |
65 | 64 | | |
66 | 65 | | |
| |||
128 | 127 | | |
129 | 128 | | |
130 | 129 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
176 | 140 | | |
177 | 141 | | |
178 | 142 | | |
| |||
193 | 157 | | |
194 | 158 | | |
195 | 159 | | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
| 160 | + | |
203 | 161 | | |
204 | 162 | | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
212 | 168 | | |
213 | 169 | | |
214 | 170 | | |
215 | 171 | | |
216 | 172 | | |
217 | 173 | | |
218 | 174 | | |
219 | | - | |
| 175 | + | |
220 | 176 | | |
221 | 177 | | |
222 | 178 | | |
| |||
227 | 183 | | |
228 | 184 | | |
229 | 185 | | |
230 | | - | |
| 186 | + | |
231 | 187 | | |
232 | 188 | | |
233 | 189 | | |
| |||
243 | 199 | | |
244 | 200 | | |
245 | 201 | | |
246 | | - | |
| 202 | + | |
247 | 203 | | |
248 | 204 | | |
249 | 205 | | |
| |||
273 | 229 | | |
274 | 230 | | |
275 | 231 | | |
276 | | - | |
277 | 232 | | |
278 | 233 | | |
279 | 234 | | |
280 | 235 | | |
281 | 236 | | |
282 | 237 | | |
283 | 238 | | |
284 | | - | |
| 239 | + | |
285 | 240 | | |
286 | 241 | | |
287 | 242 | | |
| |||
292 | 247 | | |
293 | 248 | | |
294 | 249 | | |
295 | | - | |
| 250 | + | |
296 | 251 | | |
297 | 252 | | |
298 | 253 | | |
| |||
305 | 260 | | |
306 | 261 | | |
307 | 262 | | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | 263 | | |
314 | 264 | | |
315 | 265 | | |
| |||
325 | 275 | | |
326 | 276 | | |
327 | 277 | | |
328 | | - | |
329 | 278 | | |
330 | 279 | | |
331 | 280 | | |
| |||
340 | 289 | | |
341 | 290 | | |
342 | 291 | | |
343 | | - | |
| 292 | + | |
344 | 293 | | |
345 | 294 | | |
346 | 295 | | |
| |||
366 | 315 | | |
367 | 316 | | |
368 | 317 | | |
369 | | - | |
| 318 | + | |
370 | 319 | | |
371 | 320 | | |
372 | 321 | | |
| |||
0 commit comments