Change Propagation
In real work, plans change mid-flight. You tell the lead agent, "Actually, keep it in one repository for this release." It replies that it understands — while two parallel workers keep executing the old instructions and an earlier reviewer's approval quietly stays green.
Change Propagation makes mid-flight revisions reach every piece of active work without throwing away what is still valid. Because every job records the version of the request spec it started from, saving a new version lets the hub list every stale job, wait, and finding so the lead agent can decide stop, redo, or keep on each one — and show the requester one clear list to accept or overrule.
Change, Impact item
Why telling one agent doesn't change the team
When a request is split across parallel workers and independent checkers — whether drafting a multi-region launch brief, running an operational migration, or refactoring a codebase — a correction sent to the lead agent lives in only one conversation. Workers executing bounded briefs in isolated sessions never hear it, and findings already recorded against version 1 still look valid on the board.
The opposite extreme — blindly canceling every running job whenever anything changes — is nearly as costly. Half of the parallel work is often unaffected by the revision; wiping it out wastes hours of completed progress just to play it safe.
Change Propagation solves both failure modes with three hub-enforced rules:
- Every job is stamped with its spec version. When a new Request Spec version is saved, the hub mechanically finds every non-canceled job, active wait, and non-void finding tied to an older version.
-
Selective triage instead of blind cancellation. The lead agent decides
stop,redo, orkeepon eachImpact itemwith a plain-English reason, and the requester can overrule any line while the change is open. -
Confirmed execution, not wishful messaging. A change cannot close until
every impact item has an
applied_atconfirmation (or a forced attempt stop after deadline) and the decision list has been reported to the requester.
Why split discovery (hub) from triage (lead agent)? Completeness is
mechanical: a database query over request_spec_id never
forgets a running worker or an earlier approval. Judgment is contextual: only the lead agent
(and the requester, if overruling) can tell whether a build cache or research section still
holds under version 2.
Architecture and participants
Change Propagation adds two records to the hub — Change and
Impact item — that tie together six records defined
elsewhere in the catalog: Request and
Party
(Orchestrator-Workers),
Request spec (Request Spec),
Job (Durable Job),
Wait (Resumable Wait),
and Finding (Policy Gate).
Request spec
version, opens the Change, and decides
stop, redo, or
keep with a reason for each impact item.
Change links the old spec version to the new one (or
NULL on full cancellation). Each
Impact item tracks one affected job, wait, or finding
through decision and confirmation.
Execution flow
Toggle between the normal flow — where the hub stops one job, keeps another on version 2, and voids a stale review for redo — and the unconfirmed-stop failure path — where a busy worker misses the stop message, gets fenced out after its confirmation deadline, and leaves a half-finished change for a cleanup job.
The hub discovers all three version-1 items automatically, collects the lead's stop/keep/redo calls, waits for every confirmation, shows the decision list to the requester, and closes the change only when every item is applied and reported.
Begins after step 5 of the normal flow: the lead agent has decided
stop on Worker A's file-move job.
When Worker A fails to confirm within 2 minutes, the hub forces the stop by ending
Attempt 1 and canceling the job. Worker A's late completion report fails the
Progress Heartbeat attempt fence
(attempt_replaced), and the lead schedules a version-2
cleanup job to restore the half-moved folder.
Stopping is not undoing: A worker that confirms a stop in time can revert its own half-finished edits before confirming. After a forced stop, cleaning up partial side effects is scheduled as a separate job under the new spec version.
Concrete examples
Change Propagation applies to any multi-agent work driven by a versioned brief — whether shifting a product launch plan, revising a research scope, or changing a software architecture mid-flight.
Example 1 — Product launch brief narrowing from global to US-only
No code or unit tests- Revision
-
Under Spec v1 (global launch),
Worker Ais drafting EU localization pricing,Worker Bis writing US competitor positioning, and aCheckeralready approved the multi-currency executive summary. Mid-day, the requester says: "Launch US-only first." - Impact list
-
The lead saves Spec v2 and opens a
Change. The hub finds all three v1 items and creates oneImpact itemfor each. - Decisions
- Stop EU localization pricing (out of scope in v2); Keep US competitor positioning (update briefing to v2); Redo executive summary review (void the multi-currency sign-off and re-check against US-only scope).
- Outcome
- Every decision takes effect and confirms; the requester gets a 3-row summary card, agrees with all three calls, and the hub closes the change without losing Worker B's completed US research.
Example 2 — Keeping the backend in one repository
Software engineering- Revision
-
Under Spec v1 ("split the backend into two repositories"),
Worker Ais moving billing code to a new repo,Worker Bis speeding up the build with a cache, and theCheckerapproved Worker B's change after verifying two build packages. At 10:40 a.m. the requester says: "Actually, keep it in one repository for this release." - Decisions
- Lead saves Spec v2 and decides: Stop the billing file move (Worker A puts back the half-moved folder and confirms), Keep the build cache (independent of the repo split; Worker B confirms reading v2), and Redo the build review (hub voids the v1 finding and requests a one-package review).
- Forced stop
-
If Worker A misses the stop notice for 2 minutes, the hub forces Attempt 1 closed,
rejects its late completion with
attempt_replaced, and the lead opens a v2 cleanup job to move the billing code back. - Outcome
- At 10:52 a.m. the requester sees a single 3-line summary card of what stopped, what continued, and what was re-reviewed, with the option to overrule any line.
What this pattern is NOT — Single-agent chats or cheap 20-second jobs
Negative example- Scenario
- One agent doing a task in one conversation, or a fan-out of 20-second stateless tasks that are trivial to re-run from scratch.
- Why skip it
- When one agent owns everything in one session, the agent that hears the revision is already the agent doing the work. And when parallel jobs are cheap and side-effect free, canceling all of them and restarting from Spec v2 is simpler than per-item impact triage.
When to use and when to skip
Use Change Propagation when
- A request is split across multiple agents, so telling one agent will not reach the rest.
- Requesters revise or refine requirements while parallel work and reviews are already in flight.
- Requests use versioned specs (Request Spec) and every job records its starting version.
- In-progress work is expensive enough that preserving unaffected jobs matters.
Skip it when
- One agent handles the entire request inside a single conversation.
- Subtasks are short, cheap, and idempotent enough that canceling all of them and restarting is faster than triaging.
Data model and hub invariants
Change Propagation introduces two durable tables — changes
and impact_items — and reads versioned specs, jobs, waits,
and findings from the rest of the catalog. Notice that a review still running is itself a
Job assigned to a checker, whereas an already-completed
review is a Finding.
Change links an older
Request spec to a newer one (or
NULL on cancellation) and owns one
Impact item per affected job, wait, or finding.
Table: changes
| Column | Postgres type | Nullability | Notes |
|---|---|---|---|
| id | uuid | NOT NULL, PK | Unique identifier for this change event. |
| request_id | uuid | NOT NULL, FK | References requests(id); at most one open change per request. |
| from_request_spec_id | uuid | NOT NULL, FK | References request_specs(id); spec version current before the revision. |
| to_request_spec_id | uuid | NULLABLE, FK | References request_specs(id); NULL means the request was canceled. |
| changed_by_id | uuid | NOT NULL, FK | References parties(id); party whose revision triggered the change. |
| summary | text | NOT NULL | One-sentence summary of what changed. |
| state | text | NOT NULL | CHECK (state IN ('open', 'closed')). |
| opened_at | timestamptz | NOT NULL | Time the change was recorded at the hub. |
| reported_at | timestamptz | NULLABLE | Time the decision list was shown to the requester. |
| closed_at | timestamptz | NULLABLE | Set when the change closes (all items applied and list reported, or superseded). |
Table: impact_items
| Column | Postgres type | Nullability | Notes |
|---|---|---|---|
| id | uuid | NOT NULL, PK | Unique identifier for one affected piece of work. |
| change_id | uuid | NOT NULL, FK | References changes(id). |
| job_id | uuid | NULLABLE, FK | References jobs(id) when the item is about a job. |
| wait_id | uuid | NULLABLE, FK | References waits(id) when the item is about an open wait. |
| finding_id | uuid | NULLABLE, FK | References findings(id) when the item is about a non-void finding. |
| decision | text | NULLABLE | CHECK (decision IN ('stop', 'redo', 'keep')); NULL until decided. |
| reason | text | NULLABLE | One-sentence explanation shown to the requester on the decision list. |
| decided_by_id | uuid | NULLABLE, FK | References parties(id); lead agent, overruling requester, or hub on cascade. |
| decided_at | timestamptz | NULLABLE | Time the decision was recorded. |
| applied_at | timestamptz | NULLABLE | Time the hub confirmed the decision took effect; cleared if overruled. |
Decision semantics across work types
| Decision | For a Job | For a Wait | For a Finding |
|---|---|---|---|
| stop | End current attempt and mark job canceled. |
Cancel the wait so nothing restarts the job. | Set voided_at; finding no longer counts as evidence. |
| redo | End attempt, point job at new spec version, start fresh attempt. | Cancel wait and reopen it for what the new version needs. | Set voided_at and ask the checker to re-review against v2. |
| keep | Update job's request_spec_id to v2; worker confirms reading v2. |
Wait stands unchanged. | Finding stands as valid evidence under the new version. |
Seven hub invariants
-
01Every impact item targets exactly one job, wait, or finding Database constraint
CHECK (num_nonnulls(job_id, wait_id, finding_id) = 1)(mirrored byinvalid_impact_subject) plus unique partial indexes per(change_id, target_id)ensure every piece of work appears at most once per change. -
02Decision fields are all-or-nothing, and applied_at requires a decision Database constraint
A
CHECKconstraint guaranteesdecision,reason,decided_by_id, anddecided_atare either all set or all null, and forbids settingapplied_atbefore a decision exists (hub guard:invalid_decision). -
03At most one open change per request Database constraint
A partial unique index on
changes(request_id) WHERE state = 'open'prevents overlapping change lists. If the spec changes again before the first change closes,open_changecloses the earlier change early and re-scans all stale work under the new change. -
04Request cancellation requires every impact item to stop Hub guard
When
to_request_spec_idisNULL,deciderejectskeeporredowithcancellation_requires_stop. -
05Lead decides items; requester may overrule while open Hub guard
deciderejects closed changes withchange_already_closedand unauthorized callers withnot_authorized_to_decide. Overruling an already-applied item resetsapplied_attoNULLso the new commands run. -
06Stopping a job cascades stop to its waits and findings Hub guard
When a job's impact item is decided
stop, the hub automatically decidesstopfor sibling impact items referencing that job's active waits and non-void findings so no orphaned wait can restart a canceled job. -
07Change closes only after all items apply and the list is reported Hub guard
close_changerejects closure withunapplied_impact_itemsif any item lacksapplied_atand withchange_not_reportedifreported_atis null. Once closed, no unfinished job still names an older spec version.
Reference implementation
The change-enumeration, triage, cascade, command-emission, and closure guards in TypeScript,
Python, and Elixir. A production hub executes the emitted commands asynchronously and calls
confirm_applied once each worker or checker confirms.
-- Hub guards for Change Propagation (enforced in code, never in prompts)
import Std.Data.HashMap
open Std (HashMap)
inductive Decision where
| stop | redo | keep
deriving Repr, BEq, DecidableEq
inductive ChangeState where
| open | closed
deriving Repr, BEq, DecidableEq
structure Change where
id : String
requestId : String
leadId : String
requesterId : String
fromSpecId : String
toSpecId : Option String -- none = request canceled
state : ChangeState := .open
reportedAtSec : Option Nat := none
closedAtSec : Option Nat := none
deriving Repr
structure ImpactItem where
id : String
changeId : String
jobId : Option String := none
waitId : Option String := none
findingId : Option String := none
decision : Option Decision := none
reason : Option String := none
decidedById : Option String := none
decidedAtSec : Option Nat := none
appliedAtSec : Option Nat := none
deriving Repr
structure Job where
id : String
requestId : String
specId : String
canceled : Bool
structure Wait where
id : String
jobId : String
active : Bool
structure Finding where
id : String
jobId : String
voided : Bool
inductive Command where
| endAttempt (jobId : String) | cancelJob (jobId : String)
| setSpec (jobId : String) (specId : Option String) | startAttempt (jobId : String)
| sendBriefing (jobId : String)
| cancelWait (waitId : String) | reopenWait (waitId : String)
| voidFinding (findingId : String) | requestReview (findingId : String)
deriving Repr
inductive HubError where
| unknownImpactItem | unknownChange | changeAlreadyClosed | invalidDecision
| notAuthorizedToDecide | cancellationRequiresStop | unappliedImpactItems
| changeNotReported | invalidImpactSubject
deriving Repr, BEq, DecidableEq
structure Hub where
changes : HashMap String Change := {}
items : HashMap String ImpactItem := {}
jobs : List Job := []
waits : List Wait := []
findings : List Finding := []
namespace Hub
-- Look a key up, or fail with `err` (`m[k]?` gives an Option).
def fetch {α : Type} (m : HashMap String α) (key : String) (err : HubError) :
Except HubError α :=
match m[key]? with
| some v => .ok v
| none => .error err
def openChange (hub : Hub) (change : Change) (nowSec : Nat) : List ImpactItem × Hub :=
-- At most one open change per request: close any superseded open change first
let changes := hub.changes.map fun _ existing =>
if existing.requestId == change.requestId && existing.state == .open then
{ existing with state := .closed, closedAtSec := some nowSec }
else existing
let changes := changes.insert change.id
{ change with state := .open, reportedAtSec := none, closedAtSec := none }
let staleJobs := hub.jobs.filter fun j =>
j.requestId == change.requestId && some j.specId != change.toSpecId && !j.canceled
let jobIds := staleJobs.map (·.id)
let waits := hub.waits.filter fun w => w.active && jobIds.contains w.jobId
let findings := hub.findings.filter fun f => !f.voided && jobIds.contains f.jobId
let item (id : String) : ImpactItem := { id := "item_" ++ id, changeId := change.id }
let created :=
staleJobs.map (fun j => { item j.id with jobId := some j.id }) ++
waits.map (fun w => { item w.id with waitId := some w.id }) ++
findings.map (fun f => { item f.id with findingId := some f.id })
let items := created.foldl (fun m i => m.insert i.id i) hub.items
(created, { hub with changes, items })
def commandsFor (item : ImpactItem) (change : Change) : Except HubError (List Command) :=
match item.jobId, item.waitId, item.findingId, item.decision with
| some j, _, _, some .stop => .ok [.endAttempt j, .cancelJob j]
| some j, _, _, some .redo => .ok [.endAttempt j, .setSpec j change.toSpecId, .startAttempt j]
| some j, _, _, some .keep => .ok [.setSpec j change.toSpecId, .sendBriefing j]
| none, some w, _, some .stop => .ok [.cancelWait w]
| none, some w, _, some .redo => .ok [.cancelWait w, .reopenWait w]
| none, some _, _, some .keep => .ok []
| none, none, some f, some .stop => .ok [.voidFinding f]
| none, none, some f, some .redo => .ok [.voidFinding f, .requestReview f]
| none, none, some _, some .keep => .ok []
| _, _, _, _ => .error .invalidImpactSubject
-- Stopping a job automatically cascades stop to its waits and findings
def cascadeStop (hub : Hub) (changeId jobId : String) (nowSec : Nat) : Hub :=
let hit (sib : ImpactItem) : Bool :=
sib.changeId == changeId &&
(hub.waits.any (fun w => sib.waitId == some w.id && w.jobId == jobId) ||
hub.findings.any (fun f => sib.findingId == some f.id && f.jobId == jobId))
{ hub with
items := hub.items.map fun _ sib =>
if hit sib then
{ sib with decision := some .stop, reason := some "Parent job stopped",
decidedById := some "hub", decidedAtSec := some nowSec, appliedAtSec := none }
else sib }
def decide (hub : Hub) (itemId : String) (decision : Decision) (reason actorId : String)
(nowSec : Nat) : Except HubError (List Command × Hub) := do
let item ← fetch hub.items itemId .unknownImpactItem
let change ← fetch hub.changes item.changeId .unknownChange
unless change.state == .open do throw .changeAlreadyClosed
unless actorId == change.leadId || actorId == change.requesterId do
throw .notAuthorizedToDecide
if change.toSpecId.isNone && decision != .stop then throw .cancellationRequiresStop
-- Overruling an earlier decision clears appliedAtSec so new commands run
let updated := { item with
decision := some decision, reason := some reason, decidedById := some actorId,
decidedAtSec := some nowSec, appliedAtSec := none }
let cmds ← commandsFor updated change
let hub := { hub with items := hub.items.insert itemId updated }
match updated.jobId, decision with
| some jobId, .stop => return (cmds, hub.cascadeStop change.id jobId nowSec)
| _, _ => return (cmds, hub)
def confirmApplied (hub : Hub) (itemId : String) (nowSec : Nat) : Except HubError Hub := do
let item ← fetch hub.items itemId .unknownImpactItem
if item.decision.isNone then throw .invalidDecision
return { hub with items := hub.items.insert itemId { item with appliedAtSec := some nowSec } }
def markReported (hub : Hub) (changeId : String) (nowSec : Nat) : Except HubError Hub := do
let change ← fetch hub.changes changeId .unknownChange
let change := { change with reportedAtSec := some nowSec }
return { hub with changes := hub.changes.insert changeId change }
def closeChange (hub : Hub) (changeId : String) (nowSec : Nat) : Except HubError Hub := do
let change ← fetch hub.changes changeId .unknownChange
unless change.state == .open do throw .changeAlreadyClosed
let mine := hub.items.values.filter (·.changeId == changeId)
unless mine.all (·.appliedAtSec.isSome) do throw .unappliedImpactItems
if change.reportedAtSec.isNone then throw .changeNotReported
let closed := { change with state := .closed, closedAtSec := some nowSec }
return { hub with changes := hub.changes.insert changeId closed }
-- An impact item with no job, wait or finding never produces commands.
theorem no_subject_no_commands (i c : String) (d : Option Decision) (ch : Change) :
commandsFor { id := i, changeId := c, decision := d } ch = .error .invalidImpactSubject := by
cases d <;> rfl
end Hub
// Hub guards for Change Propagation (enforced in code, never in prompts)
type Decision = "stop" | "redo" | "keep";
interface Change {
id: string;
requestId: string;
leadId: string;
requesterId: string;
fromSpecId: string;
toSpecId: string | null; // null = request canceled
state: "open" | "closed";
reportedAtSec: number | null;
closedAtSec: number | null;
}
interface ImpactItem {
id: string;
changeId: string;
jobId: string | null;
waitId: string | null;
findingId: string | null;
decision: Decision | null;
reason: string | null;
decidedById: string | null;
decidedAtSec: number | null;
appliedAtSec: number | null;
}
class Hub {
private changes = new Map<string, Change>();
private items = new Map<string, ImpactItem>();
private jobs: Array<{ id: string; requestId: string; specId: string; state: string }> = [];
private waits: Array<{ id: string; jobId: string; active: boolean }> = [];
private findings: Array<{ id: string; jobId: string; voided: boolean }> = [];
openChange(change: Change, nowSec: number): ImpactItem[] {
// At most one open change per request: close any superseded open change first
for (const existing of this.changes.values()) {
if (existing.requestId === change.requestId && existing.state === "open") {
existing.state = "closed";
existing.closedAtSec = nowSec;
}
}
this.changes.set(change.id, { ...change, state: "open", reportedAtSec: null, closedAtSec: null });
const staleJobs = this.jobs.filter(
(j) => j.requestId === change.requestId && j.specId !== change.toSpecId && j.state !== "canceled"
);
const jobIds = new Set(staleJobs.map((j) => j.id));
const created: ImpactItem[] = [];
const pushItem = (id: string, target: Partial<ImpactItem>) => {
const item: ImpactItem = {
id, changeId: change.id, jobId: null, waitId: null, findingId: null,
decision: null, reason: null, decidedById: null, decidedAtSec: null, appliedAtSec: null,
...target
};
this.items.set(id, item);
created.push(item);
};
staleJobs.forEach((j) => pushItem("item_" + j.id, { jobId: j.id }));
this.waits
.filter((w) => w.active && jobIds.has(w.jobId))
.forEach((w) => pushItem("item_" + w.id, { waitId: w.id }));
this.findings
.filter((f) => !f.voided && jobIds.has(f.jobId))
.forEach((f) => pushItem("item_" + f.id, { findingId: f.id }));
return created;
}
decide(itemId: string, decision: Decision, reason: string, actorId: string, nowSec: number): string[] {
const item = this.items.get(itemId);
if (!item) throw new Error("unknown_impact_item");
const change = this.changes.get(item.changeId);
if (!change) throw new Error("unknown_change");
if (change.state !== "open") throw new Error("change_already_closed");
if (actorId !== change.leadId && actorId !== change.requesterId) {
throw new Error("not_authorized_to_decide");
}
if (change.toSpecId === null && decision !== "stop") {
throw new Error("cancellation_requires_stop");
}
// Overruling an earlier decision clears appliedAtSec so new commands run
item.decision = decision;
item.reason = reason;
item.decidedById = actorId;
item.decidedAtSec = nowSec;
item.appliedAtSec = null;
// Stopping a job automatically cascades stop to its waits and findings
if (item.jobId && decision === "stop") {
for (const sibling of this.items.values()) {
if (sibling.changeId !== change.id) continue;
const waitHit = sibling.waitId && this.waits.some((w) => w.id === sibling.waitId && w.jobId === item.jobId);
const findingHit = sibling.findingId && this.findings.some((f) => f.id === sibling.findingId && f.jobId === item.jobId);
if (waitHit || findingHit) {
sibling.decision = "stop";
sibling.reason = "Parent job stopped";
sibling.decidedById = "hub";
sibling.decidedAtSec = nowSec;
sibling.appliedAtSec = null;
}
}
}
return this.commandsFor(item, change);
}
confirmApplied(itemId: string, nowSec: number): void {
const item = this.items.get(itemId);
if (!item) throw new Error("unknown_impact_item");
if (!item.decision) throw new Error("invalid_decision");
item.appliedAtSec = nowSec;
}
markReported(changeId: string, nowSec: number): void {
const change = this.changes.get(changeId);
if (!change) throw new Error("unknown_change");
change.reportedAtSec = nowSec;
}
closeChange(changeId: string, nowSec: number): void {
const change = this.changes.get(changeId);
if (!change) throw new Error("unknown_change");
if (change.state !== "open") throw new Error("change_already_closed");
const mine = [...this.items.values()].filter((i) => i.changeId === changeId);
if (mine.some((i) => i.appliedAtSec === null)) throw new Error("unapplied_impact_items");
if (change.reportedAtSec === null) throw new Error("change_not_reported");
change.state = "closed";
change.closedAtSec = nowSec;
}
private commandsFor(item: ImpactItem, change: Change): string[] {
if (item.jobId) {
if (item.decision === "stop") return ["end_attempt:" + item.jobId, "cancel_job:" + item.jobId];
if (item.decision === "redo") return ["end_attempt:" + item.jobId, "set_spec:" + change.toSpecId, "start_attempt:" + item.jobId];
return ["set_spec:" + change.toSpecId, "send_briefing:" + item.jobId];
}
if (item.waitId) {
if (item.decision === "stop") return ["cancel_wait:" + item.waitId];
if (item.decision === "redo") return ["cancel_wait:" + item.waitId, "reopen_wait:" + item.waitId];
return [];
}
if (item.findingId) {
if (item.decision === "stop") return ["void_finding:" + item.findingId];
if (item.decision === "redo") return ["void_finding:" + item.findingId, "request_review:" + item.findingId];
return [];
}
throw new Error("invalid_impact_subject");
}
}
# Hub guards for Change Propagation (enforced in code, never in prompts)
from dataclasses import dataclass
from typing import Literal, Optional
Decision = Literal["stop", "redo", "keep"]
@dataclass
class Change:
id: str
request_id: str
lead_id: str
requester_id: str
from_spec_id: str
to_spec_id: Optional[str]
state: Literal["open", "closed"] = "open"
reported_at_sec: Optional[int] = None
closed_at_sec: Optional[int] = None
@dataclass
class ImpactItem:
id: str
change_id: str
job_id: Optional[str] = None
wait_id: Optional[str] = None
finding_id: Optional[str] = None
decision: Optional[Decision] = None
reason: Optional[str] = None
decided_by_id: Optional[str] = None
decided_at_sec: Optional[int] = None
applied_at_sec: Optional[int] = None
class HubError(Exception):
pass
class Hub:
def __init__(self) -> None:
self.changes: dict[str, Change] = {}
self.items: dict[str, ImpactItem] = {}
self.jobs: list[dict[str, str]] = []
self.waits: list[dict[str, object]] = []
self.findings: list[dict[str, object]] = []
def open_change(self, change: Change, now_sec: int) -> list[ImpactItem]:
for existing in self.changes.values():
if existing.request_id == change.request_id and existing.state == "open":
existing.state = "closed"
existing.closed_at_sec = now_sec
self.changes[change.id] = change
stale_jobs = [
j for j in self.jobs
if j["request_id"] == change.request_id
and j["spec_id"] != change.to_spec_id
and j["state"] != "canceled"
]
job_ids = {j["id"] for j in stale_jobs}
created: list[ImpactItem] = []
for j in stale_jobs:
item = ImpactItem(id=f"item_{j['id']}", change_id=change.id, job_id=j["id"])
self.items[item.id] = item
created.append(item)
for w in self.waits:
if w["active"] and w["job_id"] in job_ids:
wid = str(w["id"])
item = ImpactItem(id=f"item_{wid}", change_id=change.id, wait_id=wid)
self.items[item.id] = item
created.append(item)
for f in self.findings:
if not f["voided"] and f["job_id"] in job_ids:
fid = str(f["id"])
item = ImpactItem(id=f"item_{fid}", change_id=change.id, finding_id=fid)
self.items[item.id] = item
created.append(item)
return created
def decide(
self, item_id: str, decision: Decision, reason: str, actor_id: str, now_sec: int
) -> list[str]:
item = self.items.get(item_id)
if item is None:
raise HubError("unknown_impact_item")
change = self.changes.get(item.change_id)
if change is None:
raise HubError("unknown_change")
if change.state != "open":
raise HubError("change_already_closed")
if actor_id not in (change.lead_id, change.requester_id):
raise HubError("not_authorized_to_decide")
if change.to_spec_id is None and decision != "stop":
raise HubError("cancellation_requires_stop")
item.decision = decision
item.reason = reason
item.decided_by_id = actor_id
item.decided_at_sec = now_sec
item.applied_at_sec = None
if item.job_id is not None and decision == "stop":
self._cascade_job_stop(change.id, item.job_id, now_sec)
return self._commands_for(item, change)
def confirm_applied(self, item_id: str, now_sec: int) -> None:
item = self.items.get(item_id)
if item is None:
raise HubError("unknown_impact_item")
if item.decision is None:
raise HubError("invalid_decision")
item.applied_at_sec = now_sec
def mark_reported(self, change_id: str, now_sec: int) -> None:
change = self.changes.get(change_id)
if change is None:
raise HubError("unknown_change")
change.reported_at_sec = now_sec
def close_change(self, change_id: str, now_sec: int) -> None:
change = self.changes.get(change_id)
if change is None:
raise HubError("unknown_change")
if change.state != "open":
raise HubError("change_already_closed")
mine = [i for i in self.items.values() if i.change_id == change_id]
if any(i.applied_at_sec is None for i in mine):
raise HubError("unapplied_impact_items")
if change.reported_at_sec is None:
raise HubError("change_not_reported")
change.state = "closed"
change.closed_at_sec = now_sec
def _cascade_job_stop(self, change_id: str, job_id: str, now_sec: int) -> None:
for sib in self.items.values():
if sib.change_id != change_id:
continue
wait_hit = sib.wait_id and any(w["id"] == sib.wait_id and w["job_id"] == job_id for w in self.waits)
find_hit = sib.finding_id and any(f["id"] == sib.finding_id and f["job_id"] == job_id for f in self.findings)
if wait_hit or find_hit:
sib.decision = "stop"
sib.reason = "Parent job stopped"
sib.decided_by_id = "hub"
sib.decided_at_sec = now_sec
sib.applied_at_sec = None
def _commands_for(self, item: ImpactItem, change: Change) -> list[str]:
if item.job_id:
if item.decision == "stop":
return [f"end_attempt:{item.job_id}", f"cancel_job:{item.job_id}"]
if item.decision == "redo":
return [f"end_attempt:{item.job_id}", f"set_spec:{change.to_spec_id}", f"start_attempt:{item.job_id}"]
return [f"set_spec:{change.to_spec_id}", f"send_briefing:{item.job_id}"]
if item.wait_id:
if item.decision == "stop":
return [f"cancel_wait:{item.wait_id}"]
if item.decision == "redo":
return [f"cancel_wait:{item.wait_id}", f"reopen_wait:{item.wait_id}"]
return []
if item.finding_id:
if item.decision == "stop":
return [f"void_finding:{item.finding_id}"]
if item.decision == "redo":
return [f"void_finding:{item.finding_id}", f"request_review:{item.finding_id}"]
return []
raise HubError("invalid_impact_subject")
# Hub guards for Change Propagation (pure functional core)
defmodule ChangePropagation do
def open_change(state, change, now) do
changes =
Map.new(state.changes, fn {id, existing} ->
if existing.request_id == change.request_id and existing.state == :open do
{id, %{existing | state: :closed, closed_at: now}}
else
{id, existing}
end
end)
|> Map.put(change.id, %{change | state: :open, reported_at: nil, closed_at: nil})
stale_jobs =
Enum.filter(state.jobs, fn j ->
j.request_id == change.request_id and j.spec_id != change.to_spec_id and j.state != :canceled
end)
job_ids = MapSet.new(stale_jobs, & &1.id)
waits = Enum.filter(state.waits, &(&1.active and &1.job_id in job_ids))
findings = Enum.filter(state.findings, &(not &1.voided and &1.job_id in job_ids))
new_items =
Enum.map(stale_jobs, &build_item(change.id, "item_" <> &1.id, job_id: &1.id)) ++
Enum.map(waits, &build_item(change.id, "item_" <> &1.id, wait_id: &1.id)) ++
Enum.map(findings, &build_item(change.id, "item_" <> &1.id, finding_id: &1.id))
items = Map.merge(state.items, Map.new(new_items, &{&1.id, &1}))
{:ok, new_items, %{state | changes: changes, items: items}}
end
def decide(state, item_id, decision, reason, actor_id, now) do
with {:ok, item} <- fetch(state.items, item_id, :unknown_impact_item),
{:ok, change} <- fetch(state.changes, item.change_id, :unknown_change),
true <- change.state == :open || {:error, :change_already_closed},
true <- decision in [:stop, :redo, :keep] || {:error, :invalid_decision},
true <- actor_id in [change.lead_id, change.requester_id] || {:error, :not_authorized_to_decide},
true <- (change.to_spec_id != nil or decision == :stop) || {:error, :cancellation_requires_stop},
{:ok, cmds} <- commands(%{item | decision: decision}, change) do
updated = %{
item
| decision: decision,
reason: reason,
decided_by_id: actor_id,
decided_at: now,
applied_at: nil
}
items =
state.items
|> Map.put(item_id, updated)
|> maybe_cascade_stop(state, updated, now)
{:ok, cmds, %{state | items: items}}
end
end
def confirm_applied(state, item_id, now) do
with {:ok, item} <- fetch(state.items, item_id, :unknown_impact_item),
true <- item.decision != nil || {:error, :invalid_decision} do
{:ok, put_in(state, [:items, item_id, :applied_at], now)}
end
end
def mark_reported(state, change_id, now) do
with {:ok, _change} <- fetch(state.changes, change_id, :unknown_change) do
{:ok, put_in(state, [:changes, change_id, :reported_at], now)}
end
end
def close_change(state, change_id, now) do
with {:ok, change} <- fetch(state.changes, change_id, :unknown_change),
true <- change.state == :open || {:error, :change_already_closed},
mine = Enum.filter(Map.values(state.items), &(&1.change_id == change_id)),
true <- Enum.all?(mine, &(&1.applied_at != nil)) || {:error, :unapplied_impact_items},
true <- change.reported_at != nil || {:error, :change_not_reported} do
{:ok, put_in(state, [:changes, change_id], %{change | state: :closed, closed_at: now})}
end
end
def commands(%{job_id: id, decision: :stop}, _) when is_binary(id),
do: {:ok, [{:end_attempt, id}, {:cancel_job, id}]}
def commands(%{job_id: id, decision: :redo}, c) when is_binary(id),
do: {:ok, [{:end_attempt, id}, {:set_spec, id, c.to_spec_id}, {:start_attempt, id}]}
def commands(%{job_id: id, decision: :keep}, c) when is_binary(id),
do: {:ok, [{:set_spec, id, c.to_spec_id}, {:send_briefing, id}]}
def commands(%{wait_id: id, decision: :stop}, _) when is_binary(id),
do: {:ok, [{:cancel_wait, id}]}
def commands(%{wait_id: id, decision: :redo}, _) when is_binary(id),
do: {:ok, [{:cancel_wait, id}, {:reopen_wait, id}]}
def commands(%{wait_id: id, decision: :keep}, _) when is_binary(id),
do: {:ok, []}
def commands(%{finding_id: id, decision: :stop}, _) when is_binary(id),
do: {:ok, [{:void_finding, id}]}
def commands(%{finding_id: id, decision: :redo}, _) when is_binary(id),
do: {:ok, [{:void_finding, id}, {:request_review, id}]}
def commands(%{finding_id: id, decision: :keep}, _) when is_binary(id),
do: {:ok, []}
def commands(_, _), do: {:error, :invalid_impact_subject}
defp maybe_cascade_stop(items, state, %{job_id: jid, decision: :stop, change_id: cid}, now)
when is_binary(jid) do
Map.new(items, fn {k, sib} ->
hit? =
sib.change_id == cid and
((sib.wait_id != nil and Enum.any?(state.waits, &(&1.id == sib.wait_id and &1.job_id == jid))) or
(sib.finding_id != nil and Enum.any?(state.findings, &(&1.id == sib.finding_id and &1.job_id == jid))))
if hit? do
{k, %{sib | decision: :stop, reason: "Parent job stopped", decided_by_id: "hub", decided_at: now, applied_at: nil}}
else
{k, sib}
end
end)
end
defp maybe_cascade_stop(items, _state, _item, _now), do: items
defp build_item(change_id, id, subject) do
Map.merge(
%{id: id, change_id: change_id, job_id: nil, wait_id: nil, finding_id: nil,
decision: nil, reason: nil, decided_by_id: nil, decided_at: nil, applied_at: nil},
Map.new(subject)
)
end
defp fetch(map, key, err), do: Map.fetch(map, key) |> then(&if(&1 == :error, do: {:error, err}, else: &1))
end
Triage and closure trace
Walking Example 2 (keeping the backend in one repository) through these guards shows how all three version-1 items are enumerated, triaged, blocked from premature closure until confirmed and reported, and closed cleanly:
1. hub.openChange({ id: "chg_1", requestId: "req_repo",
fromSpecId: "spec_v1", toSpecId: "spec_v2", changedById: "requester_1" })
-> ok (3 impact items: job_move_billing, job_build_cache, finding_build_v1)
2. hub.decide("item_job_move_billing", "stop", "Spec v2 keeps one repository", "lead_1", "10:42Z")
hub.decide("item_job_build_cache", "keep", "Build cache does not depend on split", "lead_1", "10:42Z")
hub.decide("item_finding_build_v1", "redo", "Checker verified two packages, not one", "lead_1", "10:42Z")
-> commands: [end_attempt + cancel_job(job_move_billing)],
[set_spec(spec_v2) + send_briefing(job_build_cache)],
[void_finding + request_review(finding_build_v1)]
3. hub.closeChange("chg_1", "10:45Z")
-> error: unapplied_impact_items (workers and checker have not confirmed yet)
4. hub.confirmApplied("item_job_move_billing", "10:47Z")
hub.confirmApplied("item_job_build_cache", "10:48Z")
hub.confirmApplied("item_finding_build_v1", "10:51Z")
hub.closeChange("chg_1", "10:51Z")
-> error: change_not_reported (requester has not been shown the decision list)
5. hub.markReported("chg_1", "10:52Z")
hub.closeChange("chg_1", "11:30Z")
-> ok (chg_1 closed; zero unfinished jobs reference spec_v1)
Tradeoffs and practical guidance
Change Propagation keeps parallel work aligned with moving requirements without discarding healthy progress, while carrying three practical costs:
-
Version stamping discipline: every job, wait, and finding must be
reachable from a
request_spec_id; any unversioned work is invisible to impact discovery. -
Lead judgment can still err: the lead agent might mistakenly mark a
subtle dependency as
keep; showing the decision list to the requester is the safety net, though it arrives after execution begins. - Stopping does not automatically undo side effects: halting a worker mid-operation can leave partial files or half-applied changes that require explicit cleanup work.
Practical implementation notes
-
Pause irreversible steps immediately: the instant a
Changeopens, hold merges, deploys, and external writes on affected jobs until their impact items are decided, while allowing safe read/draft work to continue. -
Include finished jobs in the scan: list every non-canceled job stamped
with an older spec version — including finished ones. An unnecessary
keepcosts seconds; missing a finished job whose output conflicts with v2 can cost a day. - Never force the requester to classify their edit: whether they say "no," "actually," or "stop," translate it into a new spec version, triage the impact items, and show them the concrete list to adjust if needed.
-
Put a hard confirmation deadline on every stop: if a worker does not
confirm a
stopwithin a short window (such as 2 minutes), force-end its attempt so the Progress Heartbeat fence rejects any late output. - Plan cleanup explicitly: let cooperative workers revert partial work before confirming a stop, and have the lead open a dedicated cleanup job under Spec v2 after any forced stop.
Known uses and related patterns
- Bazel Skyframe: tracks dependency graphs over versioned inputs, invalidating downstream build targets when an input changes while reusing unaffected cached results automatically.
- GitHub protected branches (dismiss stale reviews): automatically voids earlier pull-request approvals whenever a new commit alters the branch, forcing a fresh review before merge.
- LangSmith Agent Server double-texting policies: offers explicit strategies (interrupt, rollback, enqueue, or reject) when a user sends a revised message while an earlier agent run is still executing.
- Volgenic: versions work item descriptions on every edit, withdraws obsolete questions when work closes, and discards stale review verdicts when new commits land — foundational building blocks that Change Propagation unifies across parallel jobs.
- Classic architecture relatives: adapts the GoF Observer pattern from mechanical notification to selective triage over in-flight work, and draws on Azure's Compensating Transaction for cleanup jobs after forced stops.
Related patterns
- Request Spec — supplies the versioned specification IDs that every job records and every Change transitions between.
- Tracked Answer — follows one human answer forward to its effect, whereas Change Propagation fans out from a whole-request revision across all stale work.
- Context Handoff — builds the fresh version-2 briefing delivered to every job decided
keeporredo. - Progress Heartbeat — enforces the attempt fence that rejects late reports after a forced stop.
- Durable Job, Resumable Wait, & Policy Gate — define the jobs, waits, and findings that impact items act on.
- Close-Out Triage — tracks any follow-up or cleanup items left behind after stopped work.