Repository navigation
feat(crawler): write a crawl lease (owner pid, host, heartbeat) for the whole command #946 - #1017
Merged
Merged
Conversation
7 tasks
|
Review of #1017 (crawl lease writer, schema 35). I read the diff and did not run the tests. The change is additive, nullable and write-only. The heartbeat runs on its own connection, the timer is unref'd, and release only clears rows this process still owns. The migration is mirrored in
Test coverage looks good: the writer, the migration, and the pid-scoped clear on the interrupt path are all tested. |
…he whole command #946 Signed-off-by: Nik Cubrilovic <[email protected]>
…ses live heartbeats #946 Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
feat/946-crawl-lease-write
branch
from
October 22, 2026 06:23
ff133bc to
1de729d
Compare
|
Reviewed the diff. The lease writer is write-only, additive and best-effort, and I found no blocking problems.
Nothing here needs to block merge. |
This was referenced Oct 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #946 (PR 1 of 2: lease WRITE only; no change to retirement or
self disk --prune).What
owner_pid,owner_host,heartbeat_atoncrawls, also on the crawls column reconcile list and in the fresh-db schema. Old rows and old CLIs are unaffected (NULL lease).startCrawlLease(packages/crawler): beats every 15 s on a SECOND connection withbusy_timeout1 s, skips a beat when busy, unref'd timer, re-asserts ownership each beat, release clears owner (only if still ours) and keeps the heartbeat. Polls every 1 s until the crawl row exists, so the first beat lands quickly.audit,crawlandanalyzehold it for the whole command (crawl,--resume, analyzed/building window) and release infinally. The signal handler (stopInterruptedCrawls) clears it too, sincefinallydoes not run there.kill -9leaves it, by design.storage/types.ts; stale and pid-trust are unused until PR 2.Tests
packages/crawler/tests/crawl-lease.test.ts(13): fresh db, v34-era db opens with no manual step and keeps rows, reconcile repairs a db stamped current without the columns, rollback (old-CLI-style insert/update on a db with the columns), lease written, heartbeat refreshes, waits for the crawl row, release clears/idempotent, cleared on the error path, release leaves another process's lease, signal-path clear, second-connection busy skip (about 1 s, no throw), no-op on:memory:/missing file (creates nothing).apps/cli/tests/audit/stop-interrupted-crawl.test.ts: lease dropped on the signal path, only this pid's.make validatein docs/ pass. tsgo clean in packages/crawler and apps/cli.Perf
1,000-page synthetic crawl written through
writeCrawlToStorage, bun 1.4.3, isolated dir, 7 runs each, median: no lease 2924 ms, 15 s heartbeat 2731 ms, 5 ms heartbeat (3,000x the design rate) 2960 ms. All within run-to-run noise (about 2.5 to 3.4 s). A realsquirrel crawlof 1,000 synthetic pages (isolated HOME) took 5.3 s, wrote the heartbeat and cleared the owner on exit.Not covered
Overlapping-audit, live/dead predicate and
self disklisting tests are PR 2 (nothing reads the lease here). Skill (squirrelscan/skills): no change needed.