Skip to content

refactor(gateway): split the gateway core, api and linked computers - #51

Merged
nixuuu merged 13 commits into
devfrom
refactor/split-area-a
Nov 4, 2026
Merged

nixuuu merged 13 commits into
devfrom
refactor/split-area-a

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 4, 2026

Copy link
Copy Markdown
Member

Code-quality phase 3, area A (docs/code-quality.md): apps/gateway except store/bots/connectors. All 22 size findings in 13 files → 0 (lint on the area: 0 diagnostics, all rules); 76 modules extracted, behaviour-preserving moves, original exports and import paths kept, no size suppressions.

File (apps/gateway/src/) Code lines before → after
core/core.ts 2644 → 262
computers/runtime.ts 1264 → 146
computers/agents.ts 1091 → 51
computers/shared.ts 939 → 30
computers/moves.ts 838 → 28
computers/move-state.ts 793 → 210
api/routed.ts 678 → 190
api/ui-service.ts 453 → 35
core/agent-bus.ts, core/cli-tools.ts, core/worker-ssh.ts, computers/remote.ts, computers/mirror.ts split / functions shortened

Checks: install, gen:check, typecheck, format:check, web build; linked-computer/queue integration files ×5 (475 pass); two full check:tmp runs 830 pass / 0 fail.

@nixuuu
nixuuu merged commit a04c310 into dev Nov 4, 2026
2 checks passed
@nixuuu
nixuuu deleted the refactor/split-area-a branch November 4, 2026 11:54
nixuuu added a commit that referenced this pull request Nov 13, 2026
Isolate event persistence per thread, resolve archived and deleted backlogs durably, and retain legacy delivery until the gateway is upgraded. Add redacted ingest diagnostics and recovery coverage.

Related: #51
nixuuu added a commit that referenced this pull request Nov 13, 2026
Isolate event persistence per thread, resolve archived and deleted backlogs durably, and retain legacy delivery until the gateway is upgraded. Add redacted ingest diagnostics and recovery coverage.

Related: #51
nixuuu added a commit that referenced this pull request Nov 13, 2026
Isolate event persistence per thread, resolve archived and deleted backlogs durably, and retain legacy delivery until the gateway is upgraded. Add redacted ingest diagnostics and recovery coverage.

Related: #51
nixuuu added a commit that referenced this pull request Nov 13, 2026
Isolate event persistence per thread, resolve archived and deleted backlogs durably, and retain legacy delivery until the gateway is upgraded. Add redacted ingest diagnostics and recovery coverage.

Related: #51
nixuuu added a commit that referenced this pull request Nov 13, 2026
…620)

A background task can outlive its thread's archive. When Claude reports
its completion by starting a native follow-up turn, the visibility
trigger rejects it. The previous ingest drain disconnected the entire
worker every 11 seconds and interrupted unrelated running turns.

Archived threads now retain late output for existing turns and
background-task state, while completion notes are durably cancelled in
the task-end transaction. Background processes keep running; neither the
platform note nor a native Claude follow-up starts a new turn after
archive. Unarchiving shows the completed task without replaying its
continuation. An additive lifecycle snapshot/live message tells capable
workers to suppress native wakes and stale StartTurn commands; snapshot
ordering preserves newer lifecycle updates.

Gateway ingest resolves older journals automatically: unknown archived
turns become durable quarantine notices; deleted threads receive only an
ACK cursor, without retaining new payload/history/quarantine or
resurrecting the thread. Other storage failures retry per thread with
backoff, then quarantine the original event. An unavailable durable
fallback retains the worker journal without draining the connection.

WorkerLink protocol remains 1. Old workers recover against the new
gateway. New workers encountering an old gateway's ingest drain durably
defer all then-unacknowledged journals (the old message identifies no
offending thread) and resume them when the gateway is upgraded.
Diagnostics recognize failed, dropped, quarantined and deferred ingest
templates, redact thread/worker IDs and payloads, and expose aggregate
counters. Polish execution, lifecycle, durability, protocol and
diagnostics documentation describes the policy.

Validation:
- All CI checks passed for aa005da:
static checks, all four test shards (each through check:tmp), web/Linux
builds and aggregate validation.
- Local install, gen:check, typecheck, lint, format:check and web build
passed with nice.
- Real Claude SDK adapter + SQLite + gRPC: background app server →
archive → offline completion/native wake → reconnect; no new turn/drain,
unrelated turn survives and finishes, unarchive does not wake the task.
Final-head check:tmp: 1 test / 13 assertions passed, temp directory
empty.
- Old-protocol completion/follow-up replay, archive/delete recovery,
lost ACKs, gateway/journal restarts, transient retry exhaustion and
successful-event ordering: 5 tests / 66 assertions passed locally.
Legacy-gateway recovery, existing event-storage regressions and
log-export security tests also passed.
- Local full-suite limitation: the first sequential run failed two
bot-files assertions and a bot-handoff timeout under heavy shared-host
load; those complete files then passed separately (9/83 and 10/91) and
in the second full run. The second full run reached 504 passing tests
before computer-moves reported “Laptop C is unreachable” (run 3/20);
--bail also bypassed global temp cleanup, so that local full check was
not clean. No unrelated production code or test deadlines were changed.
The complete CI suite and its temp-directory gates are green.

Copy audit (§8): adds sentence-case diagnostic labels (“Event storage
failures”, “Events dropped after deletion”, “Events quarantined”,
“Journals deferred until gateway update”) and the plain timeline notice
“Automatic follow-up skipped because this thread is archived or
deleted.” The notice explains why work did not start and contains no
user content or identifiers. No controls/layout changed; no browser
verification was performed.

Related: #51
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.

1 participant