Commit 43c15ba
fix(orchestrator): compound-review schedule cursor (Layer 0) Refs terraphim/terraphim-ai#1562 (Gitea) (#872)
* style(terraphim_multi_agent): apply cargo fmt to examples
Pre-existing rustfmt drift in the example files blocks the
workspace-wide `cargo fmt --check` step in the pre-commit hook.
Re-formatting in a separate commit so the substantive Layer 0 cursor
fix (Refs #1562) stays scoped to the orchestrator.
Refs #1562 (Gitea)
* fix(terraphim_orchestrator): gate compound-review fires against per-occurrence cursor
Adds `last_compound_review_fired_at: Option<DateTime<Utc>>` to
`AgentOrchestrator` and rewrites the compound-review branch of
`check_cron_schedules` so the cursor is recorded **before** the
`.await` on `handle_schedule_event`. Mirrors the per-agent
`last_cron_fire` pattern at the start of the same function.
Why: `reconcile_tick` is wrapped in a 90 s `tokio::time::timeout`
safety net. When the future is cancelled mid-await, `last_tick_time`
is never updated, so the previous `should_fire` check kept returning
true on every subsequent tick, spawning a fresh review worktree every
30 s (the bigbox storm). Recording the cursor synchronously before the
await makes cancellation safe: the next iteration sees the cursor and
short-circuits via `already_fired = fire_time <= prev`.
Verified via new regression test
`test_compound_review_cursor_advances_on_cancellation`: plants a
`last_tick_time` 2 h in the past, runs `check_cron_schedules` twice
without advancing wall-clock, and asserts the cursor is `Some(_)` after
the first call and unchanged after the second.
Note on design drift: the design doc (docs/design/adf-worktree-lifecycle-design.md
section 4.1) used `take_while(|t| *t <= now)` plus an explicit
`already_fired` gate. I initially collapsed both into
`compound_sched.after(&cursor).next()` for brevity but reverted to the
documented shape after the regression test exposed the catch-up vs
gating semantic difference -- the design's `last_tick_time`-anchored
`next_fire` plus separate cursor gate is the correct read of "same
occurrence, do not re-fire". Line numbers in the design (`:241`,
`:817`, `:7137-7161`, `:7712`) all matched current source unchanged.
Layer 0 of the ADF worktree lifecycle epic (Gitea #1567). Out of scope:
the per-agent cron path at lib.rs:7484, the WorktreeGuard refactor
(Layer 1, Gitea #1569), startup sweep (Layer 2, #1570), and the
adf-cleanup.sh hardening (Layer 3, #1571).
Refs #1562 (Gitea)
---------
Co-authored-by: Alex <alex@example.com>1 parent 0287636 commit 43c15ba
7 files changed
Lines changed: 145 additions & 26 deletions
File tree
- crates
- terraphim_multi_agent/examples
- terraphim_orchestrator/src
Lines changed: 6 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
42 | 40 | | |
43 | 41 | | |
44 | 42 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
242 | 250 | | |
243 | 251 | | |
244 | 252 | | |
| |||
824 | 832 | | |
825 | 833 | | |
826 | 834 | | |
| 835 | + | |
827 | 836 | | |
828 | 837 | | |
829 | 838 | | |
| |||
7137 | 7146 | | |
7138 | 7147 | | |
7139 | 7148 | | |
| 7149 | + | |
7140 | 7150 | | |
7141 | 7151 | | |
7142 | 7152 | | |
7143 | 7153 | | |
7144 | | - | |
7145 | | - | |
7146 | | - | |
7147 | | - | |
7148 | | - | |
| 7154 | + | |
| 7155 | + | |
| 7156 | + | |
| 7157 | + | |
| 7158 | + | |
| 7159 | + | |
7149 | 7160 | | |
7150 | 7161 | | |
7151 | | - | |
7152 | | - | |
7153 | | - | |
7154 | | - | |
| 7162 | + | |
| 7163 | + | |
| 7164 | + | |
| 7165 | + | |
| 7166 | + | |
| 7167 | + | |
| 7168 | + | |
| 7169 | + | |
| 7170 | + | |
| 7171 | + | |
| 7172 | + | |
| 7173 | + | |
| 7174 | + | |
7155 | 7175 | | |
7156 | | - | |
7157 | | - | |
7158 | | - | |
7159 | | - | |
| 7176 | + | |
| 7177 | + | |
| 7178 | + | |
| 7179 | + | |
| 7180 | + | |
| 7181 | + | |
| 7182 | + | |
| 7183 | + | |
| 7184 | + | |
| 7185 | + | |
| 7186 | + | |
| 7187 | + | |
| 7188 | + | |
7160 | 7189 | | |
7161 | 7190 | | |
7162 | 7191 | | |
| |||
7713 | 7742 | | |
7714 | 7743 | | |
7715 | 7744 | | |
| 7745 | + | |
| 7746 | + | |
| 7747 | + | |
| 7748 | + | |
| 7749 | + | |
| 7750 | + | |
| 7751 | + | |
| 7752 | + | |
| 7753 | + | |
| 7754 | + | |
| 7755 | + | |
| 7756 | + | |
| 7757 | + | |
7716 | 7758 | | |
7717 | 7759 | | |
7718 | 7760 | | |
| |||
8094 | 8136 | | |
8095 | 8137 | | |
8096 | 8138 | | |
| 8139 | + | |
| 8140 | + | |
| 8141 | + | |
| 8142 | + | |
| 8143 | + | |
| 8144 | + | |
| 8145 | + | |
| 8146 | + | |
| 8147 | + | |
| 8148 | + | |
| 8149 | + | |
| 8150 | + | |
| 8151 | + | |
| 8152 | + | |
| 8153 | + | |
| 8154 | + | |
| 8155 | + | |
| 8156 | + | |
| 8157 | + | |
| 8158 | + | |
| 8159 | + | |
| 8160 | + | |
| 8161 | + | |
| 8162 | + | |
| 8163 | + | |
| 8164 | + | |
| 8165 | + | |
| 8166 | + | |
| 8167 | + | |
| 8168 | + | |
| 8169 | + | |
| 8170 | + | |
| 8171 | + | |
| 8172 | + | |
| 8173 | + | |
| 8174 | + | |
| 8175 | + | |
| 8176 | + | |
| 8177 | + | |
| 8178 | + | |
| 8179 | + | |
| 8180 | + | |
| 8181 | + | |
| 8182 | + | |
| 8183 | + | |
| 8184 | + | |
| 8185 | + | |
| 8186 | + | |
| 8187 | + | |
| 8188 | + | |
| 8189 | + | |
| 8190 | + | |
| 8191 | + | |
| 8192 | + | |
| 8193 | + | |
| 8194 | + | |
| 8195 | + | |
| 8196 | + | |
| 8197 | + | |
| 8198 | + | |
| 8199 | + | |
| 8200 | + | |
| 8201 | + | |
| 8202 | + | |
| 8203 | + | |
| 8204 | + | |
| 8205 | + | |
| 8206 | + | |
| 8207 | + | |
| 8208 | + | |
| 8209 | + | |
| 8210 | + | |
| 8211 | + | |
| 8212 | + | |
| 8213 | + | |
| 8214 | + | |
| 8215 | + | |
| 8216 | + | |
| 8217 | + | |
8097 | 8218 | | |
8098 | 8219 | | |
8099 | 8220 | | |
| |||
0 commit comments