Skip to content

App map: one build at a time per team, and a status the page can explain - #805

Closed
nambok wants to merge 2 commits into
mainfrom
app-map-clear
Closed

nambok wants to merge 2 commits into
mainfrom
app-map-clear

Conversation

@nambok

@nambok nambok commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Pressing "Build the map again" several times in a few seconds queued one build per press, and the worker ran each of them. Nothing deduped: the rebuild route wrote the build status with no condition and the worker never checked. Now one build runs per team, and the status tells the page enough to show the steps, the time and the last build plainly (dashboard #470).

Changes

  • common::app_map. The build status carries a build id, the worker's turn, when the build started, its stage (reading, parts, describing, done), the repositories it reads, and when the current map was built and from how many. Every write is a versioned conditional put, retried on a lost race; the decisions are pure functions: queue_next refuses while a build is queued or running (unless stuck past STALE_SECS), take_turn lets each message of a build run once (a duplicate, or another build's message, is skipped; the same message delivered again after its worker went quiet past LEASE_SECS may retake it), and progress / finished / failed only touch the build that is running. estimate_secs gives a usual range from the repository count.
  • Gateway. POST /api/app-map/rebuild answers 409 already_building with the running build's status and sends nothing; 202 with the new status otherwise. GET /api/app-map adds started_at, stage, last_build, repos, estimate, built_at, built_repos and the server clock (built date falls back to the map object's date, repositories to the map's own list), and graph=0 returns the status only, for a page watching a build.
  • Worker. Each message takes its turn before doing anything and skips when it isn't the build's next. Steps report their stage in plain words. Messages carry the build id and turn (contract JSON updated); after_push follows the same one-build rule.
  • AWS stand-in (tests only): records SQS messages and answers S3 reads as not found.
  • selfhost/versions.json: the dashboard pinned to dashboard Pin the dashboard with forgot-password outcomes and the People set-up banner #470's merge commit.

Verification

  • cargo fmt --all --check, rustfmt --check --edition 2021 worker/src/passes/incidents/*.rs, cargo clippy --workspace --all-targets -- -D warnings: clean.
  • cargo test --workspace: gateway 1274, worker 2377, common 2930 passed, 0 failed.
  • New: a_second_build_is_refused_while_one_is_queued_or_running runs the real rebuild handler against the stand-in: three presses give 202, 409, 409 and exactly one SQS message (on main each press queues one), the worker takes the start turn once and skips its duplicate and another build's message, a finished build lets a new one start, and another team is independent. presses_at_the_same_moment_still_start_one_build: six concurrent presses, one 202, one message. Worker a_duplicate_message_for_a_build_already_running_is_skipped, common one_build_at_a_time, each_message_takes_its_own_turn_once, the_estimate_grows_with_the_repositories, gateway the_status_says_when_it_started_....

The App map's "Build the map again" pressed three times in nine seconds
queued three builds and the worker ran all three: the rebuild route wrote
the status with no condition (force) and the worker never checked.

- common::app_map: the build status carries a build id, the turn the
  worker is on, when the build started, its stage (reading, parts,
  describing, done), the repositories it reads, and when the current
  map was built from how many. Every write is versioned (a conditional
  put on v), and the decisions are pure: queue_next refuses while a
  build is queued or running (unless stuck past STALE_SECS); take_turn
  lets each message of a build run once (a duplicate, or another
  build's message, is skipped; the same message again after its worker
  went quiet past LEASE_SECS may retake it); progress/finished/failed
  only touch the build that is running. estimate_secs gives a usual
  range from the repository count.
- Gateway: POST /api/app-map/rebuild answers 409 already_building with
  the running build's status and sends nothing; 202 with the new
  status otherwise. GET /api/app-map returns started_at, stage,
  last_build, repos, estimate, built_at, built_repos and the server
  clock; graph=0 returns the status only (a HEAD for the map's date).
- Worker: each message takes its turn first and skips when it isn't
  the build's next; steps report their stage; messages carry the build
  id and turn; after_push uses the same one-build rule.
- Tests: three presses queue one build and send one message (fails on
  main: each press queued one), six concurrent presses start one,
  the worker skips a duplicate start and step, status_view, estimate.
  The AWS stand-in now records SQS messages and answers S3 reads.
nambok added a commit that referenced this pull request Nov 23, 2026
…he overlays (#809)

* App map: one build at a time per team, and a status the page can explain

The App map's "Build the map again" pressed three times in nine seconds
queued three builds and the worker ran all three: the rebuild route wrote
the status with no condition (force) and the worker never checked.

- common::app_map: the build status carries a build id, the turn the
  worker is on, when the build started, its stage (reading, parts,
  describing, done), the repositories it reads, and when the current
  map was built from how many. Every write is versioned (a conditional
  put on v), and the decisions are pure: queue_next refuses while a
  build is queued or running (unless stuck past STALE_SECS); take_turn
  lets each message of a build run once (a duplicate, or another
  build's message, is skipped; the same message again after its worker
  went quiet past LEASE_SECS may retake it); progress/finished/failed
  only touch the build that is running. estimate_secs gives a usual
  range from the repository count.
- Gateway: POST /api/app-map/rebuild answers 409 already_building with
  the running build's status and sends nothing; 202 with the new
  status otherwise. GET /api/app-map returns started_at, stage,
  last_build, repos, estimate, built_at, built_repos and the server
  clock; graph=0 returns the status only (a HEAD for the map's date).
- Worker: each message takes its turn first and skips when it isn't
  the build's next; steps report their stage; messages carry the build
  id and turn; after_push uses the same one-build rule.
- Tests: three presses queue one build and send one message (fails on
  main: each press queued one), six concurrent presses start one,
  the worker skips a duplicate start and step, status_view, estimate.
  The AWS stand-in now records SQS messages and answers S3 reads.

* Pin the dashboard to the App map menu, build and layout release (dashboard #470)

* App map: the page reads the map from the bucket; the API sends only the overlays

- The worker writes the page's copy (view.json.gz, Content-Encoding gzip)
  and a small index (index.json.gz, common::app_map::MapIndex) with each
  map; a map built before them gets them on its first read.
- GET /api/app-map never reads or sends the whole map: the status, a
  15-minute signed GET for the copy (graph_url), the same bytes through
  GET /api/app-map/graph for a browser that can't reach the bucket, and
  Recent work and Health placed with the index (overlays).
- Overlays place files by lookup in the index, not by scanning the map's
  files for each one (map_path rebuilt a 3,800-entry set per file).
- Plans' why read eight at a time, for runs on the map only; Health's
  four sources read at once.
- Data bucket CORS allows GET and HEAD from the dashboard's origins.
- Includes #805 (one build at a time) merged with main.
- Tests: index round trip and equivalence with the old overlays, a page
  view on a 4,000-file map (common bench and through the handler), the
  AWS stand-in keeps S3 objects.

* Pin the dashboard to the App map loading, full screen and title release (dashboard #473)
@nambok nambok closed this Nov 23, 2026
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