Skip to content

fix(worker): dedupe artifact boot replay, incremental route trie - #203

Merged
07prajwal2000 merged 2 commits into
Fluxify-rest:mainfrom
07prajwal2000:fix/artifact-boot-trie
Aug 5, 2026
Merged

fix(worker): dedupe artifact boot replay, incremental route trie#203
07prajwal2000 merged 2 commits into
Fluxify-rest:mainfrom
07prajwal2000:fix/artifact-boot-trie

Conversation

@07prajwal2000

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes P1: artifact boot loads twice; every update rebuilds the whole route trie #191 — artifact boot replayed the initial snapshot twice, and every artifact update rebuilt the entire route trie from scratch.
  • watchArtifacts/watchProjectArtifacts now use a single NATS KV watch (includeExisting toggles LastValue vs UpdatesOnly) instead of a separate loadProjectArtifacts() snapshot read followed by a watch — no more double replay of the initial state.
  • compiledWorker.ts awaits the watch's initial replay before spawning the execution process, so it boots with a deduped snapshot exactly once.
  • HttpRouteParser gained upsertRoute/removeRoute for incremental trie insert/prune; compiledRuntime.ts uses these per-artifact instead of rebuildRoutes() on every update.
  • Removed listArtifacts() (natsKv.ts) — dead code left over from the old snapshot-read path, no remaining callers.

Test plan

  • bun test packages/lib/tests/parser.spec.ts — 4/4 pass, covers upsert/remove without disturbing unrelated routes
  • bun run --cwd apps/server lint (tsgo --noEmit) — clean
  • Manually traced trie prune logic for shared-prefix routes (e.g. /api/users + /api/users/:id) and shared-method branches — correct, only prunes branches left with no children
  • Verified KvWatchInclude.UpdatesOnly / LastValue against the installed nats package's type defs

🤖 Generated with Claude Code

Left over from the pre-fix double-load path (Fluxify-rest#191); watchArtifacts with
includeExisting now covers the initial snapshot, so nothing calls it.
@07prajwal2000
07prajwal2000 added this pull request to the merge queue Aug 5, 2026
Merged via the queue into Fluxify-rest:main with commit cf20829 Aug 5, 2026
11 checks passed
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.

P1: artifact boot loads twice; every update rebuilds the whole route trie

1 participant