Skip to content

refactor(platform): shrink the desk workflow onto two new step primitives - #2548

Merged
larryro merged 15 commits into
mainfrom
desk-workflow-simplify
Jul 8, 2026
Merged

larryro merged 15 commits into
mainfrom
desk-workflow-simplify

Conversation

@larryro

@larryro larryro commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #2542 (the shared-sandbox human pause): a structural review of desk-process.json found most of its 48 steps were vocabulary workarounds, not process. Two small engine-level primitives remove the boilerplate and the workflow drops to 36 steps with identical semantics.

New step primitives

  • request_review takes an optional round, folded into the approval's idempotency key ((execution, step, round); legacy rows read as round 0). One review-gate step now serves every human round — v1 duplicated the whole gate (request_plan_review + request_plan_re_review + a two-condition pick chain) because a re-executed responded step replays its recorded decision, and that structurally capped human reviews at two.
  • task update_status takes an optional comment, posted (as the workflow actor) just before the status change — folding the six comment→status step pairs (rollbacks, parks, exhaustion escalations) into one step each.

Workflow changes (v2.1.0)

  • Plan review is one bounded loop: bump round → bound gate → request (round-keyed) → decide; Request-changes feedback still travels via one capture variable — the definition validator (correctly) forbids advise from templating a later-ordered step's output.
  • The three near-identical Dream variants collapse into ONE step fed the judge verdict by template; the verdict routing conditions trail it (step outputs are persisted).
  • Every park/rollback is a single update_status+comment step; the four parks share the issueDesk.markInReview label so the run view renders them as one lane.
  • Agent METHOD text moves out of step instructions into the agent configs: the implementer's 6.3k-char procedure (PR dedupe, canonical-PR selection, CI watch, commit rules) becomes its systemInstructions; the reviewer's setup line now honours the shared workspace instead of instructing a re-clone. Step instructions carry only per-run context (issue ref, desk branch, repo notes, test command, loop counters).
  • All three loops (plan review / replan / rework) share the maxReworkLoops cap.

Verification

  • Graph integrity: 36 steps, no dangling refs, no unreachable steps; validateWorkflowDefinition passes (it caught one real cycle during the rewrite — see the capture-variable note above).
  • New tests: round-keyed request assertions, approvalRound (legacy rows → round 0), update_status comment ride-along (order + blank-skip), rewritten desk-graph assertions, spine-lane fixtures for the four-park pattern. Affected server suites 1989/1989 green on the branch and 341/341 re-run after rebasing onto latest main; UI suites 126/126.
  • Live dev stack: app reinstalled; the org copy now carries v2.1.0 (36 steps, round-keyed gate).

Notes for operators

Installed apps snapshot their bundle — picking this up requires an app Reinstall. Reinstall still resets per-agent runtime overrides (known gap, tracked separately).

CI fixes carried by this branch (unrelated to the refactor, but blocking it)

  • Convex push over the backend cap (1efc1ff97): all 16 Playwright shards failed at the convex preflight — ModulesTooLarge: 42.97 MiB > 42.92 MiB. The cap counts the external-deps package the backend builds server-side from npm per fresh backend, so CI drifted over the edge while locally-cached backends kept passing. Removed pure-JS zod/ai/yaml/@modelcontextprotocol/sdk from externalPackages (they bundle tree-shaken): fresh-backend push now totals 35.38 MiB (7.5 MiB headroom). Verified on a fresh scratch backend and by the green E2E round. Fixes Bug: latest main cannot boot on docker:dev — convex deploy fails ModulesTooLarge (42.97 MiB > 42.92 MiB cap), platform crash-loops #2579 (same cap breaks the docker:dev boot deploy; the vestigial canvas external — the dangling-symlink nit noted there — is dropped in ea42f6c51).
  • pdfjs on the modern build (3e9b56848, 5fd2a4155): the legacy build wove ~2 MB of core-js through the node bundle and mutated the shared node-executor's built-ins; four Buffer-backed ES2025 shims replace it (extraction suite red→green proves the swap).
  • sandbox-runtime image over budget (49777908f): Validate images has failed on main since the 2026-07-07 external-agent wave (Codex ~290 MB, OpenClaw ~170 MB, Pi ~80 MB; their PR Build runs were concurrency-cancelled, so it never surfaced pre-merge). Layer-diff of the last green vs first red manifest attributes the growth exactly; the installs are already cache-cleaned and platform-gated, so the budget moves to actual + ~10% (5400 MB).
  • 34a43fd6b commits the api.d.ts codegen that fix(platform): hide project-scoped files from the WebDAV tree #2559 landed without.

@larryro
larryro force-pushed the desk-workflow-simplify branch from 59fa637 to 3f1ca39 Compare July 8, 2026 01:32
larryro added 9 commits July 8, 2026 10:19
…ives

The desk-process graph carried 48 steps, most of them vocabulary
workarounds. Two small engine-level primitives remove the boilerplate:

- request_review takes an optional `round` folded into the approval's
  idempotency key, so ONE review-gate step serves every human round —
  v1 duplicated the whole gate (request/re_request + a pick chain) per
  round and structurally capped reviews at two.
- task update_status takes an optional `comment`, folding the six
  comment→status step pairs (rollbacks, parks, exhaustions) into one
  step each.

The workflow drops from 48 to 36 steps: one round-keyed plan-review
loop (bump → bound gate → request → decide), one shared Dream step fed
the judge verdict by template (was three near-identical variants), and
single-step parks/rollbacks whose status change carries the message.
All three loops share the maxReworkLoops cap. Agent METHOD text moves
out of step instructions into the agent configs (the implementer's
6.3k-char procedure becomes its systemInstructions; the reviewer's
setup line now honours the shared workspace instead of re-cloning) —
steps carry only per-run context.

One capture step survives by design: advise sits earlier in step order
than the review gate, and the definition validator forbids templating
a later step's output, so Request-changes feedback still travels via a
variable.
An expanded task row embeds the run view, whose tool timeline carries
long nowrap lines (truncated Bash commands, JSON error blobs). Under
the table's auto layout a nowrap line's min-content is its FULL length
— flex min-w-0 doesn't reach column sizing — so one long line stretched
the table past its container and clipped every card's right edge. Wrap
the expansion cell's content in w-0/min-w-full so it never feeds the
intrinsic measurement but still fills the row.
The stage breadcrumb and the run-view spine follow the step ARRAY
order, and the parks sat mid-flow — the header read work → deliver →
review and "Mark as In review" rendered between the plan review and
the implementer. Move every terminal park/rollback to the tail (the
validator only requires template refs to point backward, so the tail
is always legal): stages now read work → review → deliver and the
spine tells the story in order.
A conditional lane the gate skipped (a plan review the advisor never
flagged) sat at "Up next" forever while later steps visibly ran — a
lie about what's coming. A step with no node that some LATER-ordered
definition step has moved past is now pruned from the spine; a loop
that later actually runs it gives it a node and it reappears. Progress
is measured over the FULL definition order (hidden plumbing included),
so branch positions count.
The standalone composer workspace chip read as a duplicate entry for the
Workspace-files panel. The Sandbox pill now doubles as the thread's
sandbox-settings entry: clicking it opens a popover holding the working
directory (extensible with further per-thread sandbox settings later).
A custom workdir surfaces in the pill tooltip; before the thread exists
or while the composer is disabled the pill stays purely informational.
A workflow sandbox agent step whose session/container vanished out-of-band
mid-run (spawner zombie-eviction -> definitive 404) only escaped to the
engine retry on RESUME segments; a fresh segment's SessionNotFoundError
fell through to the terminal catch and was laundered into an
{ok:false, status:'failed'} business outcome that flowed downstream
(observed 2026-07-08: issue-desk dream step failed with
'session ... not found' while the next step proved the state recoverable
by re-creating against the preserved workspace).

Extract the catch's precedence into the pure, unit-tested
sandboxAgentThrowDisposition seam and classify SessionNotFoundError as
session-gone on every segment: drop the (possibly absent) checkpoint and
rethrow so the workflow step's retry restarts fresh.
The Sandbox pill never opened its settings: the popover trigger slots
its props onto the child via asChild, and the app Tooltip wrapper (a
plain function component) dropped them — clicking did nothing on any
thread. Recompose with raw tooltip primitives inside the popover
trigger (the user-button precedent), give the button a pointer cursor,
and gate Save on a dirty draft.

Pre-thread the pill now edits a workdir STAGED in the chat layout
context; useSendMessage applies it to the thread the first send
creates, ahead of the first turn — verified live: pwd on turn one
prints /user/workspace/<staged dir>.
@larryro
larryro force-pushed the desk-workflow-simplify branch from f3fdf22 to d2d3ffd Compare July 8, 2026 02:20
larryro added 6 commits July 8, 2026 10:46
… push

The self-hosted Convex backend caps a push at 45 MB zipped
(MAX_ZIPPED_PACKAGES_SIZE), counting bundled modules, component
packages, and the external-deps package it builds server-side from
npm. That last part re-resolves transitive versions on every fresh
backend, so CI (always a fresh backend) crept past the cap
(42.97 MiB > 42.92 MiB) and every Playwright platform shard failed
at the convex preflight while cached local backends kept passing.

zod, ai, yaml, and @modelcontextprotocol/sdk are pure JS and need no
external treatment (the isolate bundle already inlines them); shipping
their whole npm trees cost ~10 MiB zipped. Bundling them tree-shaken
brings a fresh push to 35.38 MiB, restoring ~7.5 MiB of headroom.
Native/asset-dependent packages (mssql, tedious, mysql2, pg, postgres,
jsdom, canvas) stay external.
documents/access and webdav/visibility landed in #2559 without the
regenerated _generated/api.d.ts.
The legacy pdfjs build exists for old runtimes: it weaves ~2 MB of
core-js through its dist files, and core-js mutates the built-ins of
the whole node-executor process that every 'use node' action shares.
The modern build drops that global pollution and ~0.4 MB of transpiled
weight from the push bundle.

On Node 22 (the floor across dev hosts, CI runners, and the upstream
convex-backend image) the modern build calls four ES2025 APIs that
only land natively in Node 24 — Promise.try (MessageHandler, every
worker message), Uint8Array.prototype.toHex (document fingerprints,
every getDocument), Uint8Array.fromBase64 and .toBase64 (XFA and
signature data). installPdfjsDomGlobals now shims them Buffer-backed
next to the existing DOMMatrix/ImageData/Path2D polyfills; the pdf
extraction suite fails without the shims (toHex) and passes with them.
The modern entries ship no declaration files, so pdfjs_worker.d.ts
redirects their types to the identical legacy declarations.
Nothing bundled imports canvas — it predates jsdom's externalization
(#1883), and the CLI never listed it in the uploaded nodeDependencies,
so the entry only made link-convex-externals link a package the
bundler never resolves.
oxlint --type-aware (the CI lint mode) rejects the
as-unknown-as-Record casts the shim installers used. A defineShim
helper with an 'in' guard and Object.defineProperty needs no
assertion, and its non-enumerable default matches the native
methods.
The 2026-07-07 external-agent wave (Codex ~290 MB single-platform
Rust binary, OpenClaw ~170 MB, Pi ~80 MB) grew amd64 from ~4.3 GB
to ~4.9 GB, and every Build run since fails 'Validate images'
(4878 MB > 4400 MB) — the agent PRs' own Build runs were
concurrency-cancelled, so the check never surfaced before merge.
Layer-by-layer manifest diff of the last green main build against
the first red one attributes the growth to exactly those three
installs; nothing else moved and the npm installs are already
cache-cleaned and platform-gated, so there is nothing to trim.
Re-budget to actual + ~10% headroom, per the file's convention.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: latest main cannot boot on docker:dev — convex deploy fails ModulesTooLarge (42.97 MiB > 42.92 MiB cap), platform crash-loops

1 participant