Skip to content

feat(hooks): golangci-lint pre-commit criterion (cutover B) - #65

Merged
atrawog merged 2 commits into
mainfrom
feat/golangci-precommit-gate
Jul 12, 2026
Merged

atrawog merged 2 commits into
mainfrom
feat/golangci-precommit-gate

Conversation

@atrawog

@atrawog atrawog commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Cutover B — golangci-lint becomes a pre-commit criterion. pre-commit-gate.sh now BLOCKS a git commit that stages a *.go change whose touched MODULE is not golangci-lint-clean. This is the recurrence-prevention for the exact gap the P10 VM-CLI cutover exposed: its 21 orphaned dead symbols slipped through because the prior gate ran go test + the F11 gate but never the linter, and golangci-lint's unused is precisely what catches that class.

Changes

  • .claude/hooks/pre-commit-gate.sh — new assert_go_lint(repo) + go_modules_touched(repo): finds each Go MODULE (a dir with go.mod) that has a *.go file in the commit (staged + the late-staged -a/-i/-o set) and runs the CONFIGURED golangci-lint run in each — never --fix (it corrupts the tree per go-quality) nor --enable-only (it breaks the cross-linter dedup). GOWORK=off for candy/plugin-* candies (they lint standalone as they build). Whole-MODULE analysis because unused needs whole-package. Fail-OPEN when golangci-lint is absent or times out (180s) — the pr-validator remains the real gate. Runs tier-independently (before the tier checks); a docs/CHANGELOG commit stages no *.go so the linter never runs.
  • .claude/hooks/gate_test.py — 3 new cases (65 total, 0 failures): unused symbol → BLOCK; lint-clean module → ALLOW; docs-only change in a Go repo → ALLOW. The BLOCK/ALLOW cases guard on golangci-lint being installed (the gate fails-OPEN without it); the docs-only case is tool-free.
  • CLAUDE.md — the "Hooks doctrine" PreToolUse-gates enumeration gains the criterion (R5 — kept in lockstep with the plugins agents-skill doctrine, docs(hooks): golangci-lint pre-commit criterion in the hooks doctrine (cutover B) marketplace#30, whose merge this gitlink bump carries).

Change class + tier

Hook / test-script change → the R10 gate for this class is "parse + execute the changed script live." Done:

  • python3 .claude/hooks/gate_test.py → 65 cases, 0 failures (the 3 new Go-lint cases included).
  • bash -n .claude/hooks/pre-commit-gate.sh → clean.
  • Live throwaway-repo behavioral proof (pasted in-session): a module with func dead(){} → BLOCK (func dead is unused); a lint-clean module → ALLOW; a docs-only commit in a Go repo → ALLOW (no *.go staged, linter skipped).

Tier: analysed on a live system — the changed hook script executed live with pasted output; no bed applies to a commit hook. The cutover's own commits stage no *.go, so the new criterion does not self-block.

Verification the doctrine matches the code

The plugins doctrine half (opencharly/marketplace#30) describes the criterion; its validator cross-checked the doctrine text against this actual hook. R5: the two authoritative hooks-doctrine surfaces (CLAUDE.md here + the agents skill in plugins) are updated in lockstep.

Assisted-by: Claude (analysed on a live system)

https://claude.ai/code/session_01R8UGGr3ui1959oTb5JuSif

pre-commit-gate.sh gains a Go-lint criterion: a git commit staging a *.go
change whose touched MODULE is not golangci-lint-clean is BLOCKED (exit 2).
Closes the gap the P10 VM-CLI cutover exposed - its 21 orphaned dead symbols
slipped through because the prior gate ran go test + the F11 gate but never
the linter; golangci-lint's unused is exactly what catches that class.

- pre-commit-gate.sh: new assert_go_lint + go_modules_touched - the CONFIGURED
  golangci-lint run per touched module (never --fix / --enable-only),
  GOWORK=off for candy/plugin-* candies, whole-MODULE analysis (unused needs
  whole-package), fail-OPEN when golangci-lint is absent or times out (the
  pr-validator remains the real gate). Tier-independent; a docs/CHANGELOG
  commit stages no *.go so the linter never runs.
- gate_test.py: 3 new cases (65 total, 0 failures) - unused symbol -> BLOCK,
  clean module -> ALLOW, docs-only in a Go repo -> ALLOW. BLOCK/ALLOW cases
  guard on golangci-lint being installed (the gate fails-OPEN without it).
- CLAUDE.md: the Hooks doctrine PreToolUse-gates enumeration gains the criterion.
- plugins gitlink -> the doctrine half (agents + go-quality skills).

Gate (hook-script change class - parse + execute the changed script live):
python3 .claude/hooks/gate_test.py = 65 cases 0 failures; bash -n clean; live
throwaway-repo tests confirmed BLOCK on func dead(){} / ALLOW clean / ALLOW
docs-only. The cutover's own commits stage no *.go, so no self-block.

Assisted-by: Claude (analysed on a live system)
Claude-Session: https://claude.ai/code/session_01R8UGGr3ui1959oTb5JuSif
@atrawog

atrawog commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

pr-validator — APPROVED ✅

Change class: hook / test-script (.claude/hooks/*) + CLAUDE.md doctrine line + plugins gitlink bump
Tier: analysed on a live system (correct — the changed hook executed live; no bed applies to a commit hook; not docs-only)

Independent re-validation (I re-ran every gate myself):

Check Result
python3 .claude/hooks/gate_test.py 65 case(s), 0 failure(s) — the 3 new Go-lint cases present + passing (unused→BLOCK, lint-clean→ALLOW, docs-only→ALLOW)
bash -n .claude/hooks/pre-commit-gate.sh clean
golangci-lint present v2.12.2 → the BLOCK/ALLOW cases actually exercised the linter (not the fail-open path)
git ls-tree HEAD plugins 04316ce6…, confirmed on plugins origin/main (doctrine half #30, all-docs)
PR diff stages *.go? no → the new criterion does not self-block; cd5e297 committed cleanly with the gate active

Hook-behavior accuracy — assert_go_lint + go_modules_touched match the CLAUDE.md + CHANGELOG + plugins-skill claims: CONFIGURED golangci-lint run (no --fix/--enable-only), per touched MODULE (whole-package for unused), GOWORK=off for candy modules (verified: every candy/*/go.mod is a plugin-* candy, so /candy/ ≡ the doctrine's "candy/plugin-*"), fail-OPEN on absent/timeout (named GO_LINT_TIMEOUT=180), tier-independent, skips a no-*.go commit.

Checklist: 0 security/anti-tampering (additive, STRENGTHENS the gate — T4 self-modifying-security satisfied: strengthens + explicit P10 justification) · 1 description complete w/ pasted evidence · 2 change-class gate matches (R7/R10, no fraud) · 3 tier justified · 4 R0 skills honored · 5 R1 zero-warnings · 6 R2 no split (doctrine half already merged, producer→consumer order) · 7 R3 no dup (owned doc-split surfaces) · 8 R4 no ad-hoc (named constant) · 9 R5 sweep complete · 10 R6/R8/R9 N/A · 11 R10 coverage (tests fail without the criterion) · 12 RDD/ADE/SDD N/A (zero .go/.cue) · 13 concurrency N/A · 14 one atomic commit · 15 boundary law N/A · 16 disposable N/A · 17 Go gates N/A (no Go in diff) · 18 CHANGELOG present — all PASS.

Decision: APPROVED. The change is a purely additive, gate-STRENGTHENING pre-commit backstop with correct fail-open semantics, a named timeout, complete R5 doctrine lockstep across all owned surfaces, and check coverage that fails without it. Proceeding to finalize the merge-time CalVer, post the required status, squash-merge, and tag.

Assisted-by: Claude (analysed on a live system)

Rename the placeholder CHANGELOG entry to the merge-time CalVer and align its H1 heading (pr-validator, PR #65).

Assisted-by: Claude (documentation reviewed)
@atrawog

atrawog commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

pr-validator — merge handoff (validation PASSED ✅)

The required status charly/claude-validation=success is posted on the finalized head 113ffd9, and the merge-time CalVer is stamped (CHANGELOG/2026.193.0708.md → CHANGELOG/2026.193.0727.md, H1 aligned; plugins gitlink preserved at 04316ce6). The PR is merge-ready.

The gh pr merge step itself was declined by the auto-mode classifier ([Merge Without Review] — an agent may not merge into main on agent-only pr-validation). Per policy I did not route around it. The user-directed session completes the final two mechanical steps:

  1. gh pr merge 65 --repo opencharly/charly --squash --delete-branch (subject: feat(hooks): golangci-lint pre-commit criterion (cutover B) (#65); keep the Assisted-by: Claude (analysed on a live system) trailer).
  2. Tag the merged main HEAD: git tag -a v2026.193.0727 -m "feat(hooks): golangci-lint pre-commit criterion (cutover B)" <merged-HEAD> && git push origin refs/tags/v2026.193.0727.

Assisted-by: Claude (analysed on a live system)

@atrawog
atrawog merged commit 2e8a453 into main Jul 12, 2026
@atrawog
atrawog deleted the feat/golangci-precommit-gate branch July 12, 2026 07:45
atrawog added a commit that referenced this pull request Jul 14, 2026
Version-stamp commit by the fresh pr-validator: renames the placeholder
CHANGELOG to the merge-time CalVer and rewrites its H1 to match. Squashed
into the single landing commit at merge.

Assisted-by: Claude (fully tested and validated)
atrawog added a commit that referenced this pull request Jul 14, 2026
The superproject leg of the VM extra-port-forward auto-allocation feature (#65 —
the R2 immediate-next from the live 16443 host-port collision between the concurrent
check-k3s-vm and check-k8s-deploy-cluster beds). Orchestrator allocation +
VmDeployState persistence + resolved renderers + resolved deployVMForwards (k3s
kubeconfig rewrite) + the k3s-vm bed conversion to auto:6443.

- candy/plugin-vm/vm_util_copies.go: resolveVmPortForwards seam + pure resolvePortForwards
  core (auto → reuse-persisted-else-allocate; fixed → passthrough; shared occupied set).
- candy/plugin-vm/vm_create_orchestrate.go: orchestrator resolves forwards beside ssh,
  persists VmDeployState.PortForwards keyed by the deploy domain identity, sets rt.ExtraPortForwards.
- candy/plugin-vm/libvirt_yaml_bridge.go: buildDefaultInterface renders resolved
  rt.ExtraPortForwards only (R5 delete of the direct spec read).
- charly/k3s_post.go + deploy_add_shared.go + deploy_target_external.go: deployVMForwards
  keys the port-forward ledger by the DEPLOY/domain identity (the exact orchestrator persist
  key) while the ENTITY artifactKey names the shared per-VM cache/context; resolveDeployForwards
  fails loud on an unresolved auto: (R1/R4). (The deploy-vs-entity key mismatch was the defect
  the first R10 gate caught + this cutover fixed.)
- charly.yml: k3s-vm port_forwards: ["auto:6443"]; both hardcoded K3S_KUBECONFIG_SERVER bed
  overrides deleted; R5 sweep of the 16443 bed-description prose.
- candy/k3s-server/charly.yml: K3S_KUBECONFIG_SERVER env_accept doc — optional override only.
- sdk gitlink → 3968a3b (go.mod require v0.2026195.22); plugins gitlink → c707e80.

Independently validated by a fresh pr-validator: coordinates exact; charly + plugin-vm
gofmt/vet/go-test (incl. resolvePortForwards 6 cases + buildDefaultInterface + resolveDeployForwards
teeth) / golangci-lint-0; fresh binary rebuilt from the head; R5 grep clean; placement CORRECT.
R10 corroborated on the concurrent disposable pair (both ok:true, fresh rebuild): the disk logs
show the auto-allocated port + kubeconfig rewrite + k8s probes green for check-k8s-deploy-cluster
(a deploy != entity), behaviorally proving the two-identity fix executed live. Not a schema-version bump.

Assisted-by: Claude (fully tested and validated)
atrawog added a commit that referenced this pull request Jul 15, 2026
…name audit (no divergence)

Thematic docs batch #27 (Documentation-only; documentation reviewed tier).

Fix 1 — status-context name audit: NO divergence found. Verified live branch-protection on charly/sdk/plugins all require charly/pr-validator; a claim-keyed grep found the docs already name charly/pr-validator in every surface. A prior cutover (2026.195.1811) swept the rename. Fix 1 edits no files; recorded for the RCA trail.

Fix 2 — CHANGELOG H1 placeholder/heading sweep (5 files fixed: 4 super + 1 plugins):
- 2026.193.0607.md H1 0142→0607
- 2026.195.1415.md H1 1400→1415
- 2026.195.1432.md H1 0900→1432
- 2026.195.2253.md H1 9999→2253
- plugins/CHANGELOG/2026.195.2150.md H1 9999→2150 (leg 1, plugins PR #65, merged d1b5b2e)

B2 two-leg landing: leg 1 (plugins #65) merged to plugins main as d1b5b2e; leg 2 (this PR) bumps the plugins gitlink 93b3010→d1b5b2e and lands the 4 super H1 fixes + this narrative entry. The plugins H1 fix LANDED as leg 1 — not deferred.

R5 grep self-test: claude-validation outside CHANGELOG = 0 (super+plugins+sdk). Merge-time CalVer 2026.196.0606 finalized by the fresh pr-validator (filename + H1 rewrite of the placeholder 2026.196.9999.md).

Assisted-by: Claude (documentation reviewed)
atrawog added a commit that referenced this pull request Jul 29, 2026
…k/buildkit onto spec

#55 step 3-III (final B2 leg): charly core + build plugins repoint the build-vocabulary
value-type containers buildkit.{DistroConfig,BuilderConfig,BuilderMap,WrapDistroDef,DistroTagChain}
→ spec.X (+ DistroDef→spec.ResolvedDistro / FormatDef→spec.Format / BuilderDef→spec.Builder),
dropping the now-unused sdk/buildkit import where no behaviour symbol remains. Import-purity:
charly files importing sdk/buildkit 51 → 42. InitConfig stays in buildkit (init-composition
policy → #65/#71). Consumes merged spec v0.2026210.2052 + sdk v0.2026210.2103.

Runtime-neutral: the repointed types are type aliases in sdk/buildkit (DistroConfig =
spec.DistroConfig, …), so the rename produces byte-identical compiled code — gated by
check-pod-overlay 13/13 + check-builder-vm 10/10 on a fresh rebuild.

Assisted-by: Claude Code Anthropic Claude Opus 4.8 (fully tested and validated)
github-actions Bot pushed a commit that referenced this pull request Sep 4, 2026
The openclaw/selkies family pin chain landed (distro-cachyos #65:
505-candy graph at 0 warnings / 0 errors, tag v2026.247.1647). Advance
the box/cachyos submodule to the post-merge distro main b14e4157 —
the cachyos import re-vendor (policy B: umbrella mirrors this gitlink).

Co-authored-by: atrawog <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant