Repository navigation
Phase 5: scheduled identifier sweep - #1636
neuromechanist merged 19 commits into
Conversation
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR1636Version: 🤖 Updated on each push. |
Review recordTwo independent reviews (Sonnet: Round 1: findings and disposition
Mutation check118 one-line mutants, each applied, run against its tests, and reverted with Round 2 (the fixes): findings and disposition
|
dae93c8
into
feature/issue-1610-epic-identifier-screening
Part of epic #1610. Closes #1615. Decision: ADR 0088. Design note: #1615 (comment)
Published datasets are screened again on a cycle, by the same workflow and report contract as a publication request (ADR 0086), and a weekly admin email says what was screened, what was not and why, and which datasets carry findings. The sweep reports and never repairs.
What changed
backend/src/services/identifier-sweep.ts: the tick, the store, the rescreen request and the weekly send. Production only, on the 30-minute tick. Each tick marks a screen pending past 50 minutesunreported, counts screens in flight (dispatches nothing when it cannot), resolves the credential before any claim (a Worker that cannot dispatch claims nothing), and dispatches at most 3, never more than 6 in flight, to the unchangedrun-identifier-screenworkflow with its own callback and token kind. A 4xx isdispatch-failed(a 401, 403 or 404 blocks the tick without counting against the dataset); a lost answer (10 s timeout, network, 5xx) stays pending with its nonce.xxid (anonymous deposits andonmirrors included). Due when there is no verdict on record, the verdict is older than 21 days, it was of an older version, or an admin asked; held back by a backoff that grows with failures in a row (6 to 96 hours). The cadence never depends on the verdict: the run list is public and names the dataset each screen reads.identifier_sweep_*keys insweep_stamps(no migration, no column). The verdict (written only from a parsed scan, credited to the version at dispatch, stored as a re-parsed projection) is kept apart from the attempt (state, error word, time, version, nonce, failures, request). A failure moves the attempt and never the verdict; an incomplete screen carries forward the strongest earlier finding unless it found as much itself.backend/src/services/identifier-sweep-report.ts(pure): a dataset counts as screened only when its verdict reads back, is at most 28 days old, is of the latest version and the scan read everything it can parse; everything else isuncheckedwith its reason. Every dataset whose last finding was a direct identifier is listed by id with kinds and counts, whatever its standing (aged out, superseded by an incomplete screen, or no longer readable); review follows, bounded. The words are the screen's (screenStateLabel,screenErrorText,kindsPhrase,SCREEN_NOT_READ, exported fromshared/identifier-screen-report.ts). Unknown renders asunknownand needs attention; work in progress does not; liveness tells idle from never and from "began after this week".identifier_sweep(opted in by default; the CLI knows it), once per ISO week by an atomic claim inaudit_logthat fails closed; a send refused outright is retried after a 120-minute lease without spending the 12-claim cap, while one that ended without an answer (it may have landed) counts.POST /webhooks/identifier-sweep-result(one-shot token of its own kind,request_idmust be 0, body bounded by a reader now shared with the publication callback, report only throughparseScreenReport, late reports accepted for 24 hours, answers without the verdict);GET /admin/identifier-sweep(the report on demand and the week's record, read-only);POST /admin/identifier-sweep/:id/rescreen(a D1 write the production tick answers).DEV_CRON_ALLOWLIST; both entry points refuse outside production on their own as well.no-report-in-time,dispatch-unconfigured).Tests
backend/test/identifier-sweep.test.ts(66): scope (malformedxx, anonymous deposit), slice, in-flight cap, fail-closed count, order, the dispatch and its token, the claim's own guard against a scope change and a racing tick, the store and every refusal, a hostile body (nothing of it reaches the row), unreported (NULL-safe), late reports and their bound, a replaced nonce, 4xx versus a lost answer, a hung dispatch, an unconfigured Worker and an unmintable App token (nothing claimed), the growing backoff, statement failures, non-object stamps, a future verdict time, the projection, a finding kept through incomplete screens, verdict-free cadence for every status, a refused credential (401) that claims nobody else, an attempt time in the future, a weaker incomplete finding that does not displace a stronger one, a finding carried as its status when its report no longer reads back, the 413 bounds, the rescreen, the mail category through the route, and a dev worker with candidates present (no dispatch, no mail, no write).backend/test/identifier-sweep-report.test.ts(42): window at ISO boundaries, standing, words, attention, liveness, derived counts, findings that stay listed, unknown never zero, the review bound, and the send: once a week, arrives when nothing is wrong, unknown records still mailed, a failed claim sends nothing, retry after the lease, sent stays sent, the cap and its exhaustion, an outage that does not burn the week, a delivered-but-unrecorded send, partial delivery, an uncountable queue, a redacted failure log, a send without an answer that counts toward the cap, a refused one that does not, a week not called exhausted while its last claim may still be sending, work owed versus due, a refused workflow that shows while verdicts are fresh, the category, the dev fence (includingDEV_ADMIN_NOTIFICATIONS=1).backend/test/identifier-sweep-d1.test.ts(6): the statements on Miniflare D1, including order and slice, the kept finding, the backoffCASE, the late bound, and the undelivered mark.test/identifier-sweep-cli.test.ts(3): the CLI shows, toggles and--all-disables the category.git statusclean: 116 killed at once; the two survivors (an idle check fed a fixture inside the window, a dispatch timeout nothing waited on) each got a test and are killed.bun run typecheck,bun run lint,biome checkon every changed file. Locally, the pure tier ran 9,907 tests with 6 timeouts in unrelated suites (aws CLI, shell completion, git-annex, the private-site RPC entry, Neurobagel writer and verify) on a machine at load average about 100; CI is the check for those.Rollout
The sweep needs ADR 0086's rollout first (the workflow merged in
nemarDatasets/.githuband the script on nemar-climain). Until then every attempt endsunreportedorworkflow-failed, the tick logs it at error level, and the weekly report says so. No on/off variable; to pause screens, disablerun-identifier-screen.yml.Not done here