doctor: cache-gate the run, drop nix develop, gate on TING_DEVSHELL, quiet the terminal #94

Merged
larandar merged 1 commit from fastlane into main 2026-08-28 08:27:22 +00:00
Owner

.envrc bootstrapped an unconditional just doctor on every direnv reload,
so a fresh HTTP fetch, OpenSpec wiki sync, and jj/git config writes ran on
every re-entry into the directory -- far more often than any of those
inputs actually change.

Wrap doctor behind a new private doctor-cached recipe tagged
[cache(inputs = [...], extra = datetime_utc(...))]: just's own recipe
cache hashes the doctor script and flake.lock content, and the UTC-hour
extra key expires it on its own at least once an hour. A failed doctor run
is never cached (just only writes the entry on a zero exit), so the next
reload retries it rather than going quiet for an hour. Verified all of
this empirically against a throwaway justfile before relying on it.

Drop nix develop --command from set shell/set script-interpreter:
.envrc's use flake has already put the devShell on PATH before just
runs, so re-entering nix develop per recipe was pure overhead -- measured
at ~1.3s per call, warm, versus ~30ms for nu run directly; ~15s of pure
shell setup across doctor's 11-recipe chain on every cache-miss run.

That drop gives up a hermetic guarantee: nix develop --command proved
nu/gum came from THIS flake's devShell, not an ambient install elsewhere on
PATH. Close most of that gap back up with a hard gate: .envrc now exports
TING_DEVSHELL right after use flake, and .doctor.just requires it via
an eager top-level env_var() assignment alongside the existing direnv := require("direnv") -- confirmed empirically that an eager assignment halts
every recipe invocation (though not --list) before any recipe body runs,
same mechanism require() already relied on. A standalone invocation
without direnv active now fails immediately and loudly instead of quietly
running every recipe against whatever nu/gum happen to be ambient.
environment's own DIRENV_FILE comparison stays as a softer, continuing
diagnostic for the narrower case this gate can't distinguish: a stale load
for this same repo, not an absent one.

Also clear the terminal and leave a single recap line at the end of a real
doctor run, and clear plus a short success line right after use flake,
instead of leaving a screenful of per-check gum log noise in scrollback on
every shell entry.

.envrc bootstrapped an unconditional `just doctor` on every direnv reload, so a fresh HTTP fetch, OpenSpec wiki sync, and jj/git config writes ran on every re-entry into the directory -- far more often than any of those inputs actually change. Wrap `doctor` behind a new private `doctor-cached` recipe tagged `[cache(inputs = [...], extra = datetime_utc(...))]`: just's own recipe cache hashes the doctor script and flake.lock content, and the UTC-hour extra key expires it on its own at least once an hour. A failed doctor run is never cached (just only writes the entry on a zero exit), so the next reload retries it rather than going quiet for an hour. Verified all of this empirically against a throwaway justfile before relying on it. Drop `nix develop --command` from `set shell`/`set script-interpreter`: `.envrc`'s `use flake` has already put the devShell on PATH before `just` runs, so re-entering `nix develop` per recipe was pure overhead -- measured at ~1.3s per call, warm, versus ~30ms for `nu` run directly; ~15s of pure shell setup across doctor's 11-recipe chain on every cache-miss run. That drop gives up a hermetic guarantee: `nix develop --command` proved nu/gum came from THIS flake's devShell, not an ambient install elsewhere on PATH. Close most of that gap back up with a hard gate: `.envrc` now exports `TING_DEVSHELL` right after `use flake`, and `.doctor.just` requires it via an eager top-level `env_var()` assignment alongside the existing `direnv := require("direnv")` -- confirmed empirically that an eager assignment halts every recipe invocation (though not `--list`) before any recipe body runs, same mechanism `require()` already relied on. A standalone invocation without direnv active now fails immediately and loudly instead of quietly running every recipe against whatever nu/gum happen to be ambient. `environment`'s own DIRENV_FILE comparison stays as a softer, continuing diagnostic for the narrower case this gate can't distinguish: a stale load for this same repo, not an absent one. Also clear the terminal and leave a single recap line at the end of a real doctor run, and clear plus a short success line right after `use flake`, instead of leaving a screenful of per-check gum log noise in scrollback on every shell entry.
.envrc bootstrapped an unconditional `just doctor` on every direnv reload,
so a fresh HTTP fetch, OpenSpec wiki sync, and jj/git config writes ran on
every re-entry into the directory -- far more often than any of those
inputs actually change.

Wrap `doctor` behind a new private `doctor-cached` recipe tagged
`[cache(inputs = [...], extra = datetime_utc(...))]`: just's own recipe
cache hashes the doctor script and flake.lock content, and the UTC-hour
extra key expires it on its own at least once an hour. A failed doctor run
is never cached (just only writes the entry on a zero exit), so the next
reload retries it rather than going quiet for an hour. Verified all of
this empirically against a throwaway justfile before relying on it.

Drop `nix develop --command` from `set shell`/`set script-interpreter`:
`.envrc`'s `use flake` has already put the devShell on PATH before `just`
runs, so re-entering `nix develop` per recipe was pure overhead -- measured
at ~1.3s per call, warm, versus ~30ms for `nu` run directly; ~15s of pure
shell setup across doctor's 11-recipe chain on every cache-miss run.

That drop gives up a hermetic guarantee: `nix develop --command` proved
nu/gum came from THIS flake's devShell, not an ambient install elsewhere on
PATH. Close most of that gap back up with a hard gate: `.envrc` now exports
`TING_DEVSHELL` right after `use flake`, and `.doctor.just` requires it via
an eager top-level `env_var()` assignment alongside the existing `direnv :=
require("direnv")` -- confirmed empirically that an eager assignment halts
every recipe invocation (though not `--list`) before any recipe body runs,
same mechanism `require()` already relied on. A standalone invocation
without direnv active now fails immediately and loudly instead of quietly
running every recipe against whatever nu/gum happen to be ambient.
`environment`'s own DIRENV_FILE comparison stays as a softer, continuing
diagnostic for the narrower case this gate can't distinguish: a stale load
for this same repo, not an absent one.

Also clear the terminal and leave a single recap line at the end of a real
doctor run, and clear plus a short success line right after `use flake`,
instead of leaving a screenful of per-check gum log noise in scrollback on
every shell entry.
larandar deleted branch fastlane 2026-08-28 08:27:22 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Ting/Jostoph!94
No description provided.