Skip to content

feat: run crawl and discovery as worker tasks from private locations - #633

Merged
fclairamb merged 73 commits into
mainfrom
feat/agent-worker-tasks
Oct 22, 2026
Merged

fclairamb merged 73 commits into
mainfrom
feat/agent-worker-tasks

Conversation

@fclairamb

Copy link
Copy Markdown
Owner

Runs crawl and network discovery as resumable worker tasks, so both work from private locations (org agents).

What changes

  • New worker_tasks table and workertasks service: claim, heartbeat, step, finish, fail, cancel, with fencing on the worker and a live lease. Signed agent routes under /api/v1/agent/tasks/ (410 TASK_GONE, 413 over 1 MiB, system agents refused).
  • Crawl moved onto worker tasks and allowed from private locations. ${param:} is resolved server-side for cloud workers only, never sent to agents. ${env:} is resolved by the worker against its allowlist.
  • Network discovery can run from a private location: agent opt-in with SP_AGENT_DISCOVERY_ENABLED and SP_AGENT_DISCOVERY_CIDRS. The server revalidates the facts and recomputes the suggestions. Audit events discovery.scan_started, scan_canceled, chunk_refused.
  • Region-bound scans require an admin membership row. The scans route joins the impersonation-forbidden routes.
  • New entitlement discovery_agent_addresses_per_day (SaaS 65 536, unlimited self-hosted), 422 DISCOVERY_QUOTA_EXCEEDED at scan start. The quota is summed in SQL and the start is atomic (advisory lock 0x50020002).
  • dash0: discovery form picks a private location, docs updated.
  • Migration in the untagged 030_v0_41_0.

Behavior changes

  • PrepareClaim signature changes.
  • GET /checks/{uid}/run: runUid is now the task uid.
  • A crawl using ${param:} on a private location always ends in error.
  • Editing a crawl config restarts it immediately. Crawls in flight during the upgrade restart from scratch.
  • One scan at a time per org, whatever its type.

Checks

  • make build-backend lint-back test test-postgres: green (265 packages).
  • dash0 typecheck:e2e, lint:e2e: green.
  • Full Playwright on a side-car: 972 passed, 0 failed, 15 skipped.
  • make build-docs still fails on the generated /docs/api/tools page, as on main before.

🤖 Generated with Claude Code

fclairamb and others added 30 commits October 22, 2026 00:04
Audit of issue 587 against HEAD: outputSchema and annotations.title were
already present on every tool; only inputSchema.additionalProperties was
missing. Set it to false in objectSchema (advertised only, handlers stay
lenient). Added a contract test over every registered tool.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The test queried real DNS; CI's stub resolver returned an unparseable TXT reply.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Two causes of the flaky 'canvas charts appear in the capture' test, both
reproduced on a side-car (3 of 225 failures at 24 workers):
- feedback:open was dispatched once after networkidle, before the listener
  (registered only when bugReport.enabled is applied) existed. Every call
  site now waits for the feedback-button first, through openFeedback().
- the dialog opens after the html-to-image capture, 1.5 to 6.5 s under
  load, past the 5 s expect timeout. The dialog wait is now bound to the
  capture (30 s); assertions are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…billing

UpgradeURL now returns <base>/d/orgs/<org>/upgrade when an upgrade template
is configured. The new dash0 page forwards admins to the signed billing URL
at click time.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…atform, never to billing

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
check-publication-hint.spec.ts was flaky for two reasons, both older than
the batch (no change to these files since 90f70c2):

- Sonner's top-positioned toast enters from translateY(-100%) and leaves
  back up the same way. With the toaster offset at 144px, a 53px toast
  started at y=91 and slid over the header's Edit and more-actions buttons
  (y 72..108) for its first frames. The test sampled the box right after
  toBeVisible and caught it mid-slide under load. Toasts at the top now
  fade in and out in place (index.css), so they never pass over the header.
- The post-create publication hint lists the org's status pages, then GETs
  each one. A page deleted in between (another operator, or a parallel E2E
  worker's cleanup) 404'd, Promise.all rejected and the hint rendered
  nothing. A 404 page is now skipped; other errors still fail the lookup.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adds discovered_checks.region (NOT NULL, '' = server) to the upsert identity,
OwnsPrivateRegion, 422 DISCOVERY_REGION_UNAVAILABLE on promote, region-scoped
dismiss-group. Appended to the untagged 030_v0_41_0 migration.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…nprivileged socket

Scan and ScanHosts now return a ScanResult carrying ICMPAvailable.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…tate topic

Appends the worker-tasks section to the untagged 030 migration (both
engines), adds the WorkerTask model, extracts the agent attachment
authentication into handlers/agentauth, and adds tasks/<uid>/step-state
(keep 2) to the attachment rail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claim takes the oldest eligible row of the worker's exact region (and the
agent's org) in one statement (FOR UPDATE SKIP LOCKED on Postgres), under
a slot limit. Heartbeat, Step, Finish and FailSlice are fenced on the
lease. State is held server side on the attachment rail. Tested on both
engines with a test-only kind.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fclairamb and others added 20 commits October 22, 2026 09:33
SP_AGENT_DISCOVERY_ENABLED and SP_AGENT_DISCOVERY_CIDRS (spec 2026-10-22-04).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The discovery capability and audit event types, HasLiveAgentWith on the
regions service, the discovery_agent_addresses_per_day entitlement
(maxDiscoveryAgentAddressesPerDay, SaaS 65536, self-hosted unlimited, demo 0),
and the Scan SkipSuggestions option (spec 2026-10-22-04).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The agent executor checks each chunk against its operator's allow-list and
egress guard and reports raw facts; the server kind filters them against the
chunk, rebuilds the suggestions, caps the org inventory at 20000 and audits
refusals once per scan and agent (spec 2026-10-22-04).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
POST /discovery/scans takes a top-level region (lan only). A region-bound scan
needs an admin membership row (no super-admin bypass, no impersonation), one
of the org's private regions with a live agent reporting discovery, and room
in the daily agent address quota; it skips the server egress refusal and
enqueues network_discovery_agent_plan. Progress, cancel and the already-running
guard read its worker tasks; scans are audited (spec 2026-10-22-04).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
TestRegionListResponseCapabilityShape predated crawl (22-03) and discovery
(22-04) on the published capability map.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… region's agent

go build ./..., golangci-lint (new from 975e5e8, whole files): 0 issues,
go test -short ./... green, Postgres tests of discoverytask, workertasks and
discovery green.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The daily agent address quota is now summed in SQL from today's
network_discovery_agent_plan jobs of the org (their config records
addressCount), canceled plans included, retry clones excluded. It no
longer reads discovery.scan_started audit events, which other scan types
also write and whose write can fail silently.

Guard, quota and job insert run in one transaction
(jobsvc.CreateJobAdmitted) under a per-org advisory transaction lock on
Postgres (dblock.ClassDiscoveryScanStart) and SQLite's single connection,
so two concurrent starts can no longer both pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Region picker on the new-scan form, region and failed-chunk lines on the scan page, discovery badge on private locations, event labels, 4 locales, user docs and wiki.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…y can run from a private location

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… can run from a private location

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.59390% with 232 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@abf3a68). Learn more about missing BASE report.

Files with missing lines Patch % Lines
server/internal/workertasks/service.go 87.97% 47 Missing ⚠️
server/internal/crawltask/server.go 85.55% 38 Missing ⚠️
server/internal/crawltask/executor.go 84.95% 17 Missing ⚠️
server/internal/discoverytask/server.go 89.05% 15 Missing ⚠️
server/internal/checkworker/backend/ws_tasks.go 79.71% 14 Missing ⚠️
server/internal/checkworker/tasks/loop.go 87.25% 13 Missing ⚠️
server/internal/handlers/discovery/service.go 92.21% 13 Missing ⚠️
server/internal/handlers/agenttasks/handler.go 89.10% 11 Missing ⚠️
server/internal/discoverytask/executor.go 92.47% 7 Missing ⚠️
.../jobs/jobtypes/job_network_discovery_agent_plan.go 81.57% 7 Missing ⚠️
... and 18 more
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #633   +/-   ##
=======================================
  Coverage        ?   83.67%           
=======================================
  Files           ?     1267           
  Lines           ?   129598           
  Branches        ?        0           
=======================================
  Hits            ?   108445           
  Misses          ?    21144           
  Partials        ?        9           
Files with missing lines Coverage Δ
server/internal/app/server.go 81.96% <100.00%> (ø)
server/internal/app/services/services.go 100.00% <ø> (ø)
...erver/internal/checkworker/backend/capabilities.go 100.00% <100.00%> (ø)
server/internal/checkworker/backend/direct.go 85.51% <100.00%> (ø)
server/internal/checkworker/backend/ws.go 80.87% <ø> (ø)
server/internal/checkworker/checkjobsvc/service.go 86.73% <100.00%> (ø)
...rver/internal/checkworker/scheduling/scheduling.go 96.87% <100.00%> (ø)
server/internal/checkworker/tasks/tasks.go 100.00% <100.00%> (ø)
server/internal/config/agent_discovery.go 100.00% <100.00%> (ø)
server/internal/config/config.go 93.70% <100.00%> (ø)
... and 60 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The positive control relied on a real ICMP reply from 127.0.0.1: CI runners
cannot open an ICMP socket and the random test port matches no default port,
so the default scan built no suggestion there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@fclairamb
fclairamb merged commit 062fd99 into main Oct 22, 2026
33 checks passed
@fclairamb
fclairamb deleted the feat/agent-worker-tasks branch October 22, 2026 12:08
fclairamb added a commit that referenced this pull request Oct 22, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.41.0](v0.40.1...v0.41.0)
(2026-10-22)


### Features

* **email:** calmer emails that say why a check is down
([#623](#623))
([8dd68d3](8dd68d3))
* run crawl and discovery as worker tasks from private locations
([#633](#633))
([062fd99](062fd99))


### Bug Fixes

* **aichecks:** hold AI runs with real secrets to a runtime host
allowlist ([#631](#631))
([c09fdd1](c09fdd1))
* **checkdns:** stub the resolver in TestDNSChecker_Execute
([#630](#630))
([cca1d88](cca1d88))
* **dash0:** drag-to-zoom on the Timing chart
([#617](#617))
([931816c](931816c))
* **deps:** update github.com/dop251/goja digest to 07c4b9d
([#637](#637))
([0170643](0170643))
* **deps:** update github.com/dop251/goja digest to 64adc8b
([#626](#626))
([1efd502](1efd502))
* **deps:** update github.com/dop251/goja digest to 7b1a022
([#619](#619))
([d3adde9](d3adde9))
* **deps:** update go dependencies (non-major)
([#622](#622))
([adb622c](adb622c))
* **deps:** update go dependencies (non-major)
([#627](#627))
([dee2fd0](dee2fd0))
* **deps:** update go dependencies (non-major)
([#635](#635))
([da717a5](da717a5))
* **deps:** update module github.com/a2aproject/a2a-go/v2 to v2.7.0
([#625](#625))
([bb8c7ae](bb8c7ae))
* **deps:** update module github.com/anthropics/anthropic-sdk-go to v2
([#628](#628))
([90f70c2](90f70c2))
* **deps:** update module github.com/fergusstrange/embedded-postgres to
v2 ([#614](#614))
([913ece9](913ece9))
* **email:** usage-cap email links to the platform upgrade page, not
billing ([#632](#632))
([abf3a68](abf3a68))
* **status-pages:** close a grouped check's entry when it recovers
([#615](#615))
([d4d9b21](d4d9b21))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant