Skip to content

fix: derive wake policy from pod shape - #963

Merged
lilyshen0722 merged 1 commit into
mainfrom
fix/task-004-wake-policy
Aug 17, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
fix/task-004-wake-policy

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Summary

  • resolve wake-on-message policy from a pod’s 1:1/shared shape at model install, signup, approval cloning, and fanout
  • make scheduler startup process-singleton to prevent duplicate cron sets
  • cover the three install paths, dynamic shared-room cutoff, and singleton behavior

Verification

  • npm test -- --runInBand __tests__/unit/services/wakePolicyService.test.js __tests__/unit/models/AgentInstallation.wakePolicy.test.js __tests__/unit/services/agentMentionService.wakeOnMessage.test.js __tests__/unit/controllers/authController.guideIdentity.test.js __tests__/unit/services/approvalActionService.test.js __tests__/unit/services/schedulerService.digestEmail.test.js (31 passed)
  • npm run tsc:check
  • Mutation checks: shared-member threshold, runtime fanout resolver, and singleton guard each red the relevant tests.

@lilyshen0722
lilyshen0722 merged commit e20db21 into main Aug 17, 2026
11 checks passed
@lilyshen0722
lilyshen0722 deleted the fix/task-004-wake-policy branch August 17, 2026 09:22
lilyshen0722 added a commit that referenced this pull request Aug 18, 2026
Ratified by Sam 2026-08-17. The status change is the point: ADR-018 sat at
Proposed while ADR-020 was Accepted, so #963's author reasonably followed the
ratified document and shipped a wake-policy regression that contradicted D8.

Ratifying without qualification would repeat that error one level down. This ADR
itself flags D4's 90s lease as a guess rather than a measurement, and leaves BYO
claim-compliance open. The status line now says so, so Accepted cannot be read as
having settled them.
lilyshen0722 added a commit that referenced this pull request Aug 18, 2026
#963's author did not ignore ADR-018 D8 — they never found it. They needed a rule
about pod shape and wake policy, went to the ADR that discusses pod shape, and D6
answered. Nothing in D6 said it governs the Guide's admin authority rather than
whether ordinary agents may speak.

Status was the second-order problem (ADR-018 sat Proposed, ADR-020 Accepted).
Discoverability was the first-order one: a cross-link here would have prevented the
regression regardless of either document's status.

Also records that D6's "1:1-shaped" counts humans, not members — the specific
misreading that shipped.
lilyshen0722 added a commit that referenced this pull request Aug 18, 2026
…968)

Ratified by Sam 2026-08-17. The status change is the point: ADR-018 sat at
Proposed while ADR-020 was Accepted, so #963's author reasonably followed the
ratified document and shipped a wake-policy regression that contradicted D8.

Ratifying without qualification would repeat that error one level down. This ADR
itself flags D4's 90s lease as a guess rather than a measurement, and leaves BYO
claim-compliance open. The status line now says so, so Accepted cannot be read as
having settled them.
lilyshen0722 added a commit that referenced this pull request Aug 18, 2026
… earned them (#969)

* docs(adr): mark ADR-020 D6's scope boundary and point at ADR-018 D8

#963's author did not ignore ADR-018 D8 — they never found it. They needed a rule
about pod shape and wake policy, went to the ADR that discusses pod shape, and D6
answered. Nothing in D6 said it governs the Guide's admin authority rather than
whether ordinary agents may speak.

Status was the second-order problem (ADR-018 sat Proposed, ADR-020 Accepted).
Discoverability was the first-order one: a cross-link here would have prevented the
regression regardless of either document's status.

Also records that D6's "1:1-shaped" counts humans, not members — the specific
misreading that shipped.

* docs: ADR status discipline — unratified loses to ratified, and cross-link adjacent scopes

Three rules earned from the 2026-08-17 wake-policy regression, written where an
implementer will actually read them rather than only in the ADRs they describe.

AGENTS.md is a symlink to this file, so both toolchains pick it up.
lilyshen0722 added a commit that referenced this pull request Aug 25, 2026
…species (#1205)

* docs(adr): ADR-018 D6.3 — a reply addresses its target regardless of species

D6.1 settled that targeting is respected and only broadcast gambles, but left
"what counts as targeting" to the implementation, which answered it with a
species gate: #703's implicit-reply path is gated on `sender.isBot === false`,
so a bot's reply to an agent never addresses that agent. Observed live on the
SEO squad 2026-08-24 — Sage stood down twice on Anvil's claim, from a thread
about Sage's own message.

Records Sam's ratified direction: a reply or quote addresses its target
whoever sent it, with anti-ping-pong moving to three bounded guards (wake
dampener, thread convergence, an exit-teaching frame). The principle the next
widening inherits: bound on evidence of a loop, never on who is speaking.

States plainly that this is less built than decided — the interim ship carries
per-target evidence on the existing message.posted fan-out and does not widen
ADDRESSED_EVENT_TYPES, and the convergence guard does not exist. Points the
interim code comment at the ADR rather than at a pod-local task id, and adds
the ADR-020 scope-boundary note that #963's regression earned.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs(adr-018): guard 2 is not merely unbuilt — it has no signal to count

D6.3 already records that the convergence guard is not implemented. What
it did not say is why, and the gap matters: the obvious implementation is
a countDocuments that always returns zero.

A total-match NO_REPLY takes the !sanitizedContent branch and persists no
message row, so "two consecutive silent turns" leaves nothing to count.
The only durable trace is a system_exchanges entry written solely in
agent-dm pods, which is the wrong population. And neither layer knows the
thread — postMessage never learns one, and AgentEvent has no thread
column, its payload being Mixed.

So a converged exchange is indistinguishable from one the instrument
cannot see, and guard 2 belongs in the ack path: a wake already knows its
thread at enqueue, and a seat that acks a thread-scoped wake and posts
nothing into that thread is the convergence event, keyed by (seat,
thread) where both are in hand.

Also records that guard 2 must state its own failure direction. Guard 1
fails open because dropping a genuine wake is the worse error; guard 2
failing open risks the unbounded reply chain the species gate existed to
prevent. Copying guard 1's shape would import an answer reasoned for a
different question.

Status line now names the two open items inside D6.3 — signal source and
threshold — so the ratified direction cannot be read as deciding them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs(adr-018): fix guard number in the D6.3 interim comment

The comment called convergence "D6.3's third guard"; the ADR it points at
calls it guard 2 throughout (1 = dampener, 2 = convergence, 3 = frame).
The comment's whole job is to route a reader to the right section before
they widen this path, so a wrong guard number defeats it.

Comment-only; zero non-comment lines changed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
samxu01 pushed a commit that referenced this pull request Sep 2, 2026
The PR arms are triggered by PR events, so a green freezes at the last
one. Two PRs that each passed when last run — one against a main holding
neither number, one before the other pushed its ADR file — can still
merge into a duplicate, and no PR-triggered check can see it happen.

This arm cannot prevent that either. It makes main say so within a
minute, instead of waiting for someone to read a directory listing,
which is how both known duplicates were actually found.

Reds main, deliberately: a duplicated number silently mis-routes every
citation of it, and #963 shipped a wake-policy regression because an
author followed the wrong member of the ADR-018 pair.

Also moves the concurrency group off the PR number, which is empty on a
push event and would put every main build in one group cancelling its
predecessor.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
lilyshen0722 added a commit that referenced this pull request Sep 2, 2026
* ci(adr): make a duplicate ADR number go red

An ADR number is a name two documents can claim at once, and every
mechanical check we own is blind to it. #1295 and #1268 both added
docs/adr/ADR-025-*.md under different slugs: different filenames, so no
textual conflict, merge-tree clean, all checks green — and main carried
two ADR-025s the moment the second merged. The same thing had already
happened at ADR-018, where the duplicate survived long enough that
#963's author followed the wrong one and shipped a wake-policy
regression.

Both were found by a human reading a directory listing.

Two checks, because the collision has two distinct lifetimes:

  1. Against main-as-it-is-right-now, unioned with this PR's own ADR
     adds/edits/deletes. Catches a PR claiming a number main already
     uses. Verified against #1295's head: exactly one error, ADR-025.

  2. Against the other OPEN PRs, which check 1 cannot see because
     neither tree contains the other's file — the state #1295 and #1268
     were in for days. Older PR keeps the number, newer renumbers, so
     it is always unilaterally fixable rather than a mutual deadlock.

Deliberately not the merge ref. refs/pull/1295/merge still contained the
duplicate ADR-018 an hour after #1463 renumbered it away, so a guard
reading that tree fails a PR for a collision somebody else already
fixed — worse than not running, because it teaches authors the check is
noise.

Deliberately not contiguity: main has no 029 and that is fine.

Both gh calls fail closed. An unchecked API error would produce an empty
ADR list, which reads as "this PR claims nothing" and passes — the guard
at its most reassuring exactly when blind.

Known limit: like every check here, this only runs on a PR event, so it
cannot see main moving underneath a PR that is not pushed to again. That
gap closes with strict: true on the branch protection, not in this file.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* ci(adr): add the main-side arm the PR arms structurally cannot cover

The PR arms are triggered by PR events, so a green freezes at the last
one. Two PRs that each passed when last run — one against a main holding
neither number, one before the other pushed its ADR file — can still
merge into a duplicate, and no PR-triggered check can see it happen.

This arm cannot prevent that either. It makes main say so within a
minute, instead of waiting for someone to read a directory listing,
which is how both known duplicates were actually found.

Reds main, deliberately: a duplicated number silently mis-routes every
citation of it, and #963 shipped a wake-policy regression because an
author followed the wrong member of the ADR-018 pair.

Also moves the concurrency group off the PR number, which is empty on a
push event and would put every main build in one group cancelling its
predecessor.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
samxu01 pushed a commit that referenced this pull request Oct 21, 2026
… human message (ADR-018 D8.1)

Sam's direction (2026-10-21, via Cofounder): "have the byo agent by default
wake on message instead of mention (the knob is always there still)". Until
now ambient wake was opt-in only, so a person who connected their own agent
and then talked to it got silence unless they typed its @name.

- wakeDefaultService.firstAgentWakeDefault: a new install of an agent a
  person brought from the Bring your own page (the own-agent seat:
  webhook, polling, host byo; or the computer placement: wrapper) defaults to
  wakeOnMessage {enabled, humanOnly}, unless another non-Scout agent in the pod
  already wakes on every message. Later agents stay mention-only. Not Scout,
  first-party apps, `agent attach`, or hosted (it can't take an ambient turn
  yet). An explicit wakeOnMessage in the request always wins.
- humanOnly (agentMentionService.humanOnlyWake): only a known human's message
  wakes such an install; agent-authored or unknown senders never do, so the
  default can't start agents answering each other. Explicit opt-ins carry no
  such flag and keep their delivery.
- boardWake.enabled false is written with the default, because an absent
  boardWake inherits wakeOnMessage and would otherwise also subscribe the
  agent to task-board wakes.
- The registry install route applies it best-effort, before the row is
  written. New installs only; nothing is migrated.
- ADR-018 D8.1, Accepted (ratified by Cofounder on Sam's direction), with a
  scope-boundary line to ADR-020 D6 / #963.

Read-only count, 2026-10-21: 76 pods hold an agent a person added; in 72 the
rule would have defaulted the first one on. None of them changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015eTFc9yqm2vKZiUyvLuBT4
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