You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d0c8d95
Browse filesBrowse the repository at this point in the historyBrowse files
* feat(project): V2 project ownership, preferences, protocol + server
TKT-315 slice 3 (core through server; app half held per Ethan, in
flight behind Henry's TKT-314 session-entities slice).
Core: ProjectV2.Service now owns list/get/updateMetadata directly
over ProjectTable (build post, "Projects: finish the V2 move before
adding favorites") -- moved from the V1 opencode Project service,
which becomes a thin adapter over the same core calls. ProjectV2.Info
is now the full public Project.Info schema type (was a 1-field {id}
placeholder).
ProjectPreferenceTable + packages/core/src/project/preference.ts: a
compare-and-set service for favorite/rank/hidden/lastOpenedAt, keyed
by project_id alone (no principal key yet -- OpenCode has no durable
user principal; see the schema comment for why that's deliberate, not
an oversight). expectedRevision absent/0 means "create"; a stale or
missing revision fails with a typed Conflict carrying the row's
actual revision, so a client can retry without a second read.
Protocol + server: packages/protocol/src/groups/project.ts (list,
get, updateMetadata, preference.read, preference.write) and
packages/server/src/handlers/project.ts. Publishing project.updated /
project.preference.updated happens at the CALLERS (server handler, V1
adapter), not inside ProjectV2.Service itself -- core cannot depend on
EventV2 without a circular import (event.ts -> location.ts ->
project.ts, which needs Project.node); see the comment on
ProjectV2.Info for the full explanation and a pointer for whoever
touches this next.
Client regenerated. Migration: project_preference table, additive,
no backfill needed (a project with no preference row reads as the
untouched default).
Fixed along the way, found by tests not typecheck: preference Conflict
was originally Effect.died like the session-lifecycle Conflict it was
modeled on, but nothing here catches defects the way session.ts does
for that one -- it would have escaped as an unhandled crash instead of
a 409. Made it a plain typed failure since this CAS has no durable-
event-transaction rollback reason to need the defect trick.
Also fixed: extending ProjectV2.Interface broke the full monorepo
typecheck in packages/cli and packages/sdk-next, both of which build
their own explicit AppNodeBuilder node lists rather than relying on
transitive discovery. cli needed ProjectV2.node added to its list;
sdk-next needed HttpRouter.provideRequest (not Layer.provide) for the
same node, since HttpRouter.toWebHandler's type distinguishes
"Requires" from "GlobalRequires" request-kinds and only the former
API discharges the latter. Neither package is otherwise touched.
Tests: packages/core/test/project.test.ts (list/get/updateMetadata,
five preference CAS scenarios including create-conflict and stale-
revision-conflict). Six new httpapi-exercise scenarios for the v2
routes, three test modes, 221/0 (was 215/0). Full packages/opencode
suite 3257/1/22/1 -- the 1 fail is the documented local-environment
umask caveat (tool.write sensitive-file-permissions), not new.
packages/core 1118/0 (was 1108/0). packages/app unchanged, 722+41/0.
bun typecheck 30/30. bun run lint 4859/1, matching FORK.md's baseline
exactly.
* fix(project): preference-create 404 not 500; explicit node wiring
Two real bugs, both caught by the httpapi exerciser's automatic
per-route bad-ID probe, not by typecheck:
1. ProjectPreference.patch's create path (no expectedRevision) relied
on the project_preference table's FK constraint to reject a
nonexistent project, wrapped in Effect.orDie -- so a bad project ID
crashed with an unhandled SQLite FOREIGN KEY error (500) instead of
a typed 404. Added an explicit existence check with a new
ProjectPreference.ProjectNotFound error, mapped to the same 404 the
other project routes already use.
2. Extending ProjectV2's interface (this ticket) and adding
SessionGoal/SessionLedger (TKT-317, #7) together pushed past
whatever threshold makes AppNodeBuilder's transitive auto-discovery
of a new global .node's own dependencies unreliable -- confirmed
via clean-dev isolation before attributing anything (dev alone:
227/0; my branch before this fix: crashes and "Service not found"
errors in three separate full-app composition sites). Explicit
node listing needed in:
- packages/server/src/routes.ts (v2 API, used by cli/sdk-next)
- packages/opencode/src/server/routes/instance/httpapi/server.ts
(the V1 HttpApiApp -- what test:httpapi actually runs against;
SessionGoal/SessionLedger gap here is pre-existing from #7, not
from this PR, but blocks this PR's own gate, so fixed here per
Ethan's ruling rather than serialized on its own ticket)
- packages/opencode/src/effect/app-runtime.ts (the CLI/TUI runtime
-- the same gap here is invisible to any HTTP-shaped test, since
nothing exercises it that way; found by enumeration, not by a
failing test)
Per Ethan's follow-up ask: enumerated every AppNodeBuilder/LayerNode
.group assembly site in the repo (grep in FORK.md's new section),
distinguished the five full-app composition sites (need every global
node) from location-services.ts (a different category -- per-location
services, global nodes don't belong) and everything else (narrow,
single-feature builds). Documented in FORK.md so the next new global
.node has a checklist instead of a minefield.
Fixing #2 unmasked a third, unrelated issue: v2.session.goal.get now
reaches its assertion instead of crashing first, and fails it in
test:httpapi's mode=effect only ("a session with no goal set should
report no data") -- coverage and auth modes both pass. Not caused by
this diff (unrelated code, TKT-317's), filed as feedback anomalyco#145 and
recorded as a new named exception in FORK.md's known-red table,
matching the TKT-305 convention exactly.
Full validation after all of the above: bun typecheck 30/30. Core
1126/0 (new: a regression test asserting patch-on-nonexistent-project
fails typed, not crashed). App 722+41/0, unchanged. Full opencode
suite 3257/1/22/1, the 1 is the documented umask caveat, unchanged.
test:httpapi 227/0 in mode=coverage and mode=auth, 226/1 in
mode=effect (the newly-filed, newly-named exception above) -- was
221/6 (all crashes) before this commit. lint 4865/1 against a
freshly-verified clean-dev-with-Gemma's-merge baseline of 4864/1 (not
the stale 4859/4860 figures from before her PR landed) -- a 1-count
difference already inside the noise band FORK.md documents as not
meaningful, confirmed by checking each of the touched files' findings
against clean dev individually: all pre-existing, none new.
* fix(project): trace app-runtime.ts node reachability; interim timeout widen
Per Ethan's ruling: the earlier "every list gets every node" framing in
FORK.md's node-assembly-sites section was too broad. The correct rule
is every list whose runtime can actually reach the node -- traced,
not assumed.
Confirmed reachable, kept in app-runtime.ts (CLI/TUI AppLayer):
- ProjectV2: the V1 project/project.ts adapter it backs is imported by
project/bootstrap.ts, which app-node-builder-v1.ts (this site's own
builder) depends on unconditionally.
- SessionGoal/SessionLedger: consumed by the built-in goal_get /
goal_update_progress / ledger_add tools, part of the standard
toolset every session gets regardless of runtime.
Both traced with concrete import chains, documented in FORK.md so the
next node addition has a method, not just a checklist.
Separately: cold-spawn distribution measurement (isolated single-test
runs vs. full-file concurrent runs, 6-8x each, branch vs. dev-baseline)
confirmed a real, reproducible ~0.2-0.5s slowdown under concurrent
subprocess load from building 3 more global nodes at every CLI boot --
invisible in isolation, real under packages/opencode/test/cli/run/
run-process.test.ts's 13 concurrent cliIt.concurrent() subprocesses.
None of the three nodes do eager I/O; this is inherent per-node
construction cost. On CI's more constrained runners this plausibly
tips several already-borderline subprocess spawns over their 30s
timeout at once (7 additional failures observed, none reproducing
locally).
The real fix is lazy node construction -- architecture, not a rider on
this PR. Filed as feedback anomalyco#150. Interim mitigation landed here: raised
timeoutMs from the 30_000 default to 45_000 on the 7 affected tests
only (each commented, linked to anomalyco#150), with the outer bun-test timeout
raised to match where a test makes multiple sequential subprocess
calls. FORK.md's known-red table and milestone-1 gate section updated
to record this as mitigated-not-currently-red.
Full validation after all of the above: bun typecheck 30/30. Full
packages/opencode suite 3257/1/22/1 -- unchanged from baseline.
run-process.test.ts itself: 13/13 pass locally, matching pre-existing
behavior.
Co-Authored-By: Claude <[email protected]>
---------
Co-authored-by: Felicity <[email protected]>
Co-authored-by: Claude <[email protected]>
--include="*.tsx" | grep -v "/test/" | grep -v "\.test\.ts$"`, then narrowed to the entries whose
140
+
own node count made clear they were "assemble everything" sites rather than one narrow feature):
141
+
142
+
1.`packages/opencode/src/server/routes/instance/httpapi/server.ts` — the `app` list (~63 nodes).
143
+
The V1 `HttpApiApp`; this is what `test:httpapi`'s exerciser actually runs against.
144
+
2.`packages/opencode/src/effect/app-runtime.ts` — `AppLayer` (~52 nodes). Powers the interactive
145
+
CLI/TUI (`opencode` run directly, not through the HTTP server) — a gap here is invisible to any
146
+
HTTP-shaped test. `ProjectV2.node`/`SessionGoal.node`/`SessionLedger.node` are listed here,
147
+
traced reachable: `ProjectV2` through the V1 `project/project.ts` adapter, imported by
148
+
`project/bootstrap.ts`, which `app-node-builder-v1.ts` (this site's own builder) depends on
149
+
unconditionally; `SessionGoal`/`SessionLedger` through the built-in `goal_get`/
150
+
`goal_update_progress`/`ledger_add` tools, part of the standard toolset every session gets
151
+
regardless of runtime. Listing them here has a real, measured cost — see feedback #150 in the
152
+
milestone-1 gate section below.
153
+
3.`packages/server/src/routes.ts` — `applicationServices` (~15 nodes). The current v2
154
+
`createRoutes`/`createEmbeddedRoutes`, used by `packages/cli` and `packages/sdk-next`.
155
+
4.`packages/cli/src/commands/handlers/serve.ts` — the CLI daemon's own explicit
156
+
`AppNodeBuilder.build(LayerNode.group([...]))` in `bind()`.
157
+
5.`packages/sdk-next/src/opencode.ts` — the embedded-server SDK's own explicit list. Also needs
158
+
the type-level `HttpRouter.provideRequest(...)` treatment below, not just the node list.
159
+
160
+
**Not on this list, and shouldn't be added to it:**`packages/core/src/location-services.ts`
161
+
(`locationServices`, ~36 nodes) looks similar by node count but is a **different category** —
162
+
per-location/per-workspace scoped services (`LayerNode.unbound`/`LocationServiceMap`), rebuilt per
163
+
directory, not process-wide singletons. A global `.node` does not belong there. Everything else
164
+
`grep` finds under `packages/` outside `test/` is a narrow, single- or few-node build for one
165
+
specific feature (e.g. `packages/opencode/src/control-plane/workspace.ts`'s two `InstanceStore.node`
166
+
uses) — not a checklist target.
167
+
168
+
**If the new node is consumed through `HttpRouter.toWebHandler`** (as in `sdk-next/opencode.ts`),
169
+
listing it in the node graph is necessary but not sufficient. `HttpRouter.toWebHandler`'s type
170
+
distinguishes `"Requires"` from `"GlobalRequires"` request-kinds, and only
171
+
`HttpRouter.provideRequest(layer)` discharges the latter — plain `Layer.provide(...)` silently
172
+
leaves it unsatisfied and the handler's call signature shifts from one argument to two
173
+
(`(request, context: Context<...>) => Promise<Response>`), a type error at the call site, not at
174
+
the provide site. `HttpRouter.serve` (used by `packages/cli`'s daemon) does not draw this same
175
+
distinction, which is why the equivalent fix there was just adding the node to the existing
176
+
`Layer.provide(AppNodeBuilder.build(...))` list.
177
+
101
178
## Merge-blocking gates
102
179
103
180
These gates are **merge-blocking conditions**, not aspirations. A PR that trips one does not
@@ -228,6 +305,7 @@ your own regression** — check whether it matches one of these first.
228
305
|`unit (windows)` — **mode B, intermittent**|`bun install --linker hoisted` fails applying the `@ai-sdk/[email protected]` patch |`error: renaming changes to cache dir: ENOTEMPTY: ... Directory not empty (NtSetInformationFile())` — matches the exact race described in [`oven-sh/bun#28147`](https://github.com/oven-sh/bun/issues/28147), which the workflow's own `bun install --linker hoisted` comment already references. Identical failure on 2/2 independent reruns at the time it was recorded. `ubuntu-latest` is unaffected. Listed alongside mode A rather than replaced by it: this mode is real and was observed, it simply is not the only way Windows goes red, and in later runs install succeeded and the job reached the tests instead. | feedback #136 (internal tracker) | Resolves when bun's patch-apply race is fixed upstream, or worked around (e.g. serialize patch application on Windows, or pin an unaffected bun patch-apply path). |
229
306
| `unit (linux)` | `packages/opencode/test/cli/run/run-process.test.ts:79` — "exits nonzero promptly when the model is unknown (regression for #27371)" | `expect(result.durationMs).toBeLessThan(15_000)` received `15285ms` then `15275ms` on two independent reruns — consistently ~275–285ms *over* the `timeoutMs: 15_000` configured two lines above the assertion. The pattern (always just past the exact configured timeout, not randomly distributed) suggests the "unknown model" fast-fail path is not triggering on GitHub Actions' network, and the process is instead being killed by its own `timeoutMs` — which structurally cannot finish before the timeout it races against. Not exercised by TKT-304's local baseline (that baseline ran `packages/core test` + `packages/opencode test:httpapi` + `packages/app test` specifically, not `packages/opencode`'s own broader suite that `bun turbo test` pulls in). | feedback #136 (internal tracker) | Resolves when #136 is triaged — either the fast-fail detection is fixed, or the test's timing assumption is loosened for CI network conditions. |
230
307
|`packages/opencode test:httpapi` — **`mode=effect` only**|`GET /api/session/{sessionID}/goal` — `v2.session.goal.get` — "a session with no goal set should report no data" | Was masked by a crash: `session.goal`/`session.ledger` routes 500'd with "Service not found" on every mode, because the app's `LayerNode.group` in `packages/opencode/src/server/routes/instance/httpapi/server.ts` never listed `SessionGoal.node`/`SessionLedger.node` (a gap in [#7](https://github.com/Draugur-AI/opencode/pull/7), fixed standalone once found while working TKT-315). Fixing that crash let this route reach its own assertion, which fails only in `mode=effect` — `mode=coverage` and `mode=auth` both pass. Confirmed deterministic across reruns. | feedback #145 (internal tracker) | Resolves when #145 is triaged against TKT-317's own code — not a node-wiring issue, the route runs now, its behavior is wrong. |
308
+
| `unit (linux)` — **run-process under load, MITIGATED not currently red** | Up to 7 additional tests in `packages/opencode/test/cli/run/run-process.test.ts`, all clustered 700-800ms over the harness's 30\_000ms default `timeoutMs` (e.g. 30740-30800ms) | TKT-315 added `ProjectV2.node`/`SessionGoal.node`/`SessionLedger.node` to `app-runtime.ts`'s `AppLayer` (see "Adding a new global `.node`?" above -- all three traced reachable, not removable). None of the three do eager I/O at layer construction, but building 3 more global nodes has nonzero cost, and `run-process.test.ts` spawns 13 real CLI subprocesses concurrently (`cliIt.concurrent`) -- isolated single-test timing showed no difference between branches (8 runs each, fully overlapping), but 6x full-file runs did: dev-baseline [11.23s-11.69s] vs the branch with these 3 nodes [11.73s-11.91s], non-overlapping. Invisible locally (this machine has headroom the CI runners don't); on CI this plausibly tips several already-borderline subprocess spawns over their timeout at once. A CI rerun of the pre-fix commit came back fully clean (0 fail) on one attempt, so the failure is a mix of this real overhead and environmental variance, not 100% deterministic either way. Interim mitigation landed in the same PR: `timeoutMs` raised from 30\_000 to 45\_000 (and the outer test timeout to match) on the 7 affected tests only, each commented and linked here -- the real fix is lazy node construction, not a rider on a feature PR. | feedback #150 (internal tracker) | Resolves when #150 is triaged and global nodes construct lazily on first use instead of eagerly at `AppLayer` boot; the `timeoutMs` widen reverts once that lands. |
0 commit comments