Skip to content

Phase 5: scheduled identifier sweep - #1636

Merged
neuromechanist merged 19 commits into
feature/issue-1610-epic-identifier-screeningfrom
feature/issue-1615-phase5-sweep
Oct 7, 2026
Merged

neuromechanist merged 19 commits into
feature/issue-1610-epic-identifier-screeningfrom
feature/issue-1615-phase5-sweep

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

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 minutes unreported, 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 unchanged run-identifier-screen workflow with its own callback and token kind. A 4xx is dispatch-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.
  • Candidates: active, public, not withdrawn, not a well-formed xx id (anonymous deposits and on mirrors 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.
  • Storage: twelve identifier_sweep_* keys in sweep_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 is unchecked with 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 from shared/identifier-screen-report.ts). Unknown renders as unknown and needs attention; work in progress does not; liveness tells idle from never and from "began after this week".
  • Weekly email under a new admin mail category identifier_sweep (opted in by default; the CLI knows it), once per ISO week by an atomic claim in audit_log that 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_id must be 0, body bounded by a reader now shared with the publication callback, report only through parseScreenReport, 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).
  • Wired inside the 30-minute tick's production guard; absent from DEV_CRON_ALLOWLIST; both entry points refuse outside production on their own as well.
  • ADR 0088 and its index line; ADR 0085's build table; a short amendment to ADR 0086 (a second caller). Two shared causes reworded (no-report-in-time, dispatch-unconfigured).

Tests

  • backend/test/identifier-sweep.test.ts (66): scope (malformed xx, 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 (including DEV_ADMIN_NOTIFICATIONS=1).
  • backend/test/identifier-sweep-d1.test.ts (6): the statements on Miniflare D1, including order and slice, the kept finding, the backoff CASE, the late bound, and the undelivered mark.
  • test/identifier-sweep-cli.test.ts (3): the CLI shows, toggles and --all-disables the category.
  • Existing pins updated: route inventories, the GitHub export surface, the cron wiring, email preferences, the screen's wording.
  • Mutation check: 118 one-line mutants across the tick, the store, the SQL, the report, the weekly send, the callback, the email and the CLI, each applied, run against its tests and reverted with git status clean: 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 check on 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/.github and the script on nemar-cli main). Until then every attempt ends unreported or workflow-failed, the tick logs it at error level, and the weekly report says so. No on/off variable; to pause screens, disable run-identifier-screen.yml.

Not done here

  • The systems inventory on docs.nemar.org does not yet list the new tick job, the mail category or the admin routes (private docs repo).
  • No bulk rescreen by standing (a burst in the public run list would name the datasets); the per-dataset route is the lever.

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR1636

Version: 0.10.13-PR1636.27a8a89
Commit: 27a8a89


🤖 Updated on each push.

@neuromechanist

Copy link
Copy Markdown
Contributor Author

Review record

Two independent reviews (Sonnet: pr-review-toolkit:code-reviewer and pr-review-toolkit:silent-failure-hunter) of the first eight commits, then a second silent-failure pass over the fixes. No critical findings in either round. Every finding was fixed except where noted as a design choice.

Round 1: findings and disposition

  • An incomplete re-screen retracted a standing finding: the finding is now carried forward (identifier_sweep_finding) and listed as found on its date until a complete screen or a newer finding replaces it.
  • A flagged dataset whose stored report stopped reading back vanished from the list: it is now named, with "kinds do not read back"; a report that is not an object also makes the dataset due.
  • A broken sweep logged at info: an unreported screen, a lost or refused dispatch, a lost claim, a blocked tick and a statement error now log at error level.
  • "Screens started" counted claims that never reached GitHub: the figure is now "dispatched" and excludes them; an unconfigured Worker no longer claims at all.
  • The CLI did not know the identifier_sweep category (--all false left it on): added to show, update --identifier-sweep, --all, the help and the type, with a CLI test and a route test.
  • not-screened and clean-edf-only-others-unscreened counted as screened without saying so, and "complete" meant only status !== unchecked: completeness is now scan.incomplete (whatever was found), and the report has a line for verdicts whose formats the scanner does not parse.
  • The 12-claim cap could burn the week on a mail outage: a claim that reached nobody is marked by row id and no longer counts; exhaustion is logged and GET /admin/identifier-sweep shows the week's record.
  • Non-object sweep_stamps made a claim report a write it never made: candidates, claims and rescreen requests refuse them, the report reads them as unreadable, and a future verdict time is unreadable and due.
  • The claim came before the credential: the credential is resolved once before any claim, and a Worker that cannot dispatch claims nothing.
  • No dispatch timeout, and an ambiguous failure dropped the nonce: 10 s timeout; a 4xx is dispatch-failed, a lost answer (timeout, network, 5xx) stays pending with its nonce.
  • A poison dataset was re-dispatched every 6 hours forever: the backoff grows with failures in a row (6, 6, 12, 24, 48, 96 hours), counted once per attempt and cleared by a verdict. A bulk "rescreen everything incomplete" lever was declined on purpose: a burst in the public run list would name those datasets; the per-dataset rescreen stays.
  • A lost claim was silent and the errors comment overclaimed: unclaimed counter, logged; comment corrected.
  • Partial delivery logged at info and the address leaked through the error message: logged at error, attempted recorded in the sent row, and the message redacted (test).
  • gatherIdentifierWeek could throw past its claim: the build is wrapped and falls back to unknown. No reachable throw source exists today, so this guard has no test.
  • Two causes overclaimed: no-report-in-time now says no report arrived (it may never have started); dispatch-unconfigured names a missing repository too. Shared with the publication screen, whose tests were updated.
  • A late report was accepted without limit: 24 hours from dispatch.
  • Test vacuity: the claim's own guard (scope change and a racing tick), dispatched on every failure, positive derived counts, the delivered-but-unrecorded branch, the failed failure record, the failed unreported pass, the failed candidate query, an App token that cannot be minted, a database error while storing (500, nonce kept, retry lands), partial delivery, an uncountable queue, verdict-free cadence for every status at 3, 20 and 22 days and in the order, the 413 bounds (now one shared reader for both screen callbacks), a malformed xx id, an anonymous deposit, unreported beside a standing verdict, an out-of-scope screen holding its slot, and the stored projection.
  • The first weekly report would have called the sweep idle: liveness distinguishes idle, never and "began after this week".
  • Anonymous deposits in scope: stated in the ADR and tested.
  • The full report was stored: a projection, parsed again before writing.
  • Prose: header, count everywhere, the ADR's "at least every 21 days" (now "comes due"), the two registerIdentifierSweepRoutes renamed apart, one -- removed.
  • Design choices kept (reviewers agreed): an unset ENVIRONMENT counts as production (the repo-wide isNonProductionEnv convention; the mail stays fenced on the literal); no cadence change for incomplete or flagged verdicts.

Mutation check

118 one-line mutants, each applied, run against its tests, and reverted with git status clean: 52 on the first implementation, 36 and 11 on the round-one fixes (including two cadence mutants that re-screen a flagged dataset sooner or hold it back, both killed), 19 on the round-two fixes. Two survived when first run (an idle check whose fixture sat inside the window; a dispatch timeout nothing waited on); each got a test, and both are killed.

Round 2 (the fixes): findings and disposition

  • An incomplete review displaced a complete direct-identifiers: carried findings are ranked; an incomplete screen carries the strongest earlier finding unless it found as much itself, and the report lists the stronger of the verdict and the carried finding.
  • A flagged verdict whose report no longer read back was erased by the next incomplete store, and a carried finding beside an unreadable verdict was not listed: the finding is carried as its status alone, listed beside an unreadable verdict, and a carried stamp that does not read back is still named (with the direct identifiers, conservatively).
  • A systemic dispatch failure read as "Nothing needs attention" while verdicts were fresh: a new "latest screen this week did not run or did not report" count over every dataset, with its own attention reason; liveness now reads work owed (due without the backoff), and the idle line says the sweep is "not running, or every dispatch is refused".
  • "Reached nobody" was not proven by zero deliveries: the sweep's mail now tells a refused send (a 4xx, or the dev fence) from one without an answer (15 s timeout, network, 5xx); only a send refused outright frees its claim from the cap.
  • A systemic 4xx burned the queue's backoff: 401, 403 and 404 close the one attempt without counting it and stop the tick (blocked).
  • The projection kept the unparsed-format map, whose keys are a pattern: dropped (with the manifest source); a carried finding's time is accepted only in the shape the sweep writes.
  • A future attempted_at held a dataset forever: it holds nothing back, and a pending one with it times out.
  • "Exhausted" could read true while the last claim was live: not while a claim is live.
  • Test gaps: no GitHub credential at all (blocked), and the claim-guard hooks now key on the exact claim statement.
  • Confirmed by the second reviewer with no action needed: no race between the prior read and the compare-and-set store; the generated statements run on local workerd D1 (CASE in a datetime modifier, json_type(col, path) IS NOT 'object', INSERT ... SELECT ... WHERE NOT EXISTS); no value reaches logs, mail or responses.

@neuromechanist
neuromechanist merged commit dae93c8 into feature/issue-1610-epic-identifier-screening Oct 7, 2026
13 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-1615-phase5-sweep branch October 7, 2026 10:31
@neuromechanist neuromechanist mentioned this pull request Oct 7, 2026
2 of 3 tasks

This branch was previously deployed

1 inactive deployment
npm — 27a8a899 Deployed Oct 7, 2026 by neuromechanist via publish #3152
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