Repository navigation
Decouple multi-agent temporal networks and show the algorithms in examples - #8
Conversation
criterion 0.8.2, proptest 1.12 and libfuzzer-sys 0.4.13 are the newest releases; the requirements now name them so a fresh resolve cannot pick an older one. Cargo.lock is not tracked, so the resolved versions were already current. The pinned GitHub Actions and pre-commit hooks are already the latest releases outside the seven-day cooldown. proptest 1.12 needs Rust 1.88. Only tests use it, and the MSRV job checks the library alone, so the comment there now names proptest instead of criterion. The docs.rs mermaid script moves from 11.17.2 to 12.3.0 (12.4.0 is inside the cooldown). Mermaid 12 switches the default layout to ELK and the default look to "neo"; the script sets the dagre layout and the classic look so the existing diagrams keep their shape. Checked by rendering the multiagent module page in a browser.
Several agents (rovers, an orbiter) share timing constraints but can rarely communicate. The new `multiagent` module (alloc only) gives each agent a part of the plan it can dispatch alone: - `MultiAgentStn::decouple` adds reference-relative cuts on both sides of every shared distance-graph edge, chosen greedily at the midpoint of the feasible interval on an incremental minimal network. Any family of locally consistent schedules then combines into a schedule of the plan. Cuts are kept even for edges the joint windows already imply: those windows may come from other agents' constraints. - `Agent::add_constraint` accepts a local change inside the cuts without communication; `Agent::propose` records one that does not fit for the next communication window. - `Agent::summary` projects an agent onto its shared points (minimal network bounds, exact by decomposability), and `AgentGroup` builds the same joint network on every member. `AgentGroup::check_consistency` decides the group's consistency without a central solver, and `Agent::redecouple` adopts the proposals and redistributes the slack, keeping cuts towards agents outside the group. Summaries carry the group and the agent's revision; mismatched or stale sets are refused with the new `Error::MismatchedSummaries`, unknown agents with `Error::UnknownAgent`. - Communication windows are contingent links of an STNU; the module docs show the pattern and a deadline that breaks controllability. Property tests check that independently chosen local schedules combine, that the distributed check and an all-agent re-decoupling equal the central check and decoupling, and that a partial re-decoupling stays sound. Dropping the cuts of implied edges, or choosing cuts outside the feasible interval, makes them fail. Closes #7
Three examples, each asserting its own results and run as a test (`test = true`), so CI keeps them working: - rover_relay: two rovers and an orbiter decouple a plan, execute it without talking, absorb a delay locally, rebalance in a relay pass, and reject a conflicting proposal naming the shared constraint. - relay_pass: a lander downlinks through a relay pass with an uncertain opening: controllability, the explanation of a deadline that cannot hold, the checksummed uplink rejecting a flipped bit, and the heap-free u16 dispatcher reacting to each combination of contingent outcomes. - observation_campaign: a telescope night planned request by request on the incremental STN with a named conflict, a 200-field survey checked with P3C against Floyd-Warshall, and the filtered dispatchable night. The README lists them.
An agent lives on its own vehicle and a summary travels over a radio link, but both could only be built inside this crate. `AgentParts` with `Agent::from_parts` / `Agent::into_parts`, and `Summary::from_parts`, rebuild them from plain data and validate the structure (sorted points without the reference, constraints and cuts on own points, shared constraints that involve the agent); `Agent::from_parts` also checks the local network and explains an inconsistency. The wire format stays the integrator's. The docs now spell out the rest of the re-decoupling protocol: no member may change between sending its summary and adopting, a single refusal returns every member to its old cuts (a clone is the rollback), and points that already happened are pinned as local constraints before summarising. The rover example uplinks each part through `AgentParts`, and its re-decoupling happens at a contact before the sol starts, when nothing has executed yet.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8 +/- ##
==========================================
- Coverage 95.80% 95.72% -0.08%
==========================================
Files 28 32 +4
Lines 3192 3885 +693
==========================================
+ Hits 3058 3719 +661
- Misses 134 166 +32
🚀 New features to boost your workflow:
|
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (2 files in incremental diff, 19 in PR)
Previous Review Summaries (2 snapshots, latest commit 0bf5485)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 0bf5485)Status: No Issues Found | Recommendation: Merge Files Reviewed (3 files in incremental diff, 19 in PR)
Previous findings: the Previous review (commit 9aec33d)Status: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (19 files)
Reviewed by deepseek-v4.1-flash-1017 · Input: 25K · Output: 2.2K · Cached: 330K |
UnknownAgent and MismatchedSummaries were inserted after UnknownTimePoint, which shifted the discriminants of every later variant. cargo-semver-checks reports that as a major change, because code casting a variant with `as` would see a different value. The new variants now come last, with a comment saying why.
AgentGroup::conflict skipped a negative-cycle edge whose constraint had no recorded origin. Every constraint of the joint network gets one when it is added, so a miss means a broken invariant, and skipping it would hand back a conflict that silently leaves out part of the cycle. It is now Error::Internal, as elsewhere in the crate. redecouple computes the conflict before it drops the proposals, so the error leaves the agent unchanged.
|
Thanks for the review. Taking the two findings in turn: WARNING, SUGGESTION, Separately, CI's semver job caught a real break: the two new |
The example's tick loop kept `t` unchanged when `next_wakeup` returned None. A dispatcher left with points it can never execute would then spin forever, and since the example runs as a test, CI would time out instead of failing. The loop now stops once the plan is complete and otherwise expects a wakeup.
pick() carried its own LCG next to the xorshift Rng in tests/it/sim.rs that does the same job. It now draws from that Rng; the seed's low bit is forced on because xorshift never leaves zero.
Closes #7.
What and why
Several agents (rovers, an orbiter) share timing constraints but can rarely talk. This PR gives each agent a part of the plan it can dispatch and change alone, and lets agents that do get to communicate check changes together and redistribute slack without a central solver. It also adds three runnable examples for the crate's algorithms and bumps the dependency floors.
Multi-agent STNs (
multiagent,alloconly)MultiAgentStn::decouple. Every non-reference point has one owner. For each shared distance-graph edgeu -> v(weightw), it adds a cutt_u - z >= ctou's owner andt_v - z <= c + wtov's.cis the midpoint of the feasible interval, computed on an incremental minimal network. Any combination of locally consistent schedules is then a schedule of the plan.Agent::add_constraintaccepts a change that fits inside the cuts without any communication.Agent::proposerecords one that does not fit for the next contact.Agent::summaryprojects an agent onto its shared points: minimal-network bounds, exact because the minimal network is decomposable.AgentGroup::newbuilds the same joint network on every member, whatever order the summaries arrive in.AgentGroup::check_consistencydecides the group's consistency. A conflict names the shared constraints and the agents involved.Agent::redecoupleadopts the proposals, or drops them if the group is inconsistent. It recomputes the cuts of the group's shared constraints and keeps the cuts towards non-members.Stnu. The module docs show the pattern, plus a deadline that breaks controllability.AgentPartswithAgent::from_parts/into_parts, andSummary::from_parts, rebuild both types from plain data and validate them. The wire format stays the integrator's.Protocol limits, documented and not enforced:
Examples (
examples/, run as tests viatest = true)rover_relay— two rovers and an orbiter:AgentParts;relay_pass— a lander downlinks through a relay pass with an uncertain opening:Dispatcher<6, 64, u16>reacting to five combinations of contingent outcomes.observation_campaign:IncrementalStn, with a rejected request naming its conflicts;Dependencies
criterion0.8.2,proptest1.12 andlibfuzzer-sys0.4.13 are now the minimum versions.Cargo.lockis not tracked, so a fresh resolve already picked these. proptest 1.12 needs Rust 1.88 for tests only. The MSRV job checks the library alone, so the comment there is updated.layout: "dagre"andlook: "classic"to keep the existing diagrams.multiagentpage in a browser.Public API changes
multiagent, re-exported at the root:MultiAgentStn,Agent,AgentParts,AgentId,AgentGroup,Summary,SharedConstraint,Cut,GroupVerdict,GroupConflict.ErrorvariantsUnknownAgentandMismatchedSummaries.Erroris#[non_exhaustive], andcargo semver-checkspasses.README "Scope", "Who this is for" and the new "Examples" section are updated. In
docs/design.md:Testing
tests/it/multiagent.rs:task cipasses, as dotask semverandtask build:no-std(theno_stdbuild withoutallocis unaffected).src/dispatchis untouched.Review order
docs/design.md§3.4, for the argument.src/multiagent/cuts.rs(the cut rule and its proof).src/multiagent.rs.src/multiagent/agent.rsandgroup.rs.tests/it/multiagent.rs.