Test complete scenario anchors against real Scene geometry

This commit is contained in:
2026-09-12 17:01:57 -07:00
parent 66a1f1690f
commit 4b782a71fc
21 changed files with 9917 additions and 0 deletions
@@ -0,0 +1 @@
wiring.patch -text -whitespace
@@ -0,0 +1,95 @@
# Complete anchor plan into actual Scene — pending execution
Prepared 2026-09-12 in isolated branch `codex/behavior-anchor-plan-ytr83r-20260912`, base `66a1f1690f778c8814bfefff7f46fe7f6bbe520e`. Parent owns compilation and publication. **Not compiled or executed.** Only test-only additions to `crates/oa-desktop/src/behavior.rs` and this new directory were authored. The existing floor experiment and its fixtures are unchanged. All new production-file statements are guarded by `cfg(test)`; normal production rendering is unchanged.
## Bounded question
Can a complete ephemeral anchor plan drive the actual Scene at exact requested y coordinates without the old running-cursor floor, preserve unspecified anchors and the entire Document, and maintain covered extents and real lifecycle derivation? This isolates the integration seam from the unresolved choice of a product movement policy.
The old floor candidate imposed existing seed increments on every requested row. This candidate seeds missing anchors from the actual baseline Scene, then replaces explicitly requested coordinates exactly. It does not impose sequence-order constraints or overlap spacing. Source-order crossings are returned as diagnostic data, not silently clamped or converted into semantic Reorder. This is a mechanical projection experiment, not evidence that crossed vertical ordering is acceptable UX.
`Candidate` is an external map keyed by occurrence UUID. `Plan` is a complete resolved input for the currently visible Scene, including operand headers missing from the ordinary rows map. It contains row roles, derived message send/receive y values, frame bounds, sequence extents and canvas height. It is not a model, parser or REST payload.
## Actual code boundary and wiring
`wiring.patch` records the exact production-file delta from the base commit. The five new cfg(test) integration points are:
1. Include this module as a private child of `behavior`, next to the unchanged floor module.
2. Immediately after the old floor hook, consume the complete plan's exact occurrence anchor, before Scene records rows and constructs the occurrence's existing geometry.
3. Before inserting an existing fragment BoxItem, use the plan's frame bounds. Existing fragment paint and label code remain in place.
4. Immediately after recording a sequence's bounds, substitute planned bounds and update the existing final insertion axis. An earlier event placed lower than the last event cannot truncate the scope merely because traversal ends earlier.
5. Before current lifecycle and activation construction, substitute the covered canvas height. Current `Rendering::new`, message alignment, activation generation and drawing remain responsible for their actual geometry.
The plan is scoped per thread, inactive by default, restored by Drop during unwinding, and has a deliberate-panic test requiring the exact sentinel payload. Other tests on other threads cannot consume its plan. The original floor hooks remain operational when their own scope is active; the new plan is otherwise absent.
Footprints are measured from the actual baseline named boxes, message polylines and label bounds, translated by requested row deltas. This avoids cloning the renderer's line or lifecycle algorithms. Empty activation bars are excluded because the real renderer derives those later. Frames conservatively preserve seed extents and can grow downward; growth adds an explicitly experimental 20px presentation margin. A move requiring upward frame growth returns `FixedFrameHeaderWouldMove`, because the candidate cannot move an unspecified painted header while retaining its FrameStart and insertion slot. Mere overlap inside the existing frame is not categorically rejected. Sequence bounds preserve seed extents and measured edge padding while expanding to cover outliers; canvas height uses the original scope-to-canvas margin. Neither these margins nor nonshrinking seed extents are adopted user requirements. This is not a general container-resize solver.
## Independently expected checks
Thirteen new test functions use the existing hand-authored fixtures through the actual parser and Document bundle loader. Numeric expectations below are independently stated rather than generated from the new planner:
| Case | Expected actual Scene result |
| --- | --- |
| Empty complete plan, both fixtures | Same rows, named boxes and marker kinds, lines and labels, scopes, slots, lifecycle, open calls and size as the unmodified baseline Scene |
| Second delivery240→200 | First148; second200; every other occurrence anchor unchanged; both second-message endpoints200; repeated exchange references retain different occurrence IDs |
| Nested action477→457 | Box top437, height70; actual fragment metadata and active header332..370 retained, header hit still resolves the fragment, before-slot290 and label unchanged; operand bounds and all other anchors unchanged |
| Nested action→300 | Proposed footprint280..350 would relocate unspecified frame top332 to260; reject with `FixedFrameHeaderWouldMove` before rendering |
| Nested action→353 / admitted380 overlap | Proposed353 gives footprint333 and operand start311, outside fragment start332; reject with `OperandScopeOutsideEnclosingInterval`. At380 the box starts360 and overlaps the fixed header while scope338..530 stays feasible; actual lifecycle diagnostics remain empty, post-fragment alive span530..845 and later self-call bars remain unchanged |
| Create243→50 or84 | Reject with `LifecycleAnchorOutsideRenderScope`; actual root lifecycle span starts85 even when insertion-scope planning expands higher. At85 the real birth marker and alive span85..427 remain present |
| Death427→380 | Create243 and call335 stay fixed; real alive span243..380; actual bar335..380; death marker/hit moves to380; unresolved-call cue remains, no Reply is invented |
| Self-call636→610 | Actual send610/receive634, using the current24 offset; reply728 unchanged; MessageSend role distinguished from the lifecycle MessageReceive role |
| Signed zero and candidate restoration | Both0 and-0 return the exact original sparse candidate; no first-edit materialization; restoring the original candidate restores Scene geometry |
| First event→1000, last remains728 | First1000/second240, SourceOrderCrossing diagnostic, source order unchanged; root scope end1026 and height1113 cover the earlier outlier rather than the traversal tail |
| Nested action→1000 | Box top980/bottom1050; enclosing frame bottom1070; actual root scope/canvas cover it; following self-call636 remains fixed and overlap is diagnosed |
| Invalid/unsupported input | Unknown anchor, nonfinite y, compound frame movement and same-scope inverted birth/death fail explicitly |
| Scoped execution | Another thread sees baseline geometry; a deliberate panic restores the baseline scope |
The primary cases compare the entire Project and original SourceBundle and require the real Document to remain clean with no Undo/Redo entry. Canonical parser roundtrip is used, but it covers only the semantic Project: layout stays external. Candidate restoration is a reversible-sidecar check, **not** a production Undo implementation. No command has been added to Document.
## Explicit limitations and falsifiers
- Crossing source-ordered events is deliberately drawable with diagnostics. That proves removal of the mechanical floor, not adoption of unrestricted vertical notation. The crossing output remains an independent product-policy falsifier.
- An expanded frame can overlap the next event. Its diagnostic preserves that evidence instead of shifting the next event implicitly. The experiment does not establish a frame/header constraint policy or all feasible layouts.
- Upward growth that would relocate an unspecified frame header is explicitly unsupported. This does not ban arbitrary overlap gaps; the numeric380 example remains admitted. Full compound/header movement policy remains unresolved.
- A proposed operand interval escaping its actual enclosing fragment/caller interval returns `OperandScopeOutsideEnclosingInterval`. The353 example would otherwise cause the real lifecycle traversal to report MissingGeometry and make the later lifetime unresolved, potentially suppressing a self-call bar despite stable row coordinates. No generic gap or sibling-order rule is added. General nested/cross-operand placement remains unproven.
- Lifecycle receive anchors must be within the actual effective Rendering scope: root85..height-20, or its recorded non-root scope with the renderer's existing empty-scope allowance. Outside coordinates are rejected before exposing a Scene whose row exists but whose marker/lifetime is missing. This bounds the inspected bridge; it does not establish general ancestor/operand ordering or cross-operand lifetime support.
- The same-scope creation-after-deletion case returns `LifetimeInversionNotSupported` before rendering. Current lifecycle intervals cannot truthfully depict that inversion without another representation policy. This is an experimental bridge limitation, not permission to reject semantically valid models or a user-approved global movement rule. Cross-operand lifecycle combinations remain unproven.
- Compound frame/operand movement, box resizing, horizontal layout, independent send/receive movement, route editing, drag transaction stamps, pointer capture, dirty-source recovery, persistence, REST and native UI are not implemented.
- Self-call send and receive roles are explicit, but the current activation engine still owns its existing row-based behavior. Peer #21's typed activation integration must consume the actual receive anchor and retain the existing lifetime clipping. These tests do not silently bless the old activation-start discrepancy.
- Scope/containment walking is deliberately straightforward and not a large-model performance implementation. There is no responsiveness claim.
- Some self-message fixture exchanges are unassigned because the current global relation model forbids self edges. The existing fixture's known incomplete-model warnings remain; tests reject semantic errors.
No storage or parser design should be adopted from this adapter. Coordinate any eventual payload with prospective #7, whose required addressing must preserve diagram/owner/occurrence identity and explicit anchor roles. Coordinate inverse resize with #16 and typed activation/lifetime union with #21 before broad UI work.
The accumulating frame, scope and lifecycle dependencies show that this is only a bridge for demonstrated feasible positions, **not an adoptable free-editing architecture**. It neither establishes unrestricted placement nor selects a semantic constraint policy. Further fundamental contradictions should become explicit falsifiers for parent replanning, not an expanding list of speculative guards in this prototype.
Parent reports [peer #21 comment716](http://217.177.34.108:3000/sorokin.oleg.edu/ARCADIA-Studio/issues/21#issuecomment-716), posted2026-09-12 23:06UTC: Codex-956atf owns an isolated typed-activation/lifecycle source union. Its intended order is finalized rows/height, lifecycle construction and Create/Delete alignment, then typed Call/Reply attachment, with receiver/scope clipping, logical reply timing distinct from clipped geometry, no resurrection after Delete, and unanswered-call cues preserved. That WIP is not integrated here. Retain the explicit send/receive seam and review the future union against these fixtures; this paragraph records a coordination dependency, not verified acceptance of peer code.
## Reproduction and handoff
At the parent's chosen compiler checkpoint, use the configured Windows Rust/linker environment:
```powershell
cargo test -p oa-desktop --bin arcadia-studio --locked --offline -- behavior_layout_scene_experiment behavior_anchor_plan_experiment --list
cargo test -p oa-desktop --bin arcadia-studio --locked --offline -- behavior_layout_scene_experiment behavior_anchor_plan_experiment --nocapture
```
The listing must contain thirteen complete-anchor tests and ten existing floor/lifetime tests. The following execution must report all23 passed,0 failed,0 ignored. Both filter strings are passed to the same test binary. Preserve compile failures, parser failures, numeric mismatches and diagnostics as results. Do not claim success from a zero-test filtered run or from compiling only production targets. An intentional panic should be followed by its restoration test passing; another panic payload is a failure.
## Static review correction history
The frozen attempt1 candidate was preserved before these corrections. The [authoritative attempt1 archive](../behavior-anchor-plan-review-20260912/attempt1/manifest.json) preserves all five original files; the adjacent review report records the source-verified counterexamples. The pre-review failures are static, unexecuted findings: nested300 silently moved the frame header to260 while row332/slot290 stayed fixed, and Create50 was omitted as MissingGeometry by the actual root lifetime span starting85. The corrected candidate adds named unsupported errors and independent numeric checks rather than recording either original behavior as acceptance. Production hooks and the original floor experiment remain unchanged.
Before the third correction, parent preserved all five attempt2 files and matching hashes under `harness/experiments/behavior-anchor-plan-review-20260912/attempt2`. That static, unexecuted candidate still admitted nested353: its operand start311 preceded enclosing fragment332, causing MissingGeometry/Unresolved in the actual lifecycle source path. The third correction rejects that exact unsupported scope escape and replaces the positive overlap example with380, including actual lifecycle diagnostics, post-fragment spans and activation-bar preservation checks. The parent-owned review archive is not modified by this experiment.
Record exact compiled commit/uncommitted patch, commands and results before publication. Source hashes supplied with the handoff identify prepared bytes, not tested code. Root should publish the complete directory and exact behavior.rs delta so remote peers can reproduce it; workspace-local paths are not remote handoffs.
## Modeling intent: primary-source comparison
The [Sirius sequence user guide](https://eclipse.dev/sirius/doc/user/sequences/Sequence%20Diagrams.html#SequenceDiagramsSemantics) explicitly ties displayed event order to semantic order: moving an event across another can update the model. It separately describes horizontal lifeline movement, Create/Delete attachment and blank-space gestures. This is framework evidence; the exact Capella modifier, feedback and saved-file effects were not verified natively.
The [Sirius event-reorder specification](https://eclipse.dev/sirius/doc/specifier/sequences/Sequence%20Diagrams.html#EventReorderTool) provides separate predecessor information for start/send and finish/receive, including coupled synchronous-message movement. That supports preserving distinct endpoint roles; it does not specify a separate user-selected reorder mode.
Root inference: the user request for intuitive whole-arrow movement does not by itself require arbitrary cosmetic chronology crossing. Compare two coherent product gestures: presentation movement within semantic order plus an explicit reorder action, versus direct dragging that previews and commits a semantic reorder when crossing an event. Evaluate ordinary spacing, intentional order changes, accidental crossing, invalid call/reply/lifetime moves, cross-operand moves, discoverability, one-step Undo and exact preview/reopen behavior. A semantic reorder may change Project/source; presentation-only adjustment must retain semantic content. The current sidecar experiment tests the latter boundary and is not a universal nonmutation requirement for all future drag operations. No gesture or public schema is selected by this note.
Root formatting completed for the new Rust modules. Independent correction review found no new blocking source finding after the operand-scope repair, including non-vacuous actual lifetime/bar assertions. Compiler and runtime results remain pending. [Prepared input hashes](prepared-inputs.json) bind the current candidate, not an accepted build.
@@ -0,0 +1,448 @@
//! Experimental complete anchor input for the actual Scene, cfg(test) only.
//! No persistence schema and no replacement line/lifecycle/activation renderer.
use super::*;
use std::cell::RefCell;
mod tests;
type Candidate = BTreeMap<Id, f32>;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum AnchorRole {
MessageSend,
MessageReceive,
Observation,
FrameStart,
OperandStart,
}
#[derive(Clone, Copy, Debug, PartialEq)]
struct Anchor {
y: f32,
role: AnchorRole,
}
#[derive(Clone, Copy, Debug, PartialEq)]
struct MessageAnchors {
send_y: f32,
receive_y: f32,
}
#[derive(Clone, Debug, PartialEq, Eq)]
enum Diagnostic {
SourceOrderCrossing { scope: Id, before: Id, after: Id },
FrameExtendsPastFollowingAnchor { frame: Id, following: Id },
}
#[derive(Clone, Debug, PartialEq, Eq)]
enum PlanError {
UnknownAnchor(Id),
NonFinite(Id),
CompoundMoveNotImplemented(Id),
FixedFrameHeaderWouldMove { frame: Id },
OperandScopeOutsideEnclosingInterval { operand: Id, fragment: Id },
LifecycleAnchorOutsideRenderScope { occurrence: Id, scope: Id },
LifetimeInversionNotSupported { create: Id, delete: Id },
}
#[derive(Clone, Debug)]
struct Plan {
anchors: BTreeMap<Id, Anchor>,
messages: BTreeMap<Id, MessageAnchors>,
frames: BTreeMap<Id, Rectangle>,
scopes: BTreeMap<Id, (f32, f32)>,
height: f32,
diagnostics: Vec<Diagnostic>,
}
fn occurrence(p: &Project, id: Id) -> Option<&OccurrenceBody> {
match p.elements.get(&id)?.shared()? {
SharedBody::Occurrence { body, .. } => Some(body),
_ => None,
}
}
fn role(body: &OccurrenceBody) -> AnchorRole {
match body {
OccurrenceBody::Exchange {
message_kind: MessageKind::Create | MessageKind::Delete,
..
} => AnchorRole::MessageReceive,
OccurrenceBody::Exchange { .. } => AnchorRole::MessageSend,
OccurrenceBody::Fragment { .. } => AnchorRole::FrameStart,
OccurrenceBody::Branch { .. } => AnchorRole::OperandStart,
_ => AnchorRole::Observation,
}
}
fn inside(p: &Project, id: Id, owner: Id) -> bool {
let mut current = p.elements.get(&id).and_then(|e| e.parent);
for _ in 0..p.elements.len() {
match current {
Some(parent) if parent == owner => return true,
Some(parent) => current = p.elements.get(&parent).and_then(|e| e.parent),
None => return false,
}
}
false
}
fn depth(p: &Project, id: Id) -> usize {
let mut current = p.elements.get(&id).and_then(|e| e.parent);
let mut result = 0;
while let Some(parent) = current {
result += 1;
if result > p.elements.len() {
break;
}
current = p.elements.get(&parent).and_then(|e| e.parent);
}
result
}
fn union(a: Rectangle, b: Rectangle) -> Rectangle {
let x = a.x.min(b.x);
let y = a.y.min(b.y);
Rectangle::new(
Point::new(x, y),
Size::new(
(a.x + a.width).max(b.x + b.width) - x,
(a.y + a.height).max(b.y + b.height) - y,
),
)
}
/// Actual named shapes/message paths supply footprint measurements; activation
/// bars are intentionally excluded because current Scene derives them later.
fn footprints(
scene: &Scene,
anchors: &BTreeMap<Id, Anchor>,
seed: &BTreeMap<Id, Anchor>,
) -> BTreeMap<Id, Rectangle> {
let mut out = BTreeMap::new();
for item in scene.boxes.iter().filter(|item| !item.title.is_empty()) {
let Some(anchor) = anchors.get(&item.id) else {
continue;
};
let mut rect = item.rect;
rect.y += anchor.y - seed[&item.id].y;
out.insert(item.id, rect);
}
for line in &scene.lines {
let Some(anchor) = anchors.get(&line.id) else {
continue;
};
let delta = anchor.y - seed[&line.id].y;
let mut rect = line.label_bounds();
rect.y += delta;
for point in &line.points {
rect = union(
rect,
Rectangle::new(Point::new(point.x, point.y + delta), Size::ZERO),
);
}
out.entry(line.id)
.and_modify(|old| *old = union(*old, rect))
.or_insert(rect);
}
out
}
fn covered_bounds(
p: &Project,
owner: Id,
footprints: &BTreeMap<Id, Rectangle>,
) -> Option<Rectangle> {
footprints
.iter()
.filter(|(id, _)| inside(p, **id, owner))
.map(|(_, rect)| *rect)
.reduce(union)
}
impl Plan {
fn build(
p: &Project,
owner: Id,
baseline: &Scene,
desired: &Candidate,
) -> Result<Self, PlanError> {
let mut seed: BTreeMap<_, _> = baseline
.rows
.iter()
.map(|(id, (_, y))| {
(
*id,
Anchor {
y: *y,
role: role(occurrence(p, *id).expect("Scene occurrence")),
},
)
})
.collect();
// Operand headers are real Scene boxes, but are not entries in rows.
for item in &baseline.boxes {
if matches!(occurrence(p, item.id), Some(OccurrenceBody::Branch { .. })) {
seed.insert(
item.id,
Anchor {
y: item.rect.y,
role: AnchorRole::OperandStart,
},
);
}
}
let mut anchors = seed.clone();
for (&id, &y) in desired {
let anchor = anchors.get_mut(&id).ok_or(PlanError::UnknownAnchor(id))?;
if !y.is_finite() {
return Err(PlanError::NonFinite(id));
}
if matches!(
anchor.role,
AnchorRole::FrameStart | AnchorRole::OperandStart
) && y != anchor.y
{
return Err(PlanError::CompoundMoveNotImplemented(id));
}
anchor.y = y;
}
let mut messages = BTreeMap::new();
for line in &baseline.lines {
if let (Some(anchor), Some(first), Some(last)) = (
anchors.get(&line.id),
line.points.first(),
line.points.last(),
) {
let delta = anchor.y - seed[&line.id].y;
messages.insert(
line.id,
MessageAnchors {
send_y: first.y + delta,
receive_y: last.y + delta,
},
);
}
}
// The current lifecycle bridge needs positive birth/death intervals.
// This is an explicit unsupported crossing, not a new semantic rule.
for (&create, message) in &messages {
if let Some(OccurrenceBody::Exchange {
message_kind: MessageKind::Create,
receiver: Some(lane),
..
}) = occurrence(p, create)
{
for (&delete, finish) in &messages {
if p.elements[&create].parent == p.elements[&delete].parent
&& matches!(occurrence(p, delete), Some(OccurrenceBody::Exchange { message_kind: MessageKind::Delete, receiver: Some(other), .. }) if other == lane)
&& message.receive_y > finish.receive_y
{
return Err(PlanError::LifetimeInversionNotSupported { create, delete });
}
}
}
}
let old_footprints = footprints(baseline, &seed, &seed);
let mut drawn = footprints(baseline, &anchors, &seed);
let mut frames = BTreeMap::new();
let mut containers: Vec<_> = seed
.keys()
.copied()
.filter(|id| matches!(occurrence(p, *id), Some(OccurrenceBody::Fragment { .. })))
.collect();
containers.sort_by_key(|id| std::cmp::Reverse(depth(p, *id)));
for id in containers {
let original = old_footprints[&id];
let mut rect = original;
if let Some(covered) = covered_bounds(p, id, &drawn) {
// Keep seed extents where possible; 20px growth padding is an
// explicit experimental presentation preference, not semantics.
// Upward envelope growth would move the painted frame header
// while its fixed FrameStart/row/slot remained at the seed.
// Reject that unsupported compound change, not mere overlap.
if covered.y < rect.y {
return Err(PlanError::FixedFrameHeaderWouldMove { frame: id });
}
if covered.y + covered.height > rect.y + rect.height {
rect.height = covered.y + covered.height + 20. - rect.y;
}
}
frames.insert(id, rect);
drawn.insert(id, rect);
}
let mut scopes = baseline.sequence_bounds.clone();
for (&scope, bounds) in &mut scopes {
if let (Some(old), Some(new)) = (
covered_bounds(p, scope, &old_footprints),
covered_bounds(p, scope, &drawn),
) {
let top_padding = (old.y - bounds.0).max(0.);
let bottom_padding = (bounds.1 - old.y - old.height).max(0.);
if new.y < bounds.0 {
bounds.0 = new.y - top_padding;
}
bounds.1 = bounds.1.max(new.y + new.height + bottom_padding);
}
}
let tail = baseline.size.height - baseline.sequence_bounds[&owner].1;
let height = baseline.size.height.max(scopes[&owner].1 + tail);
for (&operand, &(start, end)) in &scopes {
if !matches!(occurrence(p, operand), Some(OccurrenceBody::Branch { .. })) {
continue;
}
let fragment = p.elements[&operand].parent.expect("operand fragment");
let caller = p.elements[&fragment]
.parent
.expect("fragment caller sequence");
let enclosing_frame = frames[&fragment];
let (caller_start, caller_end) = if caller == owner {
(85., height - 20.)
} else {
let (a, b) = scopes[&caller];
(a, if a == b { a + 26. } else { b })
};
let enclosing_start = anchors[&fragment].y.max(caller_start);
let enclosing_end = (enclosing_frame.y + enclosing_frame.height).min(caller_end);
let effective_end = if start == end { start + 26. } else { end };
// Actual lifecycle traversal cannot enter an operand that escapes
// this enclosing interval. This guards bridge feasibility only;
// it is not a generic event-spacing or sibling-ordering policy.
if start < enclosing_start || effective_end > enclosing_end {
return Err(PlanError::OperandScopeOutsideEnclosingInterval { operand, fragment });
}
}
for (&id, message) in &messages {
if matches!(
occurrence(p, id),
Some(OccurrenceBody::Exchange {
message_kind: MessageKind::Create | MessageKind::Delete,
..
})
) {
let scope = p.elements[&id].parent.expect("lifecycle sequence owner");
// Match Rendering::new's effective scope, not the insertion
// scope: it overrides the root span to 85..height-20 and gives
// empty non-root scopes the existing 26px lifetime allowance.
let (start, end) = if scope == owner {
(85., height - 20.)
} else if let Some(&(start, end)) = scopes.get(&scope) {
(start, if start == end { start + 26. } else { end })
} else {
return Err(PlanError::LifecycleAnchorOutsideRenderScope {
occurrence: id,
scope,
});
};
if message.receive_y < start || message.receive_y > end {
return Err(PlanError::LifecycleAnchorOutsideRenderScope {
occurrence: id,
scope,
});
}
}
}
let mut diagnostics = Vec::new();
for element in p
.elements
.values()
.filter(|e| e.id == owner || inside(p, e.id, owner))
{
if let Some(steps) = element.steps() {
for pair in steps.windows(2) {
if let (Some(a), Some(b)) = (anchors.get(&pair[0]), anchors.get(&pair[1])) {
if a.y > b.y {
diagnostics.push(Diagnostic::SourceOrderCrossing {
scope: element.id,
before: pair[0],
after: pair[1],
});
}
if let Some(frame) = frames.get(&pair[0]) {
if frame.y + frame.height > b.y {
diagnostics.push(Diagnostic::FrameExtendsPastFollowingAnchor {
frame: pair[0],
following: pair[1],
});
}
}
}
}
}
}
Ok(Self {
anchors,
messages,
frames,
scopes,
height,
diagnostics,
})
}
}
thread_local! {
static PLAN: RefCell<Option<Plan>> = const { RefCell::new(None) };
}
struct Scope(Option<Plan>);
impl Scope {
fn install(plan: &Plan) -> Self {
Self(PLAN.with(|slot| slot.replace(Some(plan.clone()))))
}
}
impl Drop for Scope {
fn drop(&mut self) {
PLAN.with(|slot| {
slot.replace(self.0.take());
});
}
}
pub(super) fn row_anchor(id: Id, y: &mut f32) {
PLAN.with(|slot| {
if let Some(plan) = slot.borrow().as_ref() {
*y = plan.anchors.get(&id).expect("complete Scene anchor plan").y;
}
});
}
pub(super) fn frame_bounds(id: Id, fallback: Rectangle) -> Rectangle {
PLAN.with(|slot| {
slot.borrow()
.as_ref()
.map_or(fallback, |plan| plan.frames[&id])
})
}
pub(super) fn scope_end(owner: Id, y: &mut f32, bounds: &mut BTreeMap<Id, (f32, f32)>) {
PLAN.with(|slot| {
if let Some(plan) = slot.borrow().as_ref() {
bounds.insert(owner, plan.scopes[&owner]);
*y = plan.scopes[&owner].1 + 42.; // Existing insertion-axis offset.
}
});
}
pub(super) fn scene_extent(scene: &mut Scene) {
PLAN.with(|slot| {
if let Some(plan) = slot.borrow().as_ref() {
scene.size.height = plan.height;
}
});
}
fn render(p: &Project, owner: Id, plan: &Plan) -> Scene {
let _scope = Scope::install(plan);
Scene::sequence(p, owner, owner)
}
fn drag(original: &Candidate, frame: &Scene, target: Id, delta_y: f32) -> Candidate {
assert!(delta_y.is_finite());
if delta_y == 0. {
return original.clone();
}
let mut result = original.clone();
result.insert(target, frame.rows[&target].1 + delta_y);
result
}
@@ -0,0 +1,31 @@
{
"base": "66a1f1690f778c8814bfefff7f46fe7f6bbe520e",
"status": "Formatted candidate; uncompiled and unexecuted",
"files": [
{
"path": "crates/oa-desktop/src/behavior.rs",
"bytes": 137409,
"sha256": "5884ba35ad994eb5936ca29c071a5002efc221dc42ef35e2265d50593bdf60ec"
},
{
"path": "harness/experiments/behavior-anchor-plan-20260912/mod.rs",
"bytes": 15658,
"sha256": "cfa848bcf1f8f48324f5cd746944c9b8b4959e6aa086a7726b922d6a01cbbf3c"
},
{
"path": "harness/experiments/behavior-anchor-plan-20260912/tests.rs",
"bytes": 25567,
"sha256": "c93b5668872217888c517df549fb6bea99fbc5642fdf8c2e55bdd92537df07b8"
},
{
"path": "harness/experiments/behavior-anchor-plan-20260912/README.md",
"bytes": 16350,
"sha256": "da062779c90c7b9f0696f697521c1b0055c58d473329ac1817a55b0ba0f88370"
},
{
"path": "harness/experiments/behavior-anchor-plan-20260912/wiring.patch",
"bytes": 2131,
"sha256": "4ce4bc45fbc419eba6a07b048b82efb8d85525514e3d2e56421948e7733f40fd"
}
]
}
@@ -0,0 +1,727 @@
use super::*;
use crate::document::Document;
use oa_core::{
language,
source_project::{ProjectLimits, SourceBundle},
validation,
};
fn id(p: &Project, alias: &str) -> Id {
p.identities()
.into_iter()
.find(|(_, name)| *name == alias)
.unwrap()
.0
}
fn fixture(lifetime: bool) -> (Document, Id) {
let (name, input, owner) = if lifetime {
(
"lifetime.arcadia",
include_str!("../behavior-layout-scene-20260912/lifetime.arcadia"),
"lifetime_conversation",
)
} else {
(
"fixture.arcadia",
include_str!("../behavior-layout-scene-20260912/fixture.arcadia"),
"conversation",
)
};
let p = language::parse(input).expect("existing real Arcadia fixture");
let errors: Vec<_> = validation::validate(&p)
.into_iter()
.filter(|issue| issue.severity == validation::Severity::Error)
.collect();
assert!(errors.is_empty(), "{errors:?}");
let bundle = SourceBundle {
entry: name.into(),
files: BTreeMap::from([(name.into(), input.into())]),
};
let document = Document::from_bundle(bundle, ProjectLimits::default()).unwrap();
assert_eq!(document.project(), &p);
assert_eq!(language::parse(&language::format(&p)).unwrap(), p);
let owner = id(&p, owner);
(document, owner)
}
fn passive(document: &Document, before: &Project, source: &SourceBundle) {
assert_eq!(document.project(), before);
assert_eq!(document.bundle(), source);
assert!(!document.dirty());
assert!(!document.can_undo() && !document.can_redo());
}
fn row(scene: &Scene, id: Id) -> f32 {
scene.rows[&id].1
}
fn line(scene: &Scene, id: Id) -> &Line {
assert_eq!(scene.lines.iter().filter(|line| line.id == id).count(), 1);
scene.lines.iter().find(|line| line.id == id).unwrap()
}
fn named_box(scene: &Scene, id: Id) -> &BoxItem {
scene
.boxes
.iter()
.find(|item| item.id == id && !item.title.is_empty())
.unwrap()
}
fn same_scene(a: &Scene, b: &Scene) {
assert_eq!(a.rows, b.rows);
assert_eq!(a.sequence_bounds, b.sequence_bounds);
assert_eq!(a.size, b.size);
assert_eq!(a.lanes, b.lanes);
assert_eq!(a.lifecycle, b.lifecycle);
assert_eq!(a.open_calls, b.open_calls);
let boxes = |s: &Scene| {
s.boxes
.iter()
.map(|b| (b.id, b.rect, b.title.clone(), b.detail.clone(), b.marker))
.collect::<Vec<_>>()
};
let lines = |s: &Scene| {
s.lines
.iter()
.map(|l| {
(
l.id,
l.points.clone(),
l.label_at,
l.label.clone(),
l.dashed,
)
})
.collect::<Vec<_>>()
};
let slots = |s: &Scene| {
s.slots
.iter()
.map(|slot| {
(
slot.slot.parent,
slot.slot.before,
slot.y,
slot.label.clone(),
)
})
.collect::<Vec<_>>()
};
assert_eq!(boxes(a), boxes(b));
assert_eq!(lines(a), lines(b));
assert_eq!(slots(a), slots(b));
}
fn others_fixed(before: &Scene, after: &Scene, changed: Id) {
assert_eq!(before.rows.len(), after.rows.len());
for (&id, original) in &before.rows {
if id != changed {
assert_eq!(&after.rows[&id], original, "unexpected movement of {id}");
}
}
}
fn fixed_frame_metadata(before: &Scene, after: &Scene, frame: Id) {
let original = named_box(before, frame);
let current = named_box(after, frame);
assert_eq!(
(
current.id,
current.rect,
&current.title,
&current.detail,
current.marker
),
(
original.id,
original.rect,
&original.title,
&original.detail,
original.marker
)
);
assert_eq!(before.rows[&frame], after.rows[&frame]);
assert_eq!(row(after, frame), 332.);
// Scene::hit uses the first38px as the frame's active painted header.
let header = Rectangle::new(
Point::new(original.rect.x, original.rect.y),
Size::new(original.rect.width, 38.),
);
assert_eq!((header.y, header.y + header.height), (332., 370.));
let probe = Point::new(header.x + 8., header.y + 8.);
assert_eq!(before.hit(probe), Some(frame));
assert_eq!(after.hit(probe), Some(frame));
let original_slot = before
.slots
.iter()
.find(|slot| slot.slot.before == Some(frame))
.unwrap();
let current_slot = after
.slots
.iter()
.find(|slot| slot.slot.before == Some(frame))
.unwrap();
assert_eq!(
(
current_slot.slot.parent,
current_slot.slot.before,
current_slot.y,
&current_slot.label
),
(
original_slot.slot.parent,
original_slot.slot.before,
original_slot.y,
&original_slot.label
)
);
assert_eq!(current_slot.y, 290.);
}
fn actual_lifetime_projection(
p: &Project,
owner: Id,
scene: &Scene,
) -> Vec<scenario_lifecycle::LaneLifetime> {
// Same actual rows/scope inputs as Rendering::new, including its root span
// and empty-operand allowance; call the real projector for diagnostics.
let mut scopes = scene.sequence_bounds.clone();
for (&scope, (start, end)) in &mut scopes {
if scope != owner && *start == *end {
*end = *start + 26.;
}
}
scopes.insert(owner, (85., scene.size.height - 20.));
scenario_lifecycle::project_lifetimes(
p,
owner,
&scenario_lifecycle::Geometry {
rows: &scene.rows,
scopes: &scopes,
},
)
}
#[test]
fn complete_seed_plan_preserves_both_actual_scene_and_document_baselines() {
for lifetime in [false, true] {
let (document, owner) = fixture(lifetime);
let p = document.project();
let before = p.clone();
let source = document.bundle().clone();
let baseline = Scene::sequence(p, owner, owner);
let plan = Plan::build(p, owner, &baseline, &Candidate::new()).unwrap();
assert!(plan.diagnostics.is_empty());
for (&id, (_, y)) in &baseline.rows {
assert_eq!(plan.anchors[&id].y, *y);
}
same_scene(&baseline, &render(p, owner, &plan));
let reparsed = language::parse(&language::format(p)).unwrap();
same_scene(&baseline, &render(&reparsed, owner, &plan));
passive(&document, &before, &source);
}
}
#[test]
fn upward_second_delivery_reaches_200_and_all_other_occurrence_anchors_stay_fixed() {
let (document, owner) = fixture(false);
let p = document.project();
let before = p.clone();
let source = document.bundle().clone();
let baseline = Scene::sequence(p, owner, owner);
let first = id(p, "first");
let second = id(p, "second");
assert_ne!(first, second);
for occurrence_id in [first, second] {
assert!(
matches!(occurrence(p,occurrence_id),Some(OccurrenceBody::Exchange { exchange:Some(edge),.. }) if *edge==id(p,"channel"))
);
}
assert_eq!(
(row(&baseline, first), row(&baseline, second)),
(148., 240.)
);
let candidate = drag(&Candidate::new(), &baseline, second, -40.);
assert_eq!(candidate, Candidate::from([(second, 200.)]));
let plan = Plan::build(p, owner, &baseline, &candidate).unwrap();
let moved = render(p, owner, &plan);
assert_eq!((row(&moved, first), row(&moved, second)), (148., 200.));
others_fixed(&baseline, &moved, second);
assert_eq!(line(&moved, first).points, line(&baseline, first).points);
let left = moved.lanes[&id(p, "left")];
let right = moved.lanes[&id(p, "right")];
assert_eq!(
line(&moved, second).points,
vec![Point::new(left, 200.), Point::new(right, 200.)]
);
assert_eq!(
plan.messages[&second],
MessageAnchors {
send_y: 200.,
receive_y: 200.
}
);
assert!(plan.diagnostics.is_empty());
same_scene(&moved, &render(p, owner, &plan));
passive(&document, &before, &source);
}
#[test]
fn nested_upward_anchor_reaches_457_without_moving_parent_or_followers() {
let (document, owner) = fixture(false);
let p = document.project();
let before = p.clone();
let source = document.bundle().clone();
let baseline = Scene::sequence(p, owner, owner);
let nested = id(p, "nested");
let fragment = id(p, "fragment");
assert_eq!(row(&baseline, nested), 477.);
let candidate = drag(&Candidate::new(), &baseline, nested, -20.);
let plan = Plan::build(p, owner, &baseline, &candidate).unwrap();
let moved = render(p, owner, &plan);
assert_eq!(row(&moved, nested), 457.);
assert_eq!(named_box(&moved, nested).rect.y, 437.);
assert_eq!(named_box(&moved, nested).rect.height, 70.);
assert_eq!(
named_box(&moved, fragment).rect,
named_box(&baseline, fragment).rect
);
assert_eq!(
(
named_box(&moved, fragment).rect.y,
named_box(&moved, fragment).rect.height
),
(332., 240.)
);
fixed_frame_metadata(&baseline, &moved, fragment);
assert_eq!(
moved.sequence_bounds[&id(p, "operand")],
baseline.sequence_bounds[&id(p, "operand")]
);
others_fixed(&baseline, &moved, nested);
assert!(plan.diagnostics.is_empty());
passive(&document, &before, &source);
}
#[test]
fn nested_move_that_would_relocate_fixed_header_is_rejected_but_mere_overlap_is_not_banned() {
let (document, owner) = fixture(false);
let p = document.project();
let before = p.clone();
let source = document.bundle().clone();
let baseline = Scene::sequence(p, owner, owner);
let nested = id(p, "nested");
let fragment = id(p, "fragment");
let requested = Candidate::from([(nested, 300.)]);
// Actual70px action box has row-to-top offset-20: proposed footprint280..350.
// The old envelope union would move frame/header top332 to260 while leaving
// FrameStart332 and before-slot290. Reject before any such Scene is exposed.
let original = named_box(&baseline, nested).rect;
assert_eq!(
(row(&baseline, nested), original.y, original.height),
(477., 457., 70.)
);
let proposed_top = original.y + (300. - row(&baseline, nested));
assert_eq!((proposed_top, proposed_top + original.height), (280., 350.));
assert_eq!(
Plan::build(p, owner, &baseline, &requested).unwrap_err(),
PlanError::FixedFrameHeaderWouldMove { frame: fragment }
);
fixed_frame_metadata(&baseline, &Scene::sequence(p, owner, owner), fragment);
// Overlap inside the existing frame does not itself move its top. This
// remains admitted mechanical geometry, not a claim of usable overlap UX.
let overlap = Plan::build(p, owner, &baseline, &Candidate::from([(nested, 380.)])).unwrap();
let overlapping = render(p, owner, &overlap);
assert_eq!(named_box(&overlapping, nested).rect.y, 360.);
assert_eq!(overlapping.sequence_bounds[&id(p, "operand")], (338., 530.));
fixed_frame_metadata(&baseline, &overlapping, fragment);
let original_lifetimes = actual_lifetime_projection(p, owner, &baseline);
let moved_lifetimes = actual_lifetime_projection(p, owner, &overlapping);
assert_eq!(original_lifetimes.len(), 2);
assert_eq!(moved_lifetimes.len(), 2);
assert!(
original_lifetimes
.iter()
.all(|lane| lane.uncertainties.is_empty())
);
assert!(
moved_lifetimes
.iter()
.all(|lane| lane.uncertainties.is_empty()),
"{moved_lifetimes:?}"
);
let receiver = id(p, "right");
for scene in [&baseline, &overlapping] {
assert_eq!(
scene
.lifecycle
.alive_spans(receiver, owner, 530., scene.size.height - 20.)
.iter()
.map(|span| (span.start, span.end))
.collect::<Vec<_>>(),
vec![(530., 845.)]
);
}
let call = id(p, "self_call");
let bars = |scene: &Scene| {
scene
.boxes
.iter()
.filter(|item| item.id == call && item.title.is_empty())
.map(|item| (item.rect, item.marker))
.collect::<Vec<_>>()
};
assert!(!bars(&baseline).is_empty());
assert_eq!(bars(&overlapping), bars(&baseline));
passive(&document, &before, &source);
}
#[test]
fn nested353_scope_escape_is_named_and_rejected_before_missing_lifecycle_geometry_is_exposed() {
let (document, owner) = fixture(false);
let p = document.project();
let before = p.clone();
let source = document.bundle().clone();
let baseline = Scene::sequence(p, owner, owner);
let nested = id(p, "nested");
let operand = id(p, "operand");
let fragment = id(p, "fragment");
let original = named_box(&baseline, nested).rect;
assert_eq!(
(original.y, baseline.sequence_bounds[&operand].0),
(457., 435.)
);
let proposed_top = original.y + (353. - row(&baseline, nested));
let proposed_scope_start = proposed_top - (original.y - baseline.sequence_bounds[&operand].0);
assert_eq!(
(proposed_top, proposed_scope_start, row(&baseline, fragment)),
(333., 311., 332.)
);
assert_eq!(
Plan::build(p, owner, &baseline, &Candidate::from([(nested, 353.)])).unwrap_err(),
PlanError::OperandScopeOutsideEnclosingInterval { operand, fragment }
);
same_scene(&baseline, &Scene::sequence(p, owner, owner));
passive(&document, &before, &source);
}
#[test]
fn lifecycle_anchor_below_actual_root_render_scope_is_rejected_before_scene_construction() {
let (document, owner) = fixture(true);
let p = document.project();
let before = p.clone();
let source = document.bundle().clone();
let baseline = Scene::sequence(p, owner, owner);
let create = id(p, "create_receiver");
let provider = id(p, "provider");
let requester = id(p, "requester");
let root_life = baseline
.lifecycle
.alive_spans(requester, owner, 0., baseline.size.height);
assert_eq!(
root_life
.iter()
.map(|span| (span.start, span.end))
.collect::<Vec<_>>(),
vec![(85., 544.)]
);
for requested in [50., 84.] {
assert_eq!(
Plan::build(p, owner, &baseline, &Candidate::from([(create, requested)])).unwrap_err(),
PlanError::LifecycleAnchorOutsideRenderScope {
occurrence: create,
scope: owner
}
);
}
// At the renderer's actual85 boundary the marker/lifetime remains present.
// Source-order crossing is still diagnosed separately, not silently banned.
let boundary = Plan::build(p, owner, &baseline, &Candidate::from([(create, 85.)])).unwrap();
let moved = render(p, owner, &boundary);
let x = moved.lanes[&provider];
assert_eq!(row(&moved, create), 85.);
assert_eq!(moved.lifecycle.marker_at(Point::new(x, 85.)), Some(create));
let alive = moved
.lifecycle
.alive_spans(provider, owner, 0., moved.size.height);
assert_eq!(
alive
.iter()
.map(|span| (span.start, span.end))
.collect::<Vec<_>>(),
vec![(85., 427.)]
);
passive(&document, &before, &source);
}
#[test]
fn earlier_death_reaches_380_and_actual_lifetime_and_activation_clip_there() {
let (document, owner) = fixture(true);
let p = document.project();
let before = p.clone();
let source = document.bundle().clone();
let baseline = Scene::sequence(p, owner, owner);
let create = id(p, "create_receiver");
let call = id(p, "service_call");
let delete = id(p, "delete_receiver");
let provider = id(p, "provider");
assert_eq!(
(
row(&baseline, create),
row(&baseline, call),
row(&baseline, delete)
),
(243., 335., 427.)
);
let candidate = drag(&Candidate::new(), &baseline, delete, -47.);
let plan = Plan::build(p, owner, &baseline, &candidate).unwrap();
assert_eq!(plan.anchors[&delete].role, AnchorRole::MessageReceive);
assert_eq!(
plan.messages[&delete],
MessageAnchors {
send_y: 380.,
receive_y: 380.
}
);
let moved = render(p, owner, &plan);
assert_eq!(row(&moved, delete), 380.);
others_fixed(&baseline, &moved, delete);
let spans = moved
.lifecycle
.alive_spans(provider, owner, 85., moved.size.height - 20.);
assert_eq!(
spans.iter().map(|s| (s.start, s.end)).collect::<Vec<_>>(),
vec![(243., 380.)]
);
assert!(
moved
.lifecycle
.alive_spans(provider, owner, 380., moved.size.height - 20.)
.is_empty()
);
let x = moved.lanes[&provider];
assert_eq!(moved.lifecycle.marker_at(Point::new(x, 380.)), Some(delete));
assert_eq!(moved.lifecycle.marker_at(Point::new(x, 427.)), None);
assert_eq!(moved.hit(Point::new(x, 380.)), Some(delete));
let bars: Vec<_> = moved
.boxes
.iter()
.filter(|b| b.id == call && b.title.is_empty())
.collect();
assert_eq!(bars.len(), 1);
assert_eq!(
bars[0].rect,
Rectangle::new(Point::new(x - 4., 335.), Size::new(8., 45.))
);
assert_eq!(moved.open_calls, vec![Point::new(x + 12., 364.)]);
assert!(plan.diagnostics.is_empty());
passive(&document, &before, &source);
}
#[test]
fn self_call_has_explicit_send610_receive634_and_reply_stays728() {
let (document, owner) = fixture(false);
let p = document.project();
let before = p.clone();
let source = document.bundle().clone();
let baseline = Scene::sequence(p, owner, owner);
let call = id(p, "self_call");
let reply = id(p, "self_reply");
let candidate = drag(&Candidate::new(), &baseline, call, -26.);
let plan = Plan::build(p, owner, &baseline, &candidate).unwrap();
assert_eq!(
plan.anchors[&call],
Anchor {
y: 610.,
role: AnchorRole::MessageSend
}
);
assert_eq!(
plan.messages[&call],
MessageAnchors {
send_y: 610.,
receive_y: 634.
}
);
let moved = render(p, owner, &plan);
assert_eq!(row(&moved, call), 610.);
assert_eq!(row(&moved, reply), 728.);
assert_eq!(
line(&moved, call)
.points
.iter()
.map(|p| p.y)
.collect::<Vec<_>>(),
vec![610., 610., 634., 634.]
);
assert_eq!(line(&moved, reply).points, line(&baseline, reply).points);
others_fixed(&baseline, &moved, call);
// Peer #21 owns the activation start/column contract. This assertion covers
// actual message anchors, not the old row-based activation start defect.
passive(&document, &before, &source);
}
#[test]
fn signed_zero_keeps_sparse_candidate_and_restoring_original_candidate_restores_actual_scene() {
let (document, owner) = fixture(false);
let p = document.project();
let before = p.clone();
let source = document.bundle().clone();
let baseline = Scene::sequence(p, owner, owner);
let second = id(p, "second");
let original = Candidate::new();
for zero in [0., -0.] {
assert_eq!(drag(&original, &baseline, second, zero), original);
}
let changed = drag(&original, &baseline, second, -40.);
let plan = Plan::build(p, owner, &baseline, &changed).unwrap();
let frame = render(p, owner, &plan);
for zero in [0., -0.] {
let untouched = drag(&changed, &frame, second, zero);
assert_eq!(untouched, changed);
same_scene(
&frame,
&render(
p,
owner,
&Plan::build(p, owner, &baseline, &untouched).unwrap(),
),
);
}
// This restores the exact sidecar candidate; it is not a production Undo
// command or evidence of a layout source/REST persistence implementation.
same_scene(
&baseline,
&render(
p,
owner,
&Plan::build(p, owner, &baseline, &original).unwrap(),
),
);
passive(&document, &before, &source);
}
#[test]
fn crossing_is_rendered_exactly_and_diagnosed_with_extents_covering_the_earlier_far_event() {
let (document, owner) = fixture(false);
let p = document.project();
let before = p.clone();
let source = document.bundle().clone();
let baseline = Scene::sequence(p, owner, owner);
let first = id(p, "first");
let second = id(p, "second");
let plan = Plan::build(p, owner, &baseline, &Candidate::from([(first, 1000.)])).unwrap();
assert!(plan.diagnostics.contains(&Diagnostic::SourceOrderCrossing {
scope: owner,
before: first,
after: second
}));
let moved = render(p, owner, &plan);
assert_eq!((row(&moved, first), row(&moved, second)), (1000., 240.));
assert_eq!(row(&moved, id(p, "self_reply")), 728.);
others_fixed(&baseline, &moved, first);
assert_eq!(moved.sequence_bounds[&owner].1, 1026.);
assert_eq!(moved.size.height, 1113.);
assert!(
line(&moved, first)
.points
.iter()
.all(|point| point.y < moved.size.height)
);
assert_eq!(&p.elements[&owner].steps().unwrap()[..2], &[first, second]);
// This is a policy falsifier: mechanically exact coordinates do not prove
// that out-of-order vertical notation is understandable or acceptable.
passive(&document, &before, &source);
}
#[test]
fn nested_outlier_expands_enclosing_geometry_without_using_final_traversal_row_as_extent() {
let (document, owner) = fixture(false);
let p = document.project();
let baseline = Scene::sequence(p, owner, owner);
let nested = id(p, "nested");
let fragment = id(p, "fragment");
let following = id(p, "self_call");
let plan = Plan::build(p, owner, &baseline, &Candidate::from([(nested, 1000.)])).unwrap();
assert!(
plan.diagnostics
.contains(&Diagnostic::FrameExtendsPastFollowingAnchor {
frame: fragment,
following
})
);
let moved = render(p, owner, &plan);
assert_eq!(row(&moved, nested), 1000.);
assert_eq!(named_box(&moved, nested).rect.y, 980.);
let enclosing = named_box(&moved, fragment).rect;
assert_eq!(enclosing.y + enclosing.height, 1070.);
assert!(moved.sequence_bounds[&owner].1 >= 1070.);
assert!(moved.size.height > 1070.);
assert_eq!(row(&moved, following), 636.);
others_fixed(&baseline, &moved, nested);
}
#[test]
fn unsupported_targets_and_lifetime_inversion_fail_explicitly_instead_of_silent_clamping() {
let (document, owner) = fixture(true);
let p = document.project();
let baseline = Scene::sequence(p, owner, owner);
let create = id(p, "create_receiver");
let delete = id(p, "delete_receiver");
assert_eq!(
Plan::build(p, owner, &baseline, &Candidate::from([(delete, 200.)])).unwrap_err(),
PlanError::LifetimeInversionNotSupported { create, delete }
);
assert_eq!(
Plan::build(p, owner, &baseline, &Candidate::from([(delete, f32::NAN)])).unwrap_err(),
PlanError::NonFinite(delete)
);
let edge = id(p, "service");
assert_eq!(
Plan::build(p, owner, &baseline, &Candidate::from([(edge, 200.)])).unwrap_err(),
PlanError::UnknownAnchor(edge)
);
let (other, other_owner) = fixture(false);
let fragment = id(other.project(), "fragment");
let other_scene = Scene::sequence(other.project(), other_owner, other_owner);
assert_eq!(
Plan::build(
other.project(),
other_owner,
&other_scene,
&Candidate::from([(fragment, 300.)])
)
.unwrap_err(),
PlanError::CompoundMoveNotImplemented(fragment)
);
}
#[test]
fn complete_plan_scope_is_inactive_in_other_threads_and_restored_after_deliberate_panic() {
let (document, owner) = fixture(false);
let p = document.project();
let baseline = Scene::sequence(p, owner, owner);
let second = id(p, "second");
let plan = Plan::build(p, owner, &baseline, &Candidate::from([(second, 200.)])).unwrap();
let caught = std::panic::catch_unwind(|| {
let _scope = Scope::install(&plan);
assert_eq!(row(&Scene::sequence(p, owner, owner), second), 200.);
std::thread::spawn(|| {
let (document, owner) = fixture(false);
let p = document.project();
assert_eq!(
row(&Scene::sequence(p, owner, owner), id(p, "second")),
240.
);
})
.join()
.unwrap();
panic!("deliberate complete-anchor scope unwind");
});
let payload = caught.expect_err("deliberate panic is required");
assert_eq!(
payload.downcast_ref::<&str>().copied(),
Some("deliberate complete-anchor scope unwind")
);
same_scene(&baseline, &Scene::sequence(p, owner, owner));
}
@@ -0,0 +1,51 @@
diff --git a/crates/oa-desktop/src/behavior.rs b/crates/oa-desktop/src/behavior.rs
index 3f9fd97..f1ef5b7 100644
--- a/crates/oa-desktop/src/behavior.rs
+++ b/crates/oa-desktop/src/behavior.rs
@@ -1121,6 +1121,10 @@ fn in_machine(p: &Project, id: Id, machine: Id) -> bool {
#[path = "../../../harness/experiments/behavior-layout-scene-20260912/mod.rs"]
mod behavior_layout_scene_experiment;
+#[cfg(test)]
+#[path = "../../../harness/experiments/behavior-anchor-plan-20260912/mod.rs"]
+mod behavior_anchor_plan_experiment;
+
struct BoxItem {
id: Id,
rect: Rectangle,
@@ -1332,6 +1336,8 @@ impl Scene {
let mut y = if scenario { 148. } else { 120. };
scene.occurrences(p, owner, scenario, &lane_x, &mut y, 0);
scene.size.height = (y + 45.).max(210.);
+ #[cfg(test)]
+ behavior_anchor_plan_experiment::scene_extent(&mut scene);
if scenario {
scene.lifecycle = scenario_lifecycle::render::Rendering::new(
p,
@@ -1441,6 +1447,8 @@ impl Scene {
}
#[cfg(test)]
behavior_layout_scene_experiment::resolve_row_anchor(*id, y);
+ #[cfg(test)]
+ behavior_anchor_plan_experiment::row_anchor(*id, y);
if ordered {
let slot = scenario::Slot {
parent: owner,
@@ -1465,6 +1473,8 @@ impl Scene {
(*y - top).max(95.),
),
);
+ #[cfg(test)]
+ let rect = behavior_anchor_plan_experiment::frame_bounds(*id, rect);
self.boxes.insert(
0,
BoxItem {
@@ -1649,6 +1659,8 @@ impl Scene {
}
if ordered {
self.sequence_bounds.insert(owner, (sequence_top, *y - 42.));
+ #[cfg(test)]
+ behavior_anchor_plan_experiment::scope_end(owner, y, &mut self.sequence_bounds);
let slot = scenario::Slot {
parent: owner,
before: None,