Files
rea/tests
2dea2c2038 feat(kuna): admit PE/COFF, and forward the engine's spec variables (#15058)
* kuna: admit PE/COFF and forward the engine's spec variables

PE x64 is the class kuna handles and no other provider here does; its .pdata is a
better boundary source than discovery (430,906 discovered against 299,257
.pdata extents on one 120 MB image). Admission is the format check only — kuna
opens at the header base itself.

A source-built kuna also finds its compiled specs through KUNA_SPECS or
SLEIGHHOME, and the child environment carried only HOME/XDG_CACHE_HOME/NO_COLOR,
so a build install failed with 'Could not find .sla' and it read as a target
problem. Both are forwarded when set; a release kuna carries its specs and is
unaffected.

Adds the env test, flips the PE admission assertion, and says both in the
provider doc.

* chore: rerun checks

* fix(kuna): bind selected spec trees into the child and the cache

Forward KUNA_SPECS and SLEIGHHOME from the environment captured for the
provider, not from the ambient process. Hash each selected tree into the
analysis profile and export key so an in-place rebuild cannot reuse an
older result, and give a tree that cannot be hashed its own inspection
fence.

* fix(kuna): revalidate spec trees at launch and admit only x86-64 PE

The session kept the first specification digest, so a later export could
read a rebuilt tree and publish it under the earlier key. Each command
and export now hashes the selected trees again and keys the result with
that read; a tree that cannot be confirmed becomes an unknown identity
with a new reuse fence.

Directory close failures are retained on the caller's resource scope, and
the entry cap stops the directory read instead of buffering every name.
PE admission is x86-64; other PE architectures are refused.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* style(kuna): format the launch-revalidation changes

oxfmt --check rejected KunaProjectCache, KunaSessionClient, KunaSpecIdentity,
and the spec identity test. Apply the repository formatter.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(kuna): own spec identity once per launching operation

Compute one specification snapshot inside the session's classified
failure boundary and use that value for the cache key, the close key,
the profile, and the launch. Cached answers from an adopted project do
not walk the tree again. A tree that differs from the committed profile
is refused and the adopted reader is dropped. Directory close retains
one lease, and the session dialect keeps that cleanup on the classified
error.

Delete the extra refreshes in project build and command launch.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(kuna): check spec identity when a child spawns

Drop the operation allowlist. Each operation carries one memoized
confirmation, and runKunaCommand runs it under that command's deadline
before spawn. An unidentifiable tree reuses the fence minted for the
resolved profile, so the export key matches the profile BinarySession
commits. Relative spec paths are resolved from REA's working directory
when they are selected. A spec-file close keeps the lease the hook
returns, and installation retention is keyed by the original owner.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(kuna): keep spec-scan leases with the spawn owner

A shared export was retaining a failed spec close on the client that
started the build. That client can close while another client still
waits, and its close does not join the scan. The scan now runs in the
cache scope and the lease it returns is the cache's hash lease, so
close and settled can still release it. A client-owned command keeps
the lease in that command's scope.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(kuna): isolate each spec scan's signal and deadline

Spawns still share one identity result, but each waits on its own abort,
budget, and cleanup owner. The child timeout is whatever budget remains
after the scan and names the Kuna timeout setting.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* test(analysis-view): accept either oversized-page parent recovery

Source tests merge this branch with main, whose fixed-allowance recovery
no longer says "caller-supplied bundle".

Co-authored-by: morluto <morluto@users.noreply.github.com>

* test(views): drop recovery-prose lock on oversized route refusal

* fix(kuna): bound installation spec reads by the function timeout

identifyKunaExternalSpecs requires the caller's deadline. Inspection uses
REA_KUNA_TIMEOUT_MS, or the version-probe deadline when that timeout cannot
be read, and reports AnalysisTimeoutError.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(kuna): own spec scans through close and register spec roots

A cancelled wait keeps the physical spec read on the command or export
scope until its close settles. Setup and doctor copy an explicit
KUNA_SPECS or SLEIGHHOME into the client registration.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(kuna): retry a clean spec timeout and re-list walked directories

A spec-read timeout keeps a failed close's lease. A clean installation
timeout is not reused, so the next settings scan again. The walk re-lists
each directory and refuses the digest when the name set changed.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(kuna): keep spec-scan waits bounded and save absolute spec roots

The caller's wait ends at its deadline while the scope still owns the
read. Setup stores KUNA_SPECS and SLEIGHHOME as absolute paths.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* refactor(kuna): verify spec trees inline at each spawn

Replace the shared, detached per-operation spec scan in KunaSessionClient,
and the ownSpecScan plumbing that kept it owned, with an inline check in
runKunaCommand beside the executable-digest check. Each spawn reads the
tree under its own signal, deadline and cleanup owner, so the scan cannot
outlive the request or the shutdown that admitted it.

- Route every Kuna deadline timeout, including the spec-read timeout and
  its cleanup facts, through one kunaDeadlineTimeout owner.
- Move spec-variable selection into KunaConfiguration, its only reader.
- Pass an owner cancellation reason to the scan timer and read the
  function timeout through readRuntimeSetting (architecture guards).
- Cover a spec-file close failure that coincides with the scan timeout.

* fix(kuna): report late spec scans as timeouts and keep empty selections

- Check the deadline after the final directory read and close, so a scan
  that finishes past its budget is a timeout, not an identified tree.
- Convert only a deadline-stopped read to a timeout; an earlier physical
  failure keeps its cause beside the cleanup it left.
- Keep an explicitly empty KUNA_SPECS or SLEIGHHOME empty in setup and
  doctor registrations instead of resolving it to the working directory.

* test(kuna): remove wall-clock timing from spec deadline tests

- Observe the timeout the strings child is granted instead of asserting
  elapsed time; the scan delay must come out of that grant. A control that
  gives the child the full budget fails the test.
- Block the failing spec close on the scan's own deadline signal, with a
  test-owned release, instead of racing a fixed delay against a 20 ms
  deadline.

* fix(kuna): keep launch directory cleanup and report doctor spec timeouts

- A spec directory whose close failed during a launch scan now reports its
  retained cleanup through kunaRetainedResourceCleanupError instead of a
  plain adapter error, so the command reports cleanupIncomplete until its
  scope retries the handle.
- Doctor projects a spec read that exceeds kuna.function_timeout_ms into a
  failed Kuna version check with the timeout's recovery, instead of
  aborting the doctor run.
- Narrow the granted child timeout in the deadline test (CI typecheck).

---------

Co-authored-by: sharif <sharif@localhost>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: morluto <morluto@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-29 22:51:59 +00:00
..