Fix review H-L1-01 .. H-L1-04

From mnema-talk v3.3.13, rendered on this site.

Reviewer: independent, read-only (phase 3). Base of every fix: 9e31b5d11 (main 56f6a4101 plus the hunt-lane1 tests). Each fix branch is one commit on that base (checked with git log 9e31b5d11..<branch>). One temp worktree per branch, all removed; nothing changed in the repository, nothing pushed.

FixBranch, commitVerdict
H-L1-01msch128/fix-h-l1-01, f8d838b46MERGE
H-L1-02msch128/fix-h-l1-02, a9f2a76dbMERGE
H-L1-03msch128/fix-h-l1-03, c74618ed0MERGE
H-L1-04msch128/fix-h-l1-04, 8e32de40dMERGE

No BLOCKER in any fix. SHOULD-FIX and NOTE items below can follow in a later change.


H-L1-01: complexity gate fails when gocognit does not run (f8d838b46, ci:)

Cause removed?

Yes. scripts/complexity-check.sh:18-29 merges stderr into the output, drops three known non-finding lines (exit status 1, go: downloading ..., gocognit: note: ...), and fails with "gocognit did not run cleanly" on any other line that does not match the finding pattern (:17). Every variant in the finding and the refutation is covered: unresolvable version, no network or proxy (go prints an error line), toolchain cannot build the tool (compiler output), a source file that does not parse (gocognit prints the parse error and exit status 1, which leaves the error line).

Own inputs (a fake go on PATH that prints a chosen output, the fixed script over a throwaway tree)

InputResult
signal: killed (OOM kill of the tool)exit 1, "did not run cleanly"
a finding line plus exit status 2 (tool crash after output)exit 1, "did not run cleanly"
gocognit: lstat loadtest/viewer: no such file or directory (a scanned directory removed)exit 1, "did not run cleanly"
only go: downloading ... lines (cold module cache, clean tree)exit 0 (no false failure)
CRLF line endingsexit 1, "did not run cleanly" (fails closed)
a plain finding plus exit status 1exit 1, "cognitive complexity above 15", finding listed
empty output, exit status 1exit 0 (see NOTE 1)

False failures (lead's question)

  • Legitimate output the guard does not know: read gocognit v1.3.0 cmd/gocognit/main.go. Besides findings it writes to stderr only through log with prefix gocognit: and no timestamp (SetFlags(0), :165-166): the one-time recursion note (:509, filtered) and two warning: lines (:222, :328) that occur only with -exact-recursion, which the gate does not pass. -avg (the "Average:" line) is not used. Receivers of generic types are printed without type parameters (recv.go:12-25), so no finding contains a space in the function field and the pattern at :17 matches every finding. The script on the real tree at the fix commit: scripts/complexity-check.sh v1.3.0 exit 0, no output. So no false failure today.
  • Slow or offline module proxy: the gate now fails (before: silently passed). That is the intended fail-closed behaviour and the same as scripts/staticcheck.sh. CI caches the module directory: the backend job's actions/cache step (ci.yml:200-209) saves ~/go/pkg/mod and ~/.cache/go-build keyed on Go version and go.sum, with a restore key on the Go version, so a warm cache has gocognit already and needs no proxy. The tool is pinned: GOCOGNIT_VERSION ?= v1.3.0 (Makefile:16).
  • A future gocognit release whose go.mod needs a newer Go than CI's would print a "switching to go..." line and fail the gate. Today gocognit needs go 1.24, the repository is on 1.27. See NOTE 2.

Test runs as a normal test and fails on revert

  • scripts/tests/test_gate_tool_failure.py: the expectedFailure marker is gone; 5 tests, OK. It runs in CI through make test-scripts (Makefile:105, ci.yml:270).
  • Reverted the script to the parent commit, kept the tests: 2 failures (test_complexity_check_fails_when_the_tool_does_not_run, ..._on_a_file_that_does_not_parse). Restored.
  • The two other new cases (a function scoring 21 still reported with exit 1, a clean tree exits 0) pin that the guard did not break the gate's normal path.

Defects introduced, gates

None found. Findings and allowlist comparison unchanged (:31-51). No allowlist entry, no limit raised. English only (node scripts/check-english-only.mjs ok). bash -n ok. shellcheck reports only SC2001 style hints, the same pattern the script already used (CI does not run shellcheck). Commit type ci: fits a gate script change.

Findings

  • NOTE 1, scripts/complexity-check.sh:19,24. The tool's exit status is still replaced by || true and exit status 1 is deleted unconditionally, so "exit status 1 and no finding" passes. With the real go run this cannot happen (gocognit exits 1 only after writing findings, main.go:211; every other failure prints a message), so it is not a defect today. Cheap hardening: fail when the output contained exit status 1 but found is empty.
  • NOTE 2, scripts/complexity-check.sh:19. A Go toolchain switch line after a gocognit bump fails the gate with "did not run cleanly". Fails closed and visible to whoever bumps the version; no change needed, possibly worth a word in the comment at :15-16.

H-L1-02: TestChatCoreStaysFree fails when go list cannot list the package (a9f2a76db, test:)

Cause removed?

Yes. internal/repo/boundaries_test.go:261-270: the skip is gone, -e is dropped, and any go list error is t.Fatalf with go list's stderr. Both halves of the finding are covered: a failing go tool fails the test, and a missing or renamed package is now an error (go list -deps ./internal/chat/nonexist exits 1, "directory not found"; measured). The refuter's point that TestPackageTreesKeepTheirLayerBoundaries also catches a missing core is unaffected (both tests pass).

Own inputs

InputResult
a non-cyclic forbidden import added to core (internal/sfu)FAIL "must stay below ... depends on [internal/sfu]"
an import of internal/chat/messages added to core (a cycle)FAIL with go list's "import cycle not allowed" (before: -e would have listed and maybe passed on the cycle)
a core file with a syntax error after the package clausePASS: go list reads only the import header, so the dependency list is still right; compiling fails elsewhere. Not a gap of this test.
a go on PATH that exits 0 and prints nothingPASS without looking (see NOTE 3)

Test runs as a normal test and fails on revert

  • scripts/tests/test_repo_guard_skip.py: marker removed; 2 tests, OK. Runs in CI via make test-scripts (Makefile:106).
  • go test -run 'TestChatCoreStaysFree|TestPackageTreesKeepTheirLayerBoundaries' -v ./internal/repo: both PASS.
  • Reverted boundaries_test.go to the parent: test_guard_fails_when_the_go_tool_fails fails. Restored.

Defects introduced, gates

None. Test-only change, so no behaviour change and no API. gofmt clean, go vet ok, English ok. Commit type test: right.

Findings

  • NOTE 3, internal/repo/boundaries_test.go:271. A go that exits 0 with empty output still passes. go list -deps always prints the listed package itself last, so asserting that the output contains .../internal/chat/core would close it. Contrived (needs a broken go that reports success), so a note.

H-L1-03: the frontend job fetches tag v2.9.12, and the test fails in CI without it (c74618ed0, ci:)

Cause removed?

Yes, both sides. ci.yml (frontend job, after checkout) fetches exactly that tag with git fetch --depth 1 --no-tags origin tag v2.9.12, and web/scripts/compat-baseline.test.ts:22-24 no longer skips when CI is set: a missing tag is a failure naming the fix. The job that runs test:tooling is the only one (ci.yml npm run test:coverage; Makefile and other workflows checked: sim-sweep runs one vitest file, release.yml only npm run build, the others run no node tests).

Own inputs (shallow, tagless clone of the fix branch from the public remote)

SituationResult
CI unset, no tagpass 1, skipped 1 (local behaviour unchanged)
CI=true, no tagfail 1 with "tag v2.9.12 is not in this checkout: the CI job must fetch it"
CI=false (the string), no tagfail 1 (see NOTE 5)
CI empty, no tagskipped 1
after the step's fetch command, CI=truepass 2, skipped 0
after the fetch, CI=true, version in the committed baseline changedfail 1
parent test file, CI=true, no tag, baseline changedpass 1, skipped 1 (the defect; confirms the revert fails the guard)

The extractor needs only git rev-parse <tag>^{commit} and git show <tag>:<path> (web/scripts/compat-baseline.ts:18-24, 140-142), so one commit with its tree is enough; the clone stays shallow (is-shallow-repository true, two shallow roots).

Cost and forks (lead's question)

  • Measured anonymously against the public remote: the fetch took 1.4 s and grew .git from 21 MB to 28 MB. The job's timeout is 15 minutes. The step is gated on code == 'true' like its neighbours; a change of only the baseline JSON counts as code (the docs filter matches only Markdown), so the test runs for exactly the change it guards.
  • Fork pull requests: actions/checkout points origin at the base repository, which is public, so the fetch needs no credentials; persist-credentials stays false. The gitleaks job in the same workflow already fetches from origin anonymously on pull requests, so this adds no new kind of access.
  • A transient fetch error now fails the frontend job (no retry). Rare and visible; see NOTE 4.

Defects introduced, gates

None. actionlint passes on ci.yml. No skipped test added; one skip narrowed to non-CI runs. No step runs untrusted input (the tag is a literal). Commit type ci: fits; the test change is in the same commit.

Findings

  • NOTE 4, ci.yml frontend job, new fetch step. The tag name is written in two places (the step and the test at web/scripts/compat-baseline.test.ts:23-24). A second checked baseline would need both edited. Fine for one tag; worth a comment if more are added. No retry around the fetch.
  • NOTE 5, web/scripts/compat-baseline.test.ts:22. Boolean(process.env['CI']) treats CI=false as CI and fails instead of skipping. Fails closed, so harmless; process.env['CI'] === 'true' would match what GitHub sets exactly, but then a CI that sets CI=1 would skip. Leaving it as is is defensible.
  • NOTE 6 (outside the fix): the refuter's remark stands that baselines for other tags are committed but only v2.9.12 is compared with its tag.

H-L1-04: daily workflow runs the two published-release guards (8e32de40d, ci:)

Cause removed?

Yes for "never runs": .github/workflows/release-check.yml runs TestLiveReleaseImage and TestPublishedBundlesSatisfyDesktopLayout daily and on dispatch against the latest release (or a given tag). Each step greps its -v log for --- PASS: <name>, so an unset variable (SKIP) or a renamed test ("no tests to run") turns the run red. The bundle test itself fails when the glob finds no zip (layout_test.go:344-347), and gh release download fails when no asset matches.

The finding asked for a post-release job; this is a daily one (see SHOULD-FIX 1).

Own runs

  • Both tests against the latest release (v3.0.8) by hand with the workflow's commands: bundle test PASS (mnema-web-3.0.8.zip ok), image test PASS (sha256:fb1bdfa3..., linux/amd64 and linux/arm64, release 3.0.8). This reads only public artifacts (GitHub releases, GHCR, public Sigstore).
  • Tag validation, the regex at :54 under bash: rejected v1$(id), v3.0.8;id, v3.0.8 followed by a newline and more text, v3.0.8 (trailing space), 3.0.8, v3.0.8-../../x; accepted v3.0.8-rc.1. The input reaches the shell only through env (:47), and the derived tag and image reach later steps through env (:66, :76), never through ${{ }} in a run line.
  • actionlint passes. AGENTS.md path check, doc link check, English check, gofmt and go vet on the two touched test files: all ok.

Workflow checklist

  • Actions pinned to full SHAs (the same SHAs as ci.yml and trust-expiry.yml). persist-credentials false.
  • Permissions: workflow-level contents: read, nothing else. The token can read repository contents and releases of a public repository; it cannot write, cannot push packages, and no secret is used. No registry login.
  • Triggers: schedule and workflow_dispatch only; neither runs for forks or pull requests, so no untrusted code or input reaches the job beyond the validated dispatch tag, which only a user with write access can set.
  • Timeout 15 minutes; go test's default 10 minute timeout sits inside it. No module cache (cache: false, no actions/cache), so each run downloads modules; acceptable for one run a day.

What a failing daily run tells whom (lead's question)

A failed scheduled run is shown in the Actions tab and, under GitHub's default notification settings, mailed to the account that last changed the workflow's cron schedule (here the account that commits the file). The run summary names the tag. Nothing else happens: no issue, no commit status, the release stays published, and the updater in the field is not affected (it verifies independently and fails closed). The same alert model as trust-expiry.yml and image-scan.yml, and documented as such in doc/development.md. A GHCR or Sigstore outage gives a false alarm for that day (no retry), which the log tells apart from a verification failure. GitHub disables schedules in a public repository after 60 days without activity; not a concern at this repository's rate, and the same for the sibling workflows.

Defects introduced, gates

None. Test files change only comments. Docs (AGENTS.md workflow list, doc/development.md Releases, the two test comments) match the workflow. English only. Commit type ci: right.

Findings

  • SHOULD-FIX 1 (non-blocking), release-check.yml:16-24. Add workflow_run: { workflows: [Release], types: [completed] } (job if on success). The commit message rejects a post-release step because release workflows are out of bounds, but a workflow_run trigger lives in this file and does not touch release.yml. It would run the guards minutes after a release instead of up to a day later. Release is itself triggered by workflow_run of CI, so this is the third level, which GitHub still allows. The run would use the default-branch checkout and gh release view, so no untrusted input enters. Keep the schedule for the "a later change makes a published release unverifiable" case.
  • NOTE 7, release-check.yml:74-82. GH_TOKEN stays in the environment of the go test in the bundle step. The token is read-only and the code is the default branch's own, so the exposure is nil in practice; splitting download and test into two steps would follow least privilege to the letter.
  • NOTE 8. The workflow checks the default branch's Verify code against the latest released image. That catches a drift that the next release's updater would hit; it does not re-check the already released updater binary (which the field runs). That is what the finding asked for; stated here so nobody reads more into a green run.

What I ran

  • scripts/complexity-check.sh v1.3.0 on the real tree at f8d838b46; python3 scripts/tests/test_gate_tool_failure.py with and without the parent script; seven fake-go probes.
  • python3 scripts/tests/test_repo_guard_skip.py with and without the parent test file; targeted go test -run on internal/repo; three injected core files and a fake go that exits 0.
  • A shallow tagless clone of the fix-03 branch from the public remote: node --test scripts/compat-baseline.test.ts under seven situations, the tag fetch timed and sized.
  • Both release guards against v3.0.8 with the workflow's commands; the tag regex on seven inputs.
  • actionlint (ci.yml, release-check.yml), gofmt, go vet, check-english-only, check-agents-paths, check-doc-links, bash -n, shellcheck.
  • All with nice -n 10, one heavy job at a time.

What I did not check

  • No real GitHub Actions run of any changed workflow: the schedule and dispatch triggers, the CI cache restore for gocognit, and the fork pull-request path are read from the files and GitHub's documented behaviour, not observed.
  • The full make test-scripts and the whole internal/repo package were not run (targeted tests only).
  • gocognit output on Windows or with GOFLAGS set in other environments.
  • The desktop client repository.

Second round: H-L1-04 delta, workflow_run trigger (843e7bc6c on msch128/hunt-harness-1, ci:)

Delta: release-check.yml gains workflow_run: { workflows: ["Release"], types: [completed] } and the job condition github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success'; header comment and AGENTS.md line updated. actionlint passes. Read in the checkout, nothing run on GitHub.

Verdict: MERGE. This closes SHOULD-FIX 1.

  • Security. A workflow_run run uses the workflow file and the checkout of the default branch, with the permissions this file declares (workflow-level contents: read) and no secrets. The job reads nothing from the event payload except workflow_run.conclusion in the if; no head_branch, head_sha, artifact or title reaches a run step, and actions/checkout uses no ref. Release itself starts only from CI runs with head branch main (release.yml:38-42). A fork pull request whose branch is also named main can start a Release run, but release-please runs only for workflow_run.event == 'push' (release.yml:61-63), so nothing is published. At most such a run triggers one release check of the latest real release, from the default branch's code. A fork cannot change what is checked or what runs.
  • Tag resolution. On workflow_run there is no input, so INPUT_TAG is empty and the step runs gh release view (latest release) as before; the regex still applies.
  • Ordering. Everything this check reads is published inside the same Release run. release-please creates the GitHub release and tag (job release-please). The image is pushed and cosign-signed in job image (release.yml:226-298), and the bundle is attached in job web-bundle (release.yml:472-585). A workflow run completes only after all of its jobs, so a successful Release run means image, signature and bundle are in place, and the latest release is the one just made. There is no later publishing run. Docker Hub mirroring is in the same run and is not read here.
    • Edge 1: if the bundle signing key is not configured, web-bundle skips its steps but succeeds, and no zip is attached. The bundle step then fails on "no assets match". That is a true signal and the same as in the daily run.
    • Edge 2: if one Release job fails, the conclusion is not success and the check does not run. The daily run covers that case.
  • Wasted runs. Every green push to main is released (release.yml header), so most Release runs publish and the check is useful. A run without a new release re-checks the latest release, which costs about a minute plus a module download. That happens when CI did not test main's tip, on a backfill dispatch of Release (mirror only), and on a fork pull request named main whose run ends in success. Those are the cases where the Release run's conclusion is success but nothing was published. A failed CI that still runs Release (release-please skipped) has a conclusion other than success in practice, so the if filters it; if GitHub reports such a run as success, the cost is the same one-minute re-check. Acceptable.
  • Chain depth: CI -> Release -> Published release check is three workflow_run levels, which GitHub allows. A fourth level must not be chained onto this workflow.
  • NOTE 9: the header comment at release-check.yml:13-14 ends a sentence fragment ("A") on its own line before "failed run is the alert". Cosmetic.

Something wrong on this page? Tell us.