Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
- `UNGUARDED_SNAPSHOT` (R-8) looks through components: a callback prop given to a component, and a component's handler
that reads `props.f`, are checked against what each site passes and what the component's regions show. A click that
reads a list its region never shows (another column's cards, say) is now a compile error instead of a failure thrown
out of the click.
out of the click. A `disabled` that reads the value only behind `&&` or `?:` covers it only where the site's props
make that read.

**Fixed**

Expand Down
145 changes: 138 additions & 7 deletions compiler/src/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,92 @@ fn prop_snapshot_reads<'a>(n: Node<'a>, caught: bool, locals: &mut HashSet<Strin
prop_snapshot_reads(c, caught, locals, out);
}
}
/// R-8: one site's props, for `sure_parts`: the props value's name and the site's `(field, value)` pairs
type SiteArgs<'s, 'a> = Option<(&'s str, &'s [(String, &'a Expr, EId)])>;
#[derive(PartialEq)]
enum CV {
B(bool),
N(f64),
S(String),
Nil,
}
impl CV {
fn truthy(&self) -> bool {
match self {
CV::B(b) => *b,
CV::N(n) => *n != 0.0,
CV::S(s) => !s.is_empty(),
CV::Nil => false,
}
}
}
/// a value known at this site: a literal, a prop the site binds to a literal, and `!`, `==`, `!=`, `&&`, `||` over them
fn const_eval(e: &Expr, site: SiteArgs) -> Option<CV> {
match &e.k {
ExprKind::Lit(l) => Some(match l {
Lit::Bool(b) => CV::B(*b),
Lit::Num(n) => CV::N(*n),
Lit::Str(s) => CV::S(s.clone()),
Lit::Null | Lit::Undefined => CV::Nil,
}),
ExprKind::Member { o, p, .. } => {
let (root, args) = site?;
if !matches!(&o.k, ExprKind::Id(r) if r == root) {
return None;
}
let (_, v, _) = args.iter().find(|(f, _, _)| f == p)?;
if matches!(v.k, ExprKind::Lit(_)) { const_eval(v, None) } else { None }
}
ExprKind::Un { op, e } if op == "!" => const_eval(e, site).map(|v| CV::B(!v.truthy())),
ExprKind::Bin { op, l, r } => match op.as_str() {
"==" | "===" => Some(CV::B(const_eval(l, site)? == const_eval(r, site)?)),
"!=" | "!==" => Some(CV::B(const_eval(l, site)? != const_eval(r, site)?)),
"&&" => { let a = const_eval(l, site)?; if !a.truthy() { Some(a) } else { const_eval(r, site) } }
"||" => { let a = const_eval(l, site)?; if a.truthy() { Some(a) } else { const_eval(r, site) } }
_ => None,
},
_ => None,
}
}
/// R-8: the parts of `e` that every evaluation reads: the left of `&&`, `||`, `??` and the test of `?:`, and what
/// they lead to only when the site's props decide it (`col == "done" && props.full` reads `props.full` only in the done
/// column)
fn sure_parts<'a>(e: &'a Expr, site: SiteArgs, out: &mut Vec<&'a Expr>) {
match &e.k {
ExprKind::Bin { op, l, r } if op == "&&" || op == "||" || op == "??" => {
sure_parts(l, site, out);
let go = match (op.as_str(), const_eval(l, site)) {
("&&", Some(v)) => v.truthy(),
("||", Some(v)) => !v.truthy(),
("??", Some(v)) => v == CV::Nil,
_ => false,
};
if go {
sure_parts(r, site, out);
}
}
ExprKind::If { c, t, f } => {
sure_parts(c, site, out);
match const_eval(c, site) {
Some(v) if v.truthy() => sure_parts(t, site, out),
Some(_) => sure_parts(f, site, out),
None => {}
}
}
ExprKind::Fn { .. } => {}
_ => out.push(e),
}
}
/// `reads_member` over the parts of `e` that every evaluation reads (`sure_parts`)
fn reads_member_sure(e: &Expr, root: &str, f: &str, site: SiteArgs) -> bool {
let mut ps = vec![];
sure_parts(e, site, &mut ps);
ps.iter().any(|p| match &p.k {
ExprKind::Bin { l, r, .. } => reads_member_sure(l, root, f, site) || reads_member_sure(r, root, f, site),
ExprKind::Un { e, .. } => reads_member_sure(e, root, f, site),
_ => reads_member(p, root, f),
})
}
/// whether `e` reads `root.f` (or the whole `root`, as a spread or an argument)
fn reads_member(e: &Expr, root: &str, f: &str) -> bool {
let mut stack = vec![Node::E(e)];
Expand Down Expand Up @@ -3275,7 +3361,8 @@ impl<'a> Checker<'a> {
// (the child shows it, and guards its own click)
// (the child shows it, and guards its own click): the value, or a value it takes its failure from
let from: Vec<SId> = if comp.is_some() { self.syms[s].expr.map(|(te, tenv)| risky.iter().copied().filter(|&u| u != s && self.depends_in(te, tenv, u, &mut HashSet::new(), false)).collect()).unwrap_or_default() } else { vec![] };
let disabled_by = |probes: bool| attrs.iter().any(|a| (a.name == "disabled" && self.depends_in(&a.e, env, s, &mut HashSet::new(), probes)) || (comp.is_some_and(|g| !is_handler(&a.name) && self.child_shows(g, &field_of(&a.name), probes)) && (self.depends_in(&a.e, env, s, &mut HashSet::new(), probes) || from.iter().any(|&u| self.depends_in(&a.e, env, u, &mut HashSet::new(), probes)))));
let site_args: Vec<(String, &'a Expr, EId)> = attrs.iter().filter(|a| !is_handler(&a.name)).map(|a| (field_of(&a.name), &a.e, env)).collect();
let disabled_by = |probes: bool| attrs.iter().any(|a| (a.name == "disabled" && self.sure_depends(&a.e, env, s, probes)) || (comp.is_some_and(|g| !is_handler(&a.name) && self.child_shows(g, &field_of(&a.name), probes, &site_args)) && (self.depends_in(&a.e, env, s, &mut HashSet::new(), probes) || from.iter().any(|&u| self.depends_in(&a.e, env, u, &mut HashSet::new(), probes)))));
let need_hold = absent && !disabled_by(true) && !self.region_reads(region, s, |r| r.provides.contains(HOLD));
let need_catch = failing && !disabled_by(false) && !self.region_reads_in(region, s, |r| r.catches.is_some(), false);
if !need_hold && !need_catch {
Expand Down Expand Up @@ -3340,7 +3427,7 @@ impl<'a> Checker<'a> {
// reads a prop this site binds to a value that reads `t` (it then fails with it, and the region shows it)
let covered = args.iter().any(|(gf, ge, genv)| {
self.depends_in(ge, *genv, t, &mut HashSet::new(), false)
&& (attrs.iter().any(|a| a.name == "disabled" && reads_member(&a.e, &root, gf)) || self.region_reads_member(region, &root, gf))
&& (attrs.iter().any(|a| a.name == "disabled" && reads_member_sure(&a.e, &root, gf, Some((root.as_str(), &args)))) || self.region_reads_member(region, &root, gf, Some((root.as_str(), &args))))
});
if !covered {
let tn = self.syms[t].name.clone();
Expand All @@ -3359,20 +3446,41 @@ impl<'a> Checker<'a> {
}
}
}
/// `depends_member` over the parts of `e` that every evaluation reads (`sure_parts`)
fn depends_member_sure(&self, e: &Expr, env: EId, root: &str, f: &str, site: SiteArgs) -> bool {
let mut ps = vec![];
sure_parts(e, site, &mut ps);
ps.iter().any(|p| match &p.k {
ExprKind::Bin { l, r, .. } => self.depends_member_sure(l, env, root, f, site) || self.depends_member_sure(r, env, root, f, site),
ExprKind::Un { e, .. } => self.depends_member_sure(e, env, root, f, site),
_ => self.depends_member(p, env, root, f, &mut HashSet::new()),
})
}
/// `depends_in` over the parts of `e` that every evaluation reads (`sure_parts`); an equation read is followed whole
fn sure_depends(&self, e: &Expr, env: EId, s: SId, probes: bool) -> bool {
let mut ps = vec![];
sure_parts(e, None, &mut ps);
ps.iter().any(|p| match &p.k {
ExprKind::Bin { l, r, .. } => self.sure_depends(l, env, s, probes) || self.sure_depends(r, env, s, probes),
ExprKind::Un { e, .. } => self.sure_depends(e, env, s, probes),
_ => self.depends_in(p, env, s, &mut HashSet::new(), probes),
})
}
/// whether component `g` reads `props.f` in an `errored` region's content (`probes`: or in a `disabled`), so a value
/// bound to `f` that fails takes the elements there down with it
fn child_shows(&self, g: RId, f: &str, probes: bool) -> bool {
fn child_shows(&self, g: RId, f: &str, probes: bool, site: &[(String, &'a Expr, EId)]) -> bool {
// a component from another module (its body isn't here): trust that it shows what it is handed
let Some(ps) = (0..self.syms.len()).find(|&t| self.syms[t].kind == SymKind::Props && self.syms[t].region == g) else { return true };
let root = self.syms[ps].name.clone();
let site: SiteArgs = Some((root.as_str(), site));
let comp_of_r = |mut r: RId| loop {
if self.regions[r].is_component_root || self.regions[r].parent.is_none() {
return r;
}
r = self.regions[r].parent.unwrap();
};
let in_g = |r: RId| comp_of_r(r) == g;
self.readers.iter().any(|rd| in_g(rd.region) && self.depends_member(rd.e, rd.env, &root, f, &mut HashSet::new()) && {
self.readers.iter().any(|rd| in_g(rd.region) && self.depends_member_sure(rd.e, rd.env, &root, f, site) && {
let mut cur = Some(rd.region);
let mut hit = false;
while let Some(c) = cur {
Expand All @@ -3386,12 +3494,12 @@ impl<'a> Checker<'a> {
cur = self.regions[c].parent;
}
hit
}) || self.handlers.iter().any(|h| in_g(h.region) && h.attrs.iter().any(|a| a.name == "disabled" && reads_member(&a.e, &root, f)))
}) || self.handlers.iter().any(|h| in_g(h.region) && h.attrs.iter().any(|a| a.name == "disabled" && reads_member_sure(&a.e, &root, f, site)))
}
fn region_reads_member(&self, r: RId, root: &str, f: &str) -> bool {
fn region_reads_member(&self, r: RId, root: &str, f: &str, site: SiteArgs) -> bool {
let mut cur = Some(r);
while let Some(c) = cur {
if self.regions[c].catches.is_some() && self.readers.iter().any(|rd| self.inside(rd.region, c) && self.depends_member(rd.e, rd.env, root, f, &mut HashSet::new())) {
if self.regions[c].catches.is_some() && self.readers.iter().any(|rd| self.inside(rd.region, c) && self.depends_member_sure(rd.e, rd.env, root, f, site)) {
return true;
}
if self.regions[c].is_component_root {
Expand Down Expand Up @@ -4708,6 +4816,29 @@ export default component App() {
assert_eq!(got, vec![5, 6, 17], "{:?}", codes(src, false));
}

/// 04 R-8: a `disabled` covers a read only if it makes it: the right of `&&` / `||` and the arms of `?:` count where
/// the site's props decide them (r17 board app 6: `props.column == "done" && props.lens.doing >= 3`).
#[test]
fn snapshot_guard_behind_and() {
let src = r#"component Lane(props: { column: string; lens: number }) {
errored fallback(e) { <p>failed</p> } {
<button disabled={props.column == "done" && props.lens > 2} onClick={() => { log(props.lens) }}>go</button>
}
}
export default component App() {
source id := 1
n = await fetch("n:" + id) -> 0
<Lane column="done" lens={n} />
<Lane column="doing" lens={n} />
}
"#;
let got: Vec<i64> = codes(src, false).iter().filter(|(_, c)| c == "UNGUARDED_SNAPSHOT").map(|(l, _)| *l).collect();
// the done lane's `disabled` reads `props.lens`; the doing lane's skips it, so its click throws n's failure
assert_eq!(got, vec![3], "{:?}", codes(src, false));
let msgs: Vec<String> = { let read = |p: &str| if p == "/app.rx" { Some(src.to_string()) } else { None }; let set = load_modules("/app.rx", &read).unwrap(); check_modules(&set, false).diags.iter().map(|d| d.msg.clone()).collect() };
assert!(msgs.iter().any(|m| m.contains("line 10")), "{:?}", msgs);
}

/// 06 AC-3a: a guess a click can make while its value loads a new question, unless the element is covered.
#[test]
fn guess_while_loading() {
Expand Down
6 changes: 5 additions & 1 deletion eval/harness/fuzz-board.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
// count may keep a declined toggle or item add while other work is in the air. At rest none of these.
// - Two accepted writes to one field: settled, the field must show the server's last answer (Ryan, 2026-11-14).
// - B5: while a column has failed, the detail may show its errored fallback, but never a wrong column or title.
// - B6 (Ryan, 2026-11-25): the detail reads every column, so while a column's fetch is in the air it may say it is
// loading, but never a wrong column or title.
// - B4 (follows from that ruling): while anything is in the air, a card's count may keep accepted toggles of an item
// that was toggled more than once in that busy period, since their answers may have come back in another order than
// the clicks (the screen keeps the last click until its re-ask lands). At rest, the server's count.
Expand Down Expand Up @@ -206,7 +208,9 @@ async function session(browser, url, seed, steps, log, others = false) {
// its errored fallback (that it can't show the card now) instead; it must still never name a wrong column or title.
// Derived from an error is errored (Ryan, 2026-11-24): that holds until the failed column answers again, also while
// its retry is out
const failed = failedCols.size > 0 || (await Promise.all(COLS.map(cl => exists(`retry-${cl}`)))).some(Boolean);
// B6 (Ryan, 2026-11-25): for the same reason, while a column's fetch is in the air it may say it is loading
const loadingCol = /loading/i.test(detail) && (await pending()).some(k => k.startsWith("fetchCards:"));
const failed = loadingCol || failedCols.size > 0 || (await Promise.all(COLS.map(cl => exists(`retry-${cl}`)))).some(Boolean);
const wrongCol = COLS.some(cl => cl !== col && detail.includes(`in ${NAME[cl]}`));
if (failed ? wrongCol : !detail.includes(`in ${NAME[col]}`)) note("detail column", `#${x.id} shows in ${NAME[col]}, the detail says "${detail.slice(0, 80)}"`);
if (!detail.includes(`#${x.id} ${x.title}`) && (!failed || detail.includes(`#${x.id} `))) note("two views", `card "${x.text}", detail "${detail.slice(0, 80)}"`);
Expand Down
17 changes: 11 additions & 6 deletions eval/results/r17-haiku-board-2026-11-24/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ passes and the after-left family.

| app | tests kept | fuzz seeds | defects |
|---|---|---|---|
| 1 | 2 | 8 | 10 |
| 1 | 2 | 3 | 5 |
| 2 | 0 | 4 | 4 |
| 3 | 1 | 0 | 1 |
| 4 | 1 | 2 | 3 |
| 5 | 1 | 5 | 6 |
| 6 | 1 | 1 | 2 |
| mean | | | **4.33** (r16 Haiku board 19.0) |
| mean | | | **3.50** (rerun Haiku board 17.0) |

With the two Solid bugs below fixed: 9, 4, 1, 3, 4, 2 = 3.83. No duplicate-id holes (AC-1h's family) remain.
2026-11-25: fuzz regraded with B6 (Ryan: the detail reads every column, so it may say loading while a column's fetch
is in the air), `grades/*.fuzz-b6.txt`; app 1 went from 8 seeds to 3 (before B6 the mean was 4.33). Every app also
ran `holds-item-reload` and `holds-rename-decline`. With the Solid bugs below fixed: 3, 4, 1, 3, 4, 2 = 2.83. No duplicate-id holes (AC-1h's family) remain.

Hold probes (all ruled fine by Ryan 2026-11-25): `holds/` (round 15 probes, the rerun's, and `../rerun-2026-11-23/trace/holds-item-reload.mjs`, new: app 4
holds an item add until its toggle's column re-asks land, which the hidden test never answers; it settles right).
Expand All @@ -34,8 +36,8 @@ Ours, fixed here:
- app 1 seed 19, app 6 seed 13 (page error "declined"): a click read a failed list through a component. App 1's
`onMove`, written on the board, read the other columns' lists; app 6's lane handler read `props.lens`, a memo over
all three. R-8 never looked through components. It now does (spec/04-rows.md R-8 "Through components"); app 1 is a
compile error. App 6 is not: its `disabled` reads `props.lens` behind `props.column == "done" && …`, and R-8 counts
any read, guarded or not.
compile error. App 6 is too (2026-11-25): its `disabled` reads `props.lens` behind `props.column == "done" && …`,
which reads it only in the done lane, so R-8 now counts such a read only where the site's props make it.
- apps 3, 6 "a move into a column that is still loading": they declare `-> null` and the `[]` stand-in the guide
teaches, so the handler sends index 0 into a column it hasn't seen. Guide (async.md §1): the stand-in is not an
answer; keep a control that computes from the list disabled while it is null.
Expand All @@ -44,7 +46,10 @@ Ours, fixed here:
guess a count as a change.

Agent:
- app 1, 6 seeds (4, 8, 11, 15, 18, 20) "detail says loading card": the detail's `loading on(sel)` borrows lists with no `-> v`.
- ~~app 1, 6 seeds (4, 8, 11, 15, 18, 20) "detail says loading card"~~: valid under B6 (Ryan 2026-11-25). Seed 8 then
shows "limit": after `left #3` fills Doing, a To do card's right stays enabled though `full` is true. Solid
(solidjs/solid#5201, `repro/attribute-misses-guess-on-row-mounted-while-held.spec.tsx`): To do's rows mounted while
a move was held, and their `disabled` misses the later guess. With it and #5195 fixed app 1 is 3.
- app 1 "a column's retry shows loading": Done's buttons read `full` over Doing, which never answers in the test, so
Done waits on it (guide §1 says to give the answer a value where it's declared).
- apps 1, 5 "an earlier move declined while a later move is out": app 1 re-asks only the lists the shown move
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
board-rx-haiku-1: 3/20 seeds found a hole
seed 6 step 27: two views: card "#1 Write spec · 0/2", detail "#1 Fix loginin To dorenamearchiveloading checklist"
add Bravo 1 ; fail fetchCards:doing ; land fetchCards:done ; land fetchCards:doing ; land fetchCards:todo ; add Bravo 2 ; left #5 ; tab archive ; land fetchArchived: ; tab board ; tab archive ; tab board ; add Alpha 3 ; land fetchCards:done ; add Delta 4 ; tab archive ; tab board ; land fetchCards:done ; land fetchCards:todo ; add Alpha 5 ; land moveCard:5,doing,2 ; fail fetchCards:doing ; lan
seed 8 step 26: limit: Doing shows 3 cards and a To do card's right is enabled
land fetchCards:doing ; right #3 ; select #4 ; fail fetchCards:done ; left #3 ; retry-done ; fail fetchCards:todo ; up #4 ; select #4 ; land fetchCards:done ; select #5 ; land fetchChecklist:5 ; retry-todo ; left #5 ; land fetchChecklist:4 ; right #3 ; land fetchCards:todo ; down #1 ; land moveCard:3,done,0 ; land fetchCards:todo ; land fetchCards:done ; land moveCard:4,doing,0 ; toggle 1 ; se
seed 19 step 30: page error: declined
land fetchCards:todo ; tab archive ; land fetchCards:done ; tab board ; land fetchArchived: ; fail fetchCards:todo ; land fetchCards:done ; add Alpha 1 ; land fetchCards:doing ; left #4 ; add Alpha 2 ; tab archive ; tab board ; land fetchCards:todo ; add Alpha 3 ; tab archive ; tab board ; land fetchCards:doing ; land fetchCards:done ; tab archive ; tab board ; land fetchCards:doing ; add Alph
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
board-rx-haiku-2: 4/20 seeds found a hole
seed 4 step -1: page crash: session timed out (120 s): the page hangs

seed 12 step -1: page crash: session timed out (120 s): the page hangs

seed 14 step -1: page crash: session timed out (120 s): the page hangs

seed 20 step 20: count: card "#3 Review PR · 1/3", progress "2/3 done"
add Bravo 1 ; land fetchCards:doing ; add Bravo 2 ; select #3 ; fail addCard:todo,Bravo 1 ; land fetchChecklist:3 ; land fetchCards:todo ; land fetchCards:done ; toggle 1 ; land addCard:todo,Bravo 2 ; land toggleItem:3,32,false ; fail fetchCards:todo ; add Delta 3 ; toggle 1 ; toggle 0 ; land fetchCards:done ; left #3 ; up #2 ; add-item docs 4 ; toggle 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
board-rx-haiku-3: 0/20 seeds found a hole
Loading
Loading