Commit dda6210
authored
fix: restore preview dependencies after sandbox wake (#202)
## Summary
- Restore disposable pnpm dependencies before a persisted preview or
pnpm-backed process relaunches in a replacement Daytona container.
- Keep the immutable app-builder template on its zero-install fast path
when both manifests match.
- Tighten the FastApply tool contract to consistently produce valid
sparse edits.
## Architecture
Durable Object storage remains the source of truth for process launch
intent and port reservations. On wake or runtime replacement, the Worker
mirrors durable project source onto native sandbox disk, reconciles the
disposable dependency tree, starts the source-sync loop, and then
relaunches the persisted process.
## Decisions Made
| Decision | Choice | Alternatives considered | Reasoning |
|---|---|---|---|
| Dependency recovery | Reconcile with pnpm before every custom process
launch | Trust a `node_modules` presence marker | Presence can be stale
after manifest changes; pnpm is the correctness boundary. |
| Cold-start behavior | Offline-first frozen install with prefer-offline
network fallback | Network-only install | Cached packages restore
quickly while custom dependencies remain recoverable. |
| Template behavior | Compare template package and lock manifests, then
skip install | Always install | The immutable template already has a
baked shared runtime and should remain instant. |
| Edit guidance | Match Morph's exact marker-based contract | Allow
ambiguous sparse edits | Explicit markers prevent accidental deletion
and reduce invalid model calls. |
## Edge Cases Handled
| Scenario | Handling |
|---|---|
| Custom dependencies disappear with a replacement container | Reinstall
from the durable lockfile before process start. |
| Cached package is unavailable offline | Retry through the registry
with bounded network concurrency. |
| Project has no lockfile | Perform a supported prefer-offline install.
|
| Unchanged scaffold uses only baked dependencies | Skip installation
after exact manifest comparison. |
| Sparse edit omits unchanged regions | Schema and tool guidance require
the exact existing-code marker. |
## How to Review
1. Start with `project-sandbox-local-source.ts` for process ordering and
dependency recovery.
2. Check the app-builder and generic process call sites.
3. Review the FastApply descriptions and README update.
## Verification
- [x] `pnpm lint`
- [x] `pnpm typecheck`
- [x] `pnpm turbo build --force`
- [x] `pnpm deadcode`
- [x] `pnpm architecture:check`
- [x] `pnpm turbo skills:build`
- [x] Generated command assertions for ordering, offline fallback,
lockless recovery, and template fast path
- [x] Production explicit FastApply flow reached an atomic
compare-and-swap write
- [ ] Production cold-restore preview QA after Worker deployment and
immutable snapshot promotion1 parent 2f97a1c commit dda6210
6 files changed
Lines changed: 49 additions & 9 deletions
File tree
- apps/agent-worker
- src/durable-objects
- packages/agent-core/src
- mastra/tool-defs
- tools/code
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
161 | 164 | | |
162 | 165 | | |
163 | 166 | | |
| |||
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
4 | 8 | | |
5 | 9 | | |
6 | 10 | | |
| |||
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
28 | | - | |
| 32 | + | |
29 | 33 | | |
Lines changed: 30 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| 54 | + | |
| 55 | + | |
53 | 56 | | |
54 | 57 | | |
55 | | - | |
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
| |||
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| |||
378 | 381 | | |
379 | 382 | | |
380 | 383 | | |
381 | | - | |
| 384 | + | |
382 | 385 | | |
383 | 386 | | |
384 | 387 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | | - | |
| 159 | + | |
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
| |||
0 commit comments