mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 11:07:10 +00:00
* fix(ltl): give every thunk a construction identity Two distinct unnamed predicates both described as "Thunk(...)", so obligation collapse merged their residuals and could drop a live violation. Identity is assigned at construction and the fields are unexported, so a thunk cannot be built without one. Claude-Session: https://claude.ai/code/session_01Fj4wJUikdABuMQEETwW55J * fix(ltl): reduce a thrown-predicate residual instead of panicking The verifier substitutes an ErrorFormula for the residual of a property whose predicate threw, and that residual is fed back in on the next step. reduce had no case for it, so the run crashed. It re-reports the same failure now. Claude-Session: https://claude.ai/code/session_01Fj4wJUikdABuMQEETwW55J * fix(ltl): make a bounded always the dual of a bounded eventually G<=n(f) and not F<=n(not f) disagreed on traces where the inner was still pending when the window closed, so nnf's negation normal form was not semantics preserving. Both sides now range over the observations at which their inner can definitely resolve: the eventually keeps a pending inner as a disjunct, and the always discharges vacuously at window close. Claude-Session: https://claude.ai/code/session_01Fj4wJUikdABuMQEETwW55J * fix(ltl): arm a one-shot root once per run A root that carries its own horizon is one obligation for the whole run, not one per observation. Re-instantiating a top-level eventually monitored G F<=n(p) instead of F<=n(p) and left one live obligation per step behind; a bounded always restarted its window every step and never closed. Claude-Session: https://claude.ai/code/session_01Fj4wJUikdABuMQEETwW55J * fix(verifier): stop wrapping a top-level eventually in always `eventually(p).within(300, "seconds")` as a property meant "within 300 seconds of every step", which spawned an obligation per step with its own resolved deadline. A 553-step run carried 553 of them and serialized a 75 KB residual. Claude-Session: https://claude.ai/code/session_01Fj4wJUikdABuMQEETwW55J * fix(ltl): serialize the resolved deadline of a bounded window Two obligations spawned at different steps from one duration-bounded formula differ only in the deadline the evaluator resolved for them, so they serialized identically and the trace erased a distinction the evaluator makes. The authored window stays in amount/unit; the resolved deadline rides alongside. Claude-Session: https://claude.ai/code/session_01Fj4wJUikdABuMQEETwW55J * fix(verifier): split a witness's origin step from its detection step A deferred obligation spans two steps: the one that armed it and the one whose reduction failed. They were conflated under one index, so the extractor snapshot (which is the detecting step's state) was reported against the origin step. Claude-Session: https://claude.ai/code/session_01Fj4wJUikdABuMQEETwW55J * fix(runner): record a witness's detection step in the trace Claude-Session: https://claude.ai/code/session_01Fj4wJUikdABuMQEETwW55J * feat(replay-ui): show the step a violation was detected at The witness evidence is the detecting step's state, so say which step that is and let a reader jump to it. Claude-Session: https://claude.ai/code/session_01Fj4wJUikdABuMQEETwW55J * fix(verifier): record the extractor state the predicates actually read On the web path extractor bodies are evaluated in V8 and injected here, but only the goja value was replaced. The trace diff and the violation witness therefore described a state no property ever saw. Claude-Session: https://claude.ai/code/session_01Fj4wJUikdABuMQEETwW55J * refactor(spec): one candidate producer over one target-eligibility rule Both hosts routed verbs themselves and both policies enumerated their own actions, and all four drifted. Web sent `swipes` to scrollable containers only, so swipe-to-dismiss on a list row was reachable on native and unreachable on web; the model policy folded gestures its own way and could not reach what the seeded picker drew. A host now reports facts about every element and never decides which verb may act on it: targets.ts acceptsTarget owns that for both. pick.ts builtinCandidates is the single enumeration, and the model policy reads it through __sanderlingEnumerateBuiltin__ instead of reimplementing it in Go. Gesture verbs change with it: scrolls stay vertical over scrollable containers, swipes go free-form in all four directions from any element with real bounds. Claude-Session: https://claude.ai/code/session_01Fj4wJUikdABuMQEETwW55J * fix(runner): name a builtin scroll by its drag origin A builtin gesture carries endpoints and no selector, so every scroll rendered as "Scroll down " in the prompt's recent-action memory and two scrollable regions were indistinguishable. Claude-Session: https://claude.ai/code/session_01Fj4wJUikdABuMQEETwW55J * fix(chrome): clear storage over cdp instead of scripting an opaque origin Launch runs while the tab is still on about:blank, whose opaque origin denies storage access, so localStorage.clear() threw SecurityError and every web run died at launch. Storage.clearDataForOrigin needs no navigation. The exception helper lands here because "Uncaught" is what hid this for so long. Claude-Session: https://claude.ai/code/session_01Fj4wJUikdABuMQEETwW55J * fix(chrome): enable the swiftshader webgl fallback Headless Chrome runs with --disable-gpu, and without this flag it refuses the software WebGL backend: getContext returns null, so a canvas-rendered app paints nothing and every screenshot is identical black. Claude-Session: https://claude.ai/code/session_01Fj4wJUikdABuMQEETwW55J * fix(web): resolve testTag through data-testid or id Compose Multiplatform emits its testTag into the element id, which the native table already accepts via the resource-id alias. The two web selector tables were the only place that rejected it. Claude-Session: https://claude.ai/code/session_01Fj4wJUikdABuMQEETwW55J * test(spec): type-check the spec api as part of make test The fake runtime in api.test.ts did not return a chainable handle from extract, so the file had not type-checked since named() was added. Wiring the check into make test stops it drifting again. Claude-Session: https://claude.ai/code/session_01Fj4wJUikdABuMQEETwW55J * docs(manual): one-shot eventually and the gesture verbs Claude-Session: https://claude.ai/code/session_01Fj4wJUikdABuMQEETwW55J
115 lines
4.4 KiB
Go
115 lines
4.4 KiB
Go
package verifier
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
"slices"
|
|
"testing"
|
|
)
|
|
|
|
// hostParityScreen is the canonical screen both hosts are driven over: one row
|
|
// per fact combination that any verb distinguishes. Each host builds it in its
|
|
// own model (this file as a hierarchy tree, pkg/spec/test/host-parity.test.ts as
|
|
// a DOM), enumerates every verb, and asserts the SAME committed golden.
|
|
var hostParityScreen = []struct {
|
|
name string
|
|
clickable bool
|
|
enabled bool
|
|
editable bool
|
|
scrollable bool
|
|
positiveBounds bool
|
|
}{
|
|
{name: "root", enabled: true, scrollable: true, positiveBounds: true},
|
|
{name: "save", clickable: true, enabled: true, positiveBounds: true},
|
|
{name: "cancel", clickable: true, positiveBounds: true},
|
|
{name: "amount", enabled: true, editable: true, positiveBounds: true},
|
|
{name: "list", enabled: true, scrollable: true, positiveBounds: true},
|
|
{name: "row", enabled: true, positiveBounds: true},
|
|
{name: "collapsed", clickable: true, enabled: true},
|
|
}
|
|
|
|
// hostParityTreeJSON is hostParityScreen as the native host sees it. Tree order
|
|
// is pre-order, so it matches hostParityScreen index for index.
|
|
const hostParityTreeJSON = `{
|
|
"attributes": {"resource-id": "root", "scrollable": "true", "bounds": "[0,0,400,800]"},
|
|
"enabled": true,
|
|
"children": [
|
|
{"attributes": {"resource-id": "save", "bounds": "[0,0,200,60]"}, "clickable": true, "enabled": true, "children": []},
|
|
{"attributes": {"resource-id": "cancel", "bounds": "[200,0,400,60]"}, "clickable": true, "enabled": false, "children": []},
|
|
{"attributes": {"resource-id": "amount", "bounds": "[0,100,400,160]"}, "editable": true, "enabled": true, "children": []},
|
|
{"attributes": {"resource-id": "list", "scrollable": "true", "bounds": "[0,200,400,600]"}, "enabled": true, "children": []},
|
|
{"attributes": {"resource-id": "row", "bounds": "[0,600,400,680]"}, "enabled": true, "children": []},
|
|
{"attributes": {"resource-id": "collapsed", "bounds": "[0,0,0,0]"}, "clickable": true, "enabled": true, "children": []}
|
|
]
|
|
}`
|
|
|
|
// TestHostsAgreeOnTargetEligibility is the guard on the claim that one
|
|
// specification induces one action space on every platform. The native host and
|
|
// the web host used to route verbs themselves and had drifted: web sent
|
|
// `swipes` to scrollable containers only, so a swipe on a list row was
|
|
// reachable on Android and unreachable on web for the same spec.
|
|
//
|
|
// Per-verb eligibility now has ONE definition (pkg/spec/src/targets.ts); a host
|
|
// reports facts and never filters. This test is what notices if a second
|
|
// definition grows back on either side: both hosts enumerate the same canonical
|
|
// screen and must name the same targets, verb for verb, in the same order.
|
|
// pkg/spec/test/host-parity.test.ts asserts the SAME golden from the web host,
|
|
// so a match on both sides proves the two hosts agree without either invoking
|
|
// the other.
|
|
func TestHostsAgreeOnTargetEligibility(t *testing.T) {
|
|
golden := loadHostParityGolden(t)
|
|
for _, verb := range policyVerbs {
|
|
t.Run(verb, func(t *testing.T) {
|
|
want, ok := golden[verb]
|
|
if !ok {
|
|
t.Fatalf("golden has no entry for %s", verb)
|
|
}
|
|
verifier := newVerifier(t, WithSeed(0x5eed))
|
|
loadActionSpec(t, verifier, fmt.Sprintf(
|
|
"import { %s } from \"@sanderling/spec\";\nglobalThis.actions = %s;", verb, verb))
|
|
pushTree(t, verifier, hostParityTreeJSON)
|
|
|
|
entries, err := verifier.enumerateBuiltin(verb)
|
|
if err != nil {
|
|
t.Fatalf("enumerate %s: %v", verb, err)
|
|
}
|
|
if len(entries) == 0 {
|
|
t.Fatalf("%s enumerated nothing at all", verb)
|
|
}
|
|
got := []string{}
|
|
for _, entry := range entries {
|
|
if entry.targetIndex < 0 {
|
|
continue
|
|
}
|
|
if entry.targetIndex >= len(hostParityScreen) {
|
|
t.Fatalf("%s produced target index %d, off the %d-row screen",
|
|
verb, entry.targetIndex, len(hostParityScreen))
|
|
}
|
|
got = append(got, hostParityScreen[entry.targetIndex].name)
|
|
}
|
|
if !slices.Equal(got, want) {
|
|
t.Errorf("native host targets for %s\n got=%v\nwant=%v", verb, got, want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func loadHostParityGolden(t *testing.T) map[string][]string {
|
|
t.Helper()
|
|
path, err := filepath.Abs("../../pkg/spec/test/fixtures/host-parity-golden.json")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
body, err := os.ReadFile(path)
|
|
if err != nil {
|
|
t.Fatalf("read golden: %v", err)
|
|
}
|
|
golden := map[string][]string{}
|
|
if err := json.Unmarshal(body, &golden); err != nil {
|
|
t.Fatalf("decode golden: %v", err)
|
|
}
|
|
return golden
|
|
}
|