Expand description
Test/integration-suite checking (P5.4,
design/tracks/semantics-in-the-checker.md §6) — closes category 7 of
bynk-check/src/analysis.rs’s own residual-gap accounting, the last of
the seven. bynk-emit/src/project/tests_emit.rs held
process_tests/process_integration_tests, real production code (not
fixture noise, despite the filename) checking + emitting suite/test integration bodies — but it ran only inside bynk-emit::run_checks
(Mode::Analyse included), never inside bynk_check::analysis::analyse_project,
the entry point the LSP now uses. That gap meant no diagnostics and no
RefSink bindings (go-to-definition/find-references) for anything inside
a test file, in the editor — see analysis.rs’s own module doc for the
full accounting this closes.
What moved here — every check-only helper process_tests/
process_integration_tests used, plus every function that is genuinely
dual-use: called both by this module’s own phase_test_bodies/
phase_integration_bodies (the checking half, real diagnostic/RefSink
sinks) and by bynk-emit’s TypeScript lowering (throwaway sinks, needed
only for the resolved-type view a body’s emission depends on). Dual-use
functions are pub, and bynk-emit calls them qualified
(bynk_check::test_suites::foo(...)) rather than duplicating them — see
build_privileged_resolved, typecheck_case_body,
check_history_binding, register_call_record_types,
history_handlers, history_variant_name, prop_binding_generable
and infer_participants for which and why (each names its own emit-side
call sites). Duplicating a dual-use function instead of relocating it is
exactly the drift risk this whole design track exists to close (§9,
“Relocating checks risks a quiet R4.6/R4.11 regression”).
What stayed in bynk-emit (pure TypeScript emission, or verified
emit-only by call-site count): block_uses_observation,
target_service_handler_kinds, is_attackable_contract,
numeric_or_scalar_base, attackable_contracts,
json_codec_qual_for_target, prop_history_binding, prop_is_history,
SystemCaseInput, RunnableTest, discovered_location,
discovery_manifest, sanitise_suite, emit_integration_module and its
http-driver/harness helpers, and the ~2,600-line TypeScript-codegen tail
starting at emit_test_module (emit_stub_class, gen_ts_for_ty,
emit_test_property_function, emit_test_history_property_function, and
the rest).
bynk-emit/src/project/tests_emit.rs’s own process_tests/
process_integration_tests keep their exact signatures (run_checks’s
callers need no change) — their bodies now call
phase_test_bodies/phase_integration_bodies for the checking half,
then proceed to their existing, unmoved Phase-5 emission logic using the
“ready for emission” data these return.
bynk-emit depends on bynk-check (a production dependency, never the
reverse), so this move has no circular-dependency subtlety to solve —
unlike P5.3’s phase_platform_lock, which needed a from-scratch pure
reimplementation because its old home reached into a bynk-emit
TypeScript-codegen helper. This is a plain code-motion job, just a large
one.
Structs§
- Resolved
Stub - v0.118: a capability seam with one or more
stuboverrides applied (testing track slice 6). Groups everystub Cap.method(…)clause — both suite-scoped and case-scoped — targeting the same capabilitycap. The resolvedCapabilityDeclsupplies each overridden method’s parameter names and return type for stub emission. - Suite
Items - #2834/#2841: what a suite declares for its bodies to use besides cases: its
helper
fns and itsfixturefiles. - Suite
View - #1814: a test suite’s composed symbol tables, closed over the types its
imported declarations reach.
hiddennames each type the closure added, with its owning commons: resolvable in the view, never nameable by the suite (resolver::check_hidden_type_names_in_suite), and imported by the test scaffold from that commons.
Enums§
- Stub
Scope - Which runs of a target’s test module a
stubclause applies to (#291). Every suite targeting a unit is emitted into one module, so a clause’s scope is narrowed to its own suite whenever another suite shares the module (#1860).
Constants§
- PROP_
GEN_ DEPTH - v0.114: the recursion cap for property-binding generability (mirrors the
checker’s
MOCK_DEPTHfor bareVal).
Functions§
- add_
suite_ fns - #2834: add a suite’s helper
fns to the view its bodies are checked in. The helpers are the suite’s alone: the unit’s own table, and with it everything the deployable emits, never sees them. - add_
suite_ fns_ to_ typed - #2834: the typed-commons counterpart of
add_suite_fns, for lowering. - build_
privileged_ resolved - Build a
resolver::ResolvedCommonsbacked byowning_unit’sprivileged_view. The same shape used by the production pipeline. Returns theResolvedCommonsplus what the view’s closure found (#1814): its hidden types and its conflicts. - check_
history_ binding - v0.119 (testing track slice 7, ADR 0155): type-check a
for all run: History[Agent]binding. The subject is a run of the agent — a generated, driven call-history — bound as an ordinaryList[Step]. Validates the DECISION-B rules (agent-only, every handler parameter generable), registers the synthetic call-sum / step / state record types intoresolved.typesso the predicate’sList+ value surface (.call is …,.old/.new,.accepted) type-checks, and returns the boundList[Step]type. - check_
suite_ decls - #3066: the
typeandconstdeclarations of a suite, checked against the case scoperesolved(the view before they join it). A name already bound in that scope (a target or used-commons declaration, a sum variant), or repeated within the suite, is refused rather than shadowed; the rest joinresolvedand are checked as a unit’s own are. Returns the initialisers’expr_typesandCalleeclassification for the emit path, which re-checks with throwaway sinks. - check_
suite_ fixtures_ in - #2841: the fixture-name rules and the unused warning for
suite, against the case scoperesolved(the view before the suite’s own items join it). - check_
suite_ fns - #2834: check a suite’s helper
fns. Each must be a free, pure function whose name no value in the case scope already uses and no sibling repeats; the helpers are then added toresolved(the suite’s view) and their bodies checked in it. Returns the bodies’expr_typesandCalleeclassification for the emit path, which re-checks with throwaway sinks. - consumed_
service_ seam_ decls - #3892: a consumed context’s services as seams, one synthetic capability per
context named by what the target calls it (its alias, else its last path
segment, the key its surface double sits under in the test
deps), with one operation per service: the parameters and return type of itson callhandler. Observation (expect Pay.authorise called …),withandtraceread them as they read a capability’s. - event_
publisher - #2052 review: the context that publishes
eventtotarget’s subscribers, resolved as the target’sfrom Events(E)header resolvesE: the target’s own declaration, else the one context among those it consumes (consumed) that declares it.Errlists the candidates when there is no unique one (none, or several). A same-named event in a context the target does not consume is never a candidate. - history_
handlers - The agent’s drivable
on callhandlers — the ones a history sequences. Other handler kinds (http/cron/message/open/close) are not RPC entry points and are never part of a generated call-history. - history_
variant_ name - The
.callvariant tag for a handler: the handler name with its first letter upper-cased (spend→Spend,topUp→TopUp). The reader matches this withis/match(s.call is Spend). - infer_
harness_ participants - #1959: the contexts a
system-tier suite’s harness stands up as Workers:infer_participants’ set, plus every context subscribing to an event one of them declares, plus itsconsumesclosure, transitively. A subscriber consumes its publisher, andconsumescycles are refused, so no subscriber of the target is ever in the target’s own closure; without it here, the fan-out would deliver to nobody. Only the harness widens: a case still reaches justinfer_participants’ set. Target first, then breadth order. - infer_
participants - v0.118: infer a
system-tier suite’s wired participants — the target’s transitiveconsumesclosure (testing track slice 6). A BFS from the target followingconsumesedges; the returned list starts with the target and includes every context reachable through it (deterministic breadth order). #1856: contexts only. A unit consumed for its capabilities alone (consumes bynk { Clock }, an adapter) is provided in-process by the composition root: no Worker, no Service Binding, no wire to cross. The walk still passes through one, but it is no participant. - integration_
resolved - The harness-root
ResolvedCommonsasystemcase (or a suite helper) is checked in: names from the harness view (#1814: closed over reached types), plus the declaring suite’s helperfns (#2834). - integration_
view - #1814: a
systemcase’s harness view: types, fns and methods from the suite’susescommons (for constructing arguments), plus each participant’s types and methods (so return types rebrand and variant patterns resolve), closed over the types those declarations reach. - phase_
integration_ bodies - P5.4 (
design/tracks/semantics-in-the-checker.md§6): the checking half oftest integration "name"suite processing — participant inference, thesystem-needs-a-serialisation-edge gate, duplicate-case-name detection, the harness-root cross-context view, and per-case body type-checking (including theWire/by Nobodytier gates). Formerly the pre-emission logic ofbynk-emit’s ownprocess_integration_tests; emission stays inbynk-driver::project::tests_emit::process_integration_tests, which calls this function for its checking half and then emits only for the groups this returns. Unlikephase_test_bodies’sResolvedStubmap, the only thing worth handing back here is the harness’sresolver::CrossContextInfo— it’s built from clone-heavy maps (harness_consumes/harness_uses), so recomputing it a second time on the emit side would be wasted work.participants/uses_targets/case_inputsare cheap and pure (a BFS, a linear scan), so the emit-side loop recomputes those itself fromparsed/unit_consumes, using the now-relocatedinfer_participants.bynk_check::analysis::analyse_projectcalls this too and discards the returned map — it never emits. Closes category 7 ofbynk-check/src/analysis.rs’s own residual-gap accounting, alongsidephase_test_bodies. - phase_
test_ bodies - P5.4 (
design/tracks/semantics-in-the-checker.md§6): the checking half oftest <target>suite processing — target resolution, duplicate-case- name detection,stub-clause resolution, and case/property body type-checking. Formerly Phases 2-4 ofbynk-emit’s ownprocess_tests; Phase 5 (TypeScript emission) stays inbynk-driver::project::tests_emit::process_tests, which calls this function for its checking half and then emits only for the targets this returns — every target this function resolves, has no duplicate case names, and whose bodies type-check clean is exactly “ready for emission”.bynk_check::analysis::analyse_projectcalls this too and discards the returned map — it never emits, so only the diagnostic/RefSinkside effects matter there. Closes category 7 ofbynk-check/src/analysis.rs’s own residual-gap accounting, alongsidephase_integration_bodies. - privileged_
view owning_unit’s privileged view: its types, fns, methods, plus those of every commons ituses, plus the types and instance methods of every consumed context. #1814: closed over the types those imported declarations reach, as the unit’s own table is, so a case is checked against the same types the target is.- prop_
binding_ generable - Whether a
for all x: Tbinding’s type is refinement-generable: refined types must not carry aMatchesorIsoDatepredicate (no refinement-driven generator), and sums/records must have every component recursively generable within the depth cap. Mirrors the checker’scan_mock_bare. - register_
call_ record_ types - Register a synthetic call-record type per capability operation of the target
context (v0.117, testing track slice 5), so
trace(Cap.op)— typedList[<CallRecord>]— supports field access on its records. The record’s fields are the operation’s parameters. - remote_
clock_ dependent - #2138 (track §3.4):
bynk.test.remote_clock_dependent, a warning for a remote run. In process everyClockreads the harness clock; a real runtime’s Workers read wall-clock time, which the runner can’t reach. So anexpectcomparing anInstantbuilt from constants can pass in process and fail remotely, and no--settleretry fixes that. - remote_
unsupported - #2138 (end-to-end testing track §3.7): what a remote run can’t honour.
Under
bynk test --against, asystemcase runs against a real deployment, which only answers on its publichttproutes. Returns thebynk.test.remote_unsupported_*refusal forcase, given the callees its body was checked with, orNonewhen it uses onlyhttpaddresses. - snapshot_
expects - Every
expect … matches snapshotinblock, at any depth, in source order (#2842). - stub_
after_ typechecks - #2683: whether a
stub … after <d>duration is aDuration. - suite_
helper_ namespace - #2834: the index namespace a suite with helpers records under: its target
(or, for a
systemsuite, its harness) and the file it is declared in. - suite_
ordinal - #1860: the ordinal of the suite at
parsed[i]among the suites inindices(each index whose file is a suite), orNonewheniis not one.StubScope::Suiteis keyed by it, so emission computes it the same way for each run. - typecheck_
case_ body - Type-check a test
case/propertybody against the target unit’s privileges, returning the inferredexpr_typesmap and theCalleeclassification recorded alongside it. The check path feeds real diagnostic/ref sinks; the emit path reuses it with throwaway sinks to give the case-body lowering full type information (so collection kernels — notablytrace(Cap.op)’sList[…]methods — dispatch on the receiver’s checked type) and fullCalleeinformation (P6.21 review: the emit path’s owncalleesaccumulator was previously built here and silently discarded —bynk-emit’ssynthetic_typed_commons_for_targetnever received it, soCallee::Intrinsic/Store/etc. were never recorded for anything inside a.test.bynkbody, even though this function computed them correctly all along). - typecheck_
integration_ case_ body - Type-check one integration test case body. The body lives in a synthetic
harness root that consumes every participant; entry calls
(
ctx.service(args)) are therefore ordinary cross-context calls. The body has typeEffect[Result[(), ExpectationError]](modelled asEffect[Result[(), ValidationError]], as in unit tests). - value_
block - v0.118: wrap a single expression as a
{ tail: e }block, so astubvalue can be type-checked or lowered in the same op-body position a provider operation’s tail occupies.