Skip to content

refactor(kuna): decide Kuna readiness once for doctor and runtime - #10997

Merged
morluto merged 2 commits into
mainfrom
refactor/kuna-admission
Nov 15, 2026
Merged

morluto merged 2 commits into
mainfrom
refactor/kuna-admission

Conversation

@morluto

@morluto morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Summary

Kuna readiness is now one decision shared by runtime availability and rea doctor: valid settings and a REA_KUNA_COMMAND that is an executable regular file. Doctor reports its version probe and cache inspection as separate health checks beside that decision instead of folding them into availability.

Problem and expected behavior

KunaProvider.inspectAvailability admitted Kuna from its settings and an executable command, while doctor's available also required a successful kuna --version probe and a usable cache root. The two disagreed: with a command whose version probe fails, or a cache root that is a file, doctor reported Kuna unavailable while the runtime provider reported it available. Each also kept its own copy of the settings-to-failure mapping and the executable check.

Expected: doctor's availability equals runtime's. The probes runtime does not pay for at readiness remain visible in doctor as labelled health checks.

Change and scope

  • New owner src/kuna/KunaAdmission.ts (admitKunaCommand): reads the Kuna configuration and checks the command is an executable regular file; it launches nothing and touches no cache.
  • KunaProvider.inspectAvailability projects the admission (its own accessSync/statSync copy and the unused command_not_file document code are removed).
  • inspectKunaInstallation starts from the admission (its configuration-failure mapping and access/stat checks are removed; it keeps realpath for the executable identity, then fingerprints and probes as before). An already-cancelled caller is checked before admission, preserving the existing pre-abort test.
  • inspectKunaProvider (doctor): available and the installation check come from the admission. When admitted, it adds a version health check (the existing probe, fingerprint and cleanup/cancellation handling) and a cache health check; neither changes available.
  • docs/kuna-provider.md documents the readiness decision and the two health checks.

Not changed: rea setup still lists Kuna as a ready provider only when every Kuna check passes (the intent of f5d1012, #5105), so a blocked cache still keeps Kuna out of setup's ready list while available reports true.

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Contract and boundary impact

  • Semantic owner and earliest changed stage: admitKunaCommand owns Kuna readiness; provider availability, the installation inspection and doctor project it.
  • Contribution scope fit and linked maintainer decision: not applicable; coordinator decision to share admission between doctor and runtime and report the probes as health checks.
  • CLI and MCP/tool-catalog contract: rea doctor --json Kuna inspection: available now follows admission; checks are installation (admission; its ok detail names the command), version (moved from installation: version, sha256, verified-version note) and cache (unchanged). Projected doctor check names become kuna-prefixed installation, version, cache. Runtime availability diagnostics for a refused setting gain setting. No tool-catalog change.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: none; analysis profiles still record the probed version and digest.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): probe cleanup and cancellation handling are unchanged and now report on the version check.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: kunaDoctor.test.ts adds "agrees with runtime availability" for a failing version probe, a non-executable command and a missing command (doctor available equals KunaProvider.inspectAvailability(), and a refusal carries the runtime's code, reason and remediation). Existing doctor, setup-readiness, hash-owner and CLI setup tests updated for the version check and for cache health no longer deciding available.
  • Base reproduction or other evidence: on the base commit the new agreement test fails for the failing probe and the missing command (run with the base src/kuna restored).
  • User-visible CLI/MCP output (if applicable): a Kuna whose cache root is a file now reports available: true with a failed cache check; a Kuna whose --version fails reports available: true with a failed version check (version_unresolved).
  • Remaining proof gaps: fake Kuna only; no real Kuna run.

For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:focused -- tests/boundary/providers/kuna/kunaDoctor.test.ts — 20 passed (7 fail with the base src/kuna).
  • npm run test:focused -- tests/boundary/providers/kuna/kunaSetupReadiness.test.ts tests/boundary/cli/setupProviderReadiness.test.ts tests/boundary/providers/kuna/kunaProvider.test.ts tests/boundary/providers/kuna/kunaSelectedCommand.test.ts tests/boundary/providers/kuna/kunaVersionProbeOwnership.test.ts tests/boundary/providers/kuna/kunaInstallationLifetime.test.ts tests/boundary/providers/kuna/kunaInstallationAttribution.test.ts tests/boundary/providers/kuna/kunaInstallationCancellation.test.ts tests/boundary/providers/readinessRemediationInventory.test.ts src/doctorRuntime.test.ts tests/boundary/providers/kuna/kunaCommandFailures.test.ts — 121 passed, 1 skipped.
  • npm run test:focused -- tests/boundary/providers/kuna/kunaHashOwnerPropagation.test.ts tests/boundary/providers/kuna/kunaInstallation.test.ts tests/boundary/cli/setupProviderReadiness.test.ts tests/boundary/providers/kuna/kunaSetupReadiness.test.ts — 43 passed.
  • npm run check:fast — passed. npm run docs:check — passed. node scripts/verify/architecture-guards.mjs — passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none to settings. Doctor JSON consumers that read the version from the Kuna installation check now find it on the version check; available no longer reflects cache or version-probe health.
  • Real Hopper/Ghidra, browser, or OS coverage: none; fake Kuna on macOS.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: runtime readiness still launches nothing; doctor runs the same probe as before.

Author readiness

Human owner:

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

Runtime availability admitted Kuna from its settings and a runnable command,
while doctor also required a passing version probe and cache inspection, so
doctor could report Kuna unavailable while runtime admitted it.

admitKunaCommand is now the one readiness decision: provider availability,
the installation inspection and doctor's installation check all project it.
Doctor reports the version probe and the cache inspection as separate health
checks (version, cache) beside admission; they no longer decide availability,
and runtime still does not pay for them. Setup continues to list Kuna as a
ready provider only when every check passes.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T09:46:13.035064Z c6dbaae New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issue was found.

Summary

Kuna now shares one readiness decision between runtime and doctor.

  • Kuna runtime and doctor use the same readiness rule.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["admitKunaCommand: settings and executable file"] --> B["Runtime availability"]
  A --> C["Doctor installation check"]
  C --> D["Doctor version health check"]
  C --> E["Doctor cache health check"]
  C --> F["Setup ready list"]
  D --> F
  E --> F
  F --> G["Include Kuna only when every check passes"]
Loading

Reviews (2) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

# Conflicts:
#	tests/boundary/providers/kuna/kunaDoctor.test.ts
@morluto
morluto merged commit 27b732e into main Nov 15, 2026
13 checks passed
@morluto
morluto deleted the refactor/kuna-admission branch November 15, 2026 10:01
Comment thread src/kuna/KunaAdmission.ts
diagnostics: { configured: true, command },
});
try {
accessSync(command, constants.X_OK);
Comment thread src/kuna/KunaAdmission.ts
});
try {
accessSync(command, constants.X_OK);
if (!statSync(command).isFile())
@morluto morluto added area: setup Setup, packaging, upgrade, install, Doctor, and client registration provider: kuna Analysis provider / engine: kuna labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: setup Setup, packaging, upgrade, install, Doctor, and client registration provider: kuna Analysis provider / engine: kuna

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants