Swarm fairness #213 follow-up: wire the yield signal into swarm.yml + mirror repo-wanted want-files in main.mts #216

Closed
opened 2026-10-15 03:43:40 +00:00 by matou-build-agent · 1 comment

Follow-up filed by the #213 swarm-fairness worker — the protected-path half of that ticket a sandcastle worker cannot land (CLAUDE.md blast-radius rule 9: .forgejo/ is protected, and main.mts's live mirror pairs with it).

Context

#213 landed the testable, root-file half of the swarm fairness work:

  • swarm-yield-lib.sh — the per-repo consecutive-swarm-yield counter + want-file path primitives (pure, offline-tested).
  • swarm-yield-signal.sh — the network signal: bump the counter, and at the threshold write this repo's want-file + comment once-per-episode on the oldest ready ticket + Mattermost line.
  • list-ready-tasks.sh — already honours a peer repo-wanted-<slug> in the host-signals dir by answering [] (frees the slot after the current ticket). Seam: SWARM_REPO_WANTED_DIR (default /run/host-signals).
  • run-swarm.sh — resets the counter + want-file on a real claim (worker confirmed born), and folds origin/main's head SHA into the debounce digest (fully live).

Two pieces need an interactive session's standing because they touch a protected / untested-core surface:

What this ticket must do

  1. .forgejo/workflows/swarm.yml (PROTECTED) — wire swarm-yield-signal.sh into the both-slots-busy yield site (the echo "swarm: both host capacity slots busy — yielding..."; exit 0 branch), exactly as triage.yml's yield_signal helper calls triage-yield-signal.sh from the prior checkout ($HOME/swarm/$REPO_SLUG/.sandcastle/swarm-yield-signal.sh, best-effort || true, never changing the yield's clean exit 0). Mirror triage.yml's yield_signal() shape. Also reset the drive-defer path as today; the new counter resets on a real claim in run-swarm.sh.
  2. main.mts — mirror every live host-side /tmp/matou-repo-wanted-* want-file (fresh, TTL like the drive reservation) into $HOST_SIGNALS_DIR/repo-wanted-<slug>, EXCLUDING this run's own slug, following the existing DRIVE_WANTED → DRIVE_SIGNAL poller (2s, TTL HOST_CAPACITY_DRIVE_WANTED_TTL). This is what populates the dir list-ready-tasks.sh already reads.

Acceptance

  • swarm.yml's both-slots-busy branch calls the signal best-effort before exit 0; a vendored re-render keeps the yield's clean-exit semantics.
  • main.mts mirrors live peer want-files into the sandbox signals dir and removes stale/own ones; the existing drive mirror is unchanged.
  • The root primitives from #213 are already tested; add any main.mts coverage the repo's harness allows.

Both reach the running self-copy and consumers only at the next re-vendor + FACTORY_REF bump (pull-only, GOTCHAS 4).

_Follow-up filed by the #213 swarm-fairness worker — the protected-path half of that ticket a sandcastle worker cannot land (CLAUDE.md blast-radius rule 9: `.forgejo/` is protected, and main.mts's live mirror pairs with it)._ ## Context #213 landed the testable, root-file half of the swarm fairness work: - `swarm-yield-lib.sh` — the per-repo consecutive-swarm-yield counter + want-file path primitives (pure, offline-tested). - `swarm-yield-signal.sh` — the network signal: bump the counter, and at the threshold write this repo's want-file + comment once-per-episode on the oldest ready ticket + Mattermost line. - `list-ready-tasks.sh` — already honours a peer `repo-wanted-<slug>` in the host-signals dir by answering `[]` (frees the slot after the current ticket). Seam: `SWARM_REPO_WANTED_DIR` (default `/run/host-signals`). - `run-swarm.sh` — resets the counter + want-file on a real claim (worker confirmed born), and folds `origin/main`'s head SHA into the debounce digest (fully live). Two pieces need an interactive session's standing because they touch a protected / untested-core surface: ## What this ticket must do 1. **`.forgejo/workflows/swarm.yml` (PROTECTED)** — wire `swarm-yield-signal.sh` into the both-slots-busy yield site (the `echo "swarm: both host capacity slots busy — yielding..."; exit 0` branch), exactly as `triage.yml`'s `yield_signal` helper calls `triage-yield-signal.sh` from the prior checkout (`$HOME/swarm/$REPO_SLUG/.sandcastle/swarm-yield-signal.sh`, best-effort `|| true`, never changing the yield's clean exit 0). Mirror triage.yml's `yield_signal()` shape. Also reset the drive-defer path as today; the new counter resets on a real claim in run-swarm.sh. 2. **`main.mts`** — mirror every live host-side `/tmp/matou-repo-wanted-*` want-file (fresh, TTL like the drive reservation) into `$HOST_SIGNALS_DIR/repo-wanted-<slug>`, EXCLUDING this run's own slug, following the existing `DRIVE_WANTED` → `DRIVE_SIGNAL` poller (2s, TTL `HOST_CAPACITY_DRIVE_WANTED_TTL`). This is what populates the dir `list-ready-tasks.sh` already reads. ## Acceptance - swarm.yml's both-slots-busy branch calls the signal best-effort before `exit 0`; a vendored re-render keeps the yield's clean-exit semantics. - main.mts mirrors live peer want-files into the sandbox signals dir and removes stale/own ones; the existing drive mirror is unchanged. - The root primitives from #213 are already tested; add any main.mts coverage the repo's harness allows. Both reach the running self-copy and consumers only at the next re-vendor + `FACTORY_REF` bump (pull-only, GOTCHAS 4).
Author
Member

Close report — #216 landed (commit 4771f92)

The #213 swarm-fairness follow-up's protected-path half is in. Both pieces reach the running self-copy and consumers only at the next re-vendor + FACTORY_REF bump (pull-only, GOTCHAS 4).

1. .forgejo/workflows/swarm.yml (PROTECTED) + its render source onboarding/templates/workflows/swarm.yml.tmpl. Added a yield_signal() helper — the swarm mirror of triage.yml's #110 yield_signal shape — pointing at $HOME/swarm/$REPO_SLUG/.sandcastle/swarm-yield-signal.sh (best-effort [ -f "$sig" ] && bash "$sig" "$1" || true), and wired yield_signal slots-busy into the both-slots-busy branch, on the line before the clean exit 0. The yield stays exit 0 (never camps, never reds the healer's if: failure()); the signal only fires the counter/want-file/comment when ready tickets exist. Template and rendered copy edited identically. The drive-defer path is unchanged (as the ticket required); the counter still resets on a real claim in run-swarm.sh (#213).

2. main.mts. Added a host-side peer-want mirror poller, modelled on the existing #111 DRIVE_WANTED → DRIVE_SIGNAL poller: every 2 s (and once synchronously at launch) it copies each fresh host-side /tmp/matou-repo-wanted-* want-file (freshness = mtime younger than the drive-reservation TTL HOST_CAPACITY_DRIVE_WANTED_TTL, default 900 s) into $HOST_SIGNALS_DIR/repo-wanted-<slug>, excluding this run's own slug (never yield to itself) and removing the mirror of any want-file that went stale or away. The slug→tag keying (/→-) and the repo-wanted-<tag> filename match swarm-yield-lib.sh:swarm_repo_wanted_path and the contract list-ready-tasks.sh (#213, seam SWARM_REPO_WANTED_DIR, default /run/host-signals) already reads. The existing drive mirror and the dir's other signals (drive-wanted, start-sha, run-landing) are left untouched — the reconcile only manages repo-wanted-*. New seam: HOST_CAPACITY_REPO_WANTED_DIR (default /tmp).

Acceptance

  • ✅ swarm.yml's both-slots-busy branch calls the signal best-effort before exit 0; the vendored re-render keeps the clean-exit semantics (template ⊆ rendered, pinned by self-workflows-drift-test.sh).
  • ✅ main.mts mirrors live peer want-files into the sandbox signals dir and removes stale/own ones; the drive mirror is unchanged.
  • ✅ Root #213 primitives already tested; coverage added where the harness allows (see below).

Proof

  • onboarding/tests/self-workflows-drift-test.sh — 10 passed (template ⊆ rendered for swarm/triage, + 2 new #213 assertions: swarm wires swarm-yield-signal.sh with yield_signal slots-busy before exit 0; triage still wires its own).
  • onboarding/tests/onboard-lib-test.sh — 271 passed (workflow render unaffected).
  • tests/swarm-yield-signal-test.sh (6), tests/list-ready-tasks-test.sh (35, incl. the peer-want → [] / own-want-surfaces contract this producer feeds), tests/triage-yield-signal-test.sh (6), tests/run-triage-test.sh (22), tests/run-swarm-drive-yield-test.sh (5), tests/run-swarm-stages-test.sh (12), tests/run-swarm-ready-list-test.sh (4), tests/swarm-lock-yield-test.sh (3), tests/docs-budget-test.sh (3), onboarding/tests/vendor-manifest-coverage-test.sh — all green.
  • main.mts type-strips cleanly under node --experimental-strip-types (only the expected runtime module-not-found for the uninstalled @ai-hero/sandcastle dev dep).

Note on main.mts coverage

main.mts cannot be imported/run in the offline bash suite — its first line imports @ai-hero/sandcastle, which is not installed on test hosts, and the whole suite is network/docker-free. The new mirror poller therefore follows the untested-but-precedented posture of its #111 drive-mirror sibling (also inline in main.mts, also with no standalone unit test): it is validated by its contract tests on both ends — the host-side want-file producer (swarm-yield-signal-test.sh) and the sandbox-side consumer (list-ready-tasks-test.sh, which already asserts a repo-wanted-<peer> file → [] and that an own want-file does not). Extracting the ~30 lines into a new vendored module purely to unit-test them would add a harness file reaching every consumer for no behavioural gain, so I judged it out of proportion. Filing no follow-up for this.

Pre-existing reds (not this ticket)

ci / test was already red on main before this commit: tests/limit-lib-test.sh and tests/claude-call-guards-test.sh fail in the #200 account-fingerprint / limit-park machinery (STATUS.md header documents the limit-lib-test fp-keying red and #225 uutils date). Neither test references any file this ticket touched; both still fail identically, unchanged by this work.

Ruled by agent under ADR 0174 — veto anytime. Two-way door throughout: revertible commit, proven by existing + extended offline tests; no secrets, no posture change, no one-way door.

## Close report — #216 landed (commit `4771f92`) The #213 swarm-fairness follow-up's protected-path half is in. Both pieces reach the running self-copy and consumers only at the next re-vendor + `FACTORY_REF` bump (pull-only, GOTCHAS 4). **1. `.forgejo/workflows/swarm.yml` (PROTECTED) + its render source `onboarding/templates/workflows/swarm.yml.tmpl`.** Added a `yield_signal()` helper — the swarm mirror of triage.yml's #110 `yield_signal` shape — pointing at `$HOME/swarm/$REPO_SLUG/.sandcastle/swarm-yield-signal.sh` (best-effort `[ -f "$sig" ] && bash "$sig" "$1" || true`), and wired `yield_signal slots-busy` into the both-slots-busy branch, on the line before the clean `exit 0`. The yield stays `exit 0` (never camps, never reds the healer's `if: failure()`); the signal only fires the counter/want-file/comment when ready tickets exist. Template and rendered copy edited identically. The drive-defer path is unchanged (as the ticket required); the counter still resets on a real claim in `run-swarm.sh` (#213). **2. `main.mts`.** Added a host-side peer-want mirror poller, modelled on the existing #111 `DRIVE_WANTED → DRIVE_SIGNAL` poller: every 2 s (and once synchronously at launch) it copies each **fresh** host-side `/tmp/matou-repo-wanted-*` want-file (freshness = mtime younger than the drive-reservation TTL `HOST_CAPACITY_DRIVE_WANTED_TTL`, default 900 s) into `$HOST_SIGNALS_DIR/repo-wanted-<slug>`, **excluding this run's own slug** (never yield to itself) and removing the mirror of any want-file that went stale or away. The slug→tag keying (`/`→`-`) and the `repo-wanted-<tag>` filename match `swarm-yield-lib.sh:swarm_repo_wanted_path` and the contract `list-ready-tasks.sh` (#213, seam `SWARM_REPO_WANTED_DIR`, default `/run/host-signals`) already reads. The existing drive mirror and the dir's other signals (`drive-wanted`, `start-sha`, `run-landing`) are left untouched — the reconcile only manages `repo-wanted-*`. New seam: `HOST_CAPACITY_REPO_WANTED_DIR` (default `/tmp`). ### Acceptance - ✅ swarm.yml's both-slots-busy branch calls the signal best-effort before `exit 0`; the vendored re-render keeps the clean-exit semantics (template ⊆ rendered, pinned by `self-workflows-drift-test.sh`). - ✅ main.mts mirrors live peer want-files into the sandbox signals dir and removes stale/own ones; the drive mirror is unchanged. - ✅ Root #213 primitives already tested; coverage added where the harness allows (see below). ### Proof - `onboarding/tests/self-workflows-drift-test.sh` — **10 passed** (template ⊆ rendered for swarm/triage, + 2 new #213 assertions: swarm wires `swarm-yield-signal.sh` with `yield_signal slots-busy` before `exit 0`; triage still wires its own). - `onboarding/tests/onboard-lib-test.sh` — 271 passed (workflow render unaffected). - `tests/swarm-yield-signal-test.sh` (6), `tests/list-ready-tasks-test.sh` (35, incl. the peer-want → `[]` / own-want-surfaces contract this producer feeds), `tests/triage-yield-signal-test.sh` (6), `tests/run-triage-test.sh` (22), `tests/run-swarm-drive-yield-test.sh` (5), `tests/run-swarm-stages-test.sh` (12), `tests/run-swarm-ready-list-test.sh` (4), `tests/swarm-lock-yield-test.sh` (3), `tests/docs-budget-test.sh` (3), `onboarding/tests/vendor-manifest-coverage-test.sh` — all green. - `main.mts` type-strips cleanly under `node --experimental-strip-types` (only the expected runtime module-not-found for the uninstalled `@ai-hero/sandcastle` dev dep). ### Note on main.mts coverage `main.mts` cannot be imported/run in the offline bash suite — its first line imports `@ai-hero/sandcastle`, which is not installed on test hosts, and the whole suite is network/docker-free. The new mirror poller therefore follows the **untested-but-precedented** posture of its #111 drive-mirror sibling (also inline in `main.mts`, also with no standalone unit test): it is validated by its contract tests on both ends — the host-side want-file producer (`swarm-yield-signal-test.sh`) and the sandbox-side consumer (`list-ready-tasks-test.sh`, which already asserts a `repo-wanted-<peer>` file → `[]` and that an own want-file does not). Extracting the ~30 lines into a new vendored module purely to unit-test them would add a harness file reaching every consumer for no behavioural gain, so I judged it out of proportion. Filing no follow-up for this. ### Pre-existing reds (not this ticket) `ci / test` was already red on `main` before this commit: `tests/limit-lib-test.sh` and `tests/claude-call-guards-test.sh` fail in the #200 account-fingerprint / limit-park machinery (STATUS.md header documents the `limit-lib-test` fp-keying red and #225 uutils `date`). Neither test references any file this ticket touched; both still fail identically, unchanged by this work. Ruled by agent under ADR 0174 — veto anytime. Two-way door throughout: revertible commit, proven by existing + extended offline tests; no secrets, no posture change, no one-way door.
matou-build-agent 2026-10-15 07:09:29 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/dev-factory#216
No description provided.