Skip to content

docs(harness): fix 10 audit findings in the Loop-Engineering epic - #13

Merged
wasikarn merged 1 commit into
developfrom
docs/audit-fixes-loop-eng
Jun 11, 2026
Merged

wasikarn merged 1 commit into
developfrom
docs/audit-fixes-loop-eng

Conversation

@wasikarn

Copy link
Copy Markdown
Owner

Follow-up to PR #11/#12. An adversarial 6-dimension audit of the merged epic found 10 documentation-accuracy / consistency defects (no behavior bugs, no blockers). All fixed and fresh-context re-verified ALL-CLEAN.

Notable: 2 major (missing CHANGELOG entry; verification-trail.md overstated "two fields parsed by the consumer scripts" — true only for verification-gate.sh) · 5 minor (CONTEXT autonomy "or multi-iteration" literally banned recursive-improve's own gated loop; stale /fix-bug.md:103-119 line-pin; verification-tier-audit.py docstring red_green; workspace-surface-audit owner-only caveat; "session's trails") · 3 nit (dup phrase, comment semicolon, audit.sh invocation).

Green bar: harness-audit 0C/0W · plugin validate --strict ✔ · hook tests 131/0 · py_compile + bash -n pass.

Pre-existing defects (NOT in this PR, flagged for separate triage): docs/ARCHITECTURE.md cited in README.md:66 + CHANGELOG.md:114 after deletion in 04f823f; docs/adr/README.md ADR-index aspiration.

An adversarial multi-dimension audit of the merged epic (PR #11/#12) found 10
documentation-accuracy / consistency defects — no behavior bugs, no blockers.
All 10 fixed and fresh-context re-verified ALL-CLEAN.

- CHANGELOG.md: add the missing [Unreleased] entry for the epic (the repo logs
  even doc-only changes for archaeology).
- docs/agents/verification-trail.md: scope the "two fields are parsed" claim to
  verification-gate.sh — verification-tier-audit.py reads only verification_tier,
  recursive-improve-observe.py reads the journal, not the trail.
- CONTEXT.md: rebind the autonomy invariant's "or multi-iteration" so it no longer
  literally bans recursive-improve's own gated, capped multi-iteration loop.
- commands/feature-dev.md: de-pin the stale "/fix-bug.md:103-119" citation (shifted
  by the #3 insertion) to "/fix-bug.md Phase 5".
- scripts/verification-tier-audit.py: docstring no longer implies red_green is a
  parsed field (it is human-readable evidence; only verification_tier is read).
- docs/harness-decay-cadence.md: owner-only caveat on workspace-surface-audit (it
  lives in ~/.claude, not bundled — skip on external install); bash-prefix +
  optional-arg brackets on the audit.sh invocation.
- docs/agents/verification-trail.md: "the session's trails" -> "every trail in
  .scratch at session end (not session-tagged)".
- skills/recursive-improve/SKILL.md: drop a duplicated "autonomy invariant" phrase
  from the repoint.
- hooks/block-bash-doctrine-write.sh: clean the trailing-semicolon comment residue
  left after the HARNESS.md removal.

Green bar: harness-audit 0C/0W, plugin validate --strict exit 0, hook tests 131/0,
py_compile + bash -n pass.
@wasikarn
wasikarn merged commit 61cb6b0 into develop Jun 11, 2026
1 check passed
@wasikarn
wasikarn deleted the docs/audit-fixes-loop-eng branch June 11, 2026 11:47
wasikarn added a commit that referenced this pull request Jun 12, 2026
Closes SYNTHESIS #13 opt-IN/OUT contract gap. The F7 test-claim gate in
hooks/task-lifecycle.sh is load-bearing (12 tests in test-critical-hooks.sh
lock the always-on behavior), but operators may want pure L2 advisory mode
in sessions where they trust the teammate chain to surface test-claim gaps
another way. This commit makes the gate opt-OUT via KBG_ENFORCE_TASK_COMPLETED=0
— default is ON (preserves all 12 F7 tests), setting the env var downgrades
F7 to log-only for that session (event still journaled, no exit 2).

The plan literally said 'default OFF' but the repo state was 'already
always-on' (shipped at a20200b); owner picked 'opt-OUT' (default ON,
breaks nothing). Naming is the inverse of the 'comprehension-debt ceiling'
sub-rule: a ceiling is a hard upper bound, an enforcement toggle is a
default-on safety check.

3 changes:
- hooks/task-lifecycle.sh: ENFORCE_TASK_COMPLETED=1 default; flipped to 0
  only when KBG_ENFORCE_TASK_COMPLETED=0. Pure additive — no behavior
  delta for sessions that don't set the env var.
- eval/regressions/task-completed-enforcement.json (new, 2 evals): default-ON
  blocks (eval #1) + opt-out allows (eval #2). Pair guards both directions.
- eval/run-eval.py: hook-script grader gains expected_exit_code,
  expected_stderr (positive + negative, negation runs first to avoid
  'contains'-substring routing ambiguity), and env fields.
- METHODOLOGY.md: Rule 4 sub-rule 'TaskCompleted enforcement is opt-OUT,
  not opt-IN' parallel to the comprehension-debt ceiling sub-rule.
- CHANGELOG.md: Phase 2.3 entry.

Verification: 202/0 critical-hooks tests pass (12 F7 + 190 others, no
regression), 2/2 new task-completed eval fixtures pass, eval-runner syntax
check clean, bash -n task-lifecycle.sh clean. The 6 pre-existing dataset
heuristic mismatches in eval are not regressions from this change.
wasikarn added a commit that referenced this pull request Jun 21, 2026
Conservative prose-tighten of the 3 most verbose/self-restating passages — Rule 4
verify-loop paragraph, the TaskCompleted-enforcement sub-rule (was restating
opt-out/default-on 3x), and the comprehension-debt-ceiling sub-rule. Saved ~504
bytes; all 13 rules + 9 sub-rules + every provenance ref (SYNTHESIS #13/#15/#41,
ADR 0003, env vars, Böckeler) verified intact.

No version bump — rides with the next substantive release (too small for a
standalone cache cycle + restart; owner chose ride-along).
wasikarn added a commit that referenced this pull request Jun 24, 2026
Apply the safe findings from the repo-wide ponytail-audit. Net -41 lines,
1 file deleted, 0 deps added.

Hooks (caged, jq -cRs . encode swaps — byte-identical envelopes, verified
decode-equal vs the prior python json.dumps including emoji/unicode):
- doctrine-bootstrap, learn-drain-nudge, ideate-rotate, decision-provenance-nudge
- auto-mode-denial-log: terminalSequence via jq (OSC framing preserved)
- pr-style-reminder, mcp-session-watchdog: jq-built journal/additionalContext fields
- notify-sensor-staleness: source _lib.sh, replace 27-line inline python journal
  with a subshell journal_append call (exit-2 isolated so a journal failure
  can never suppress the staleness warning; SID threaded for journal_append)

Scripts/skills (non-caged):
- fold acceptance_cmd.py into run-acceptance.py and delete it (one consumer,
  zero external test importers — the 'independently testable' split was
  speculative). py_compile + extract_command smoke verified.
- memory-lint: delete dead parse_pointer_line (zero callers)
- memory-trim: extract md_bytes + lint_findings helpers for the 3x-repeated
  byte-count and lint-finding extraction (safe if/else form, ${f:-?} default)

Gauntlet: 6/6 layers PASS. Version 0.4.23 -> 0.4.24 in both manifests; no
description-count change (no agent/skill/command/hook added or removed).

Skipped with reasons: hypothesis-gate (\n trap), #6 witness.sh (no
err.sh-shaped helpers — CLI UX err_die would mangle), #7 audit mktemp
(at-exit-cleanup risk in load-bearing harness), #9 run-gauntlet (err.sh not
sourced; awk swap is perf = out of scope), #10 acli temp traps (marginal),
#11 ideate transcript dup (mid-confidence + just-stabilized SessionEnd path),
#14 cosine dup (low value).

Not applied pending owner confirmation (one-way doors): #1 mailbox suite
(~486 lines), #13 migrate-plan-to-board.py (~195 lines).
wasikarn added a commit that referenced this pull request Jun 24, 2026
… suite + migrate-plan-to-board.py

Owner-confirmed one-way-door deletions (ponytail #1, #13):
- scripts/mailbox/ (6 scripts, ~614 lines) — dead code, no callers
- docs/architecture-concerns-mailbox.md (76 lines) — orphaned design doc
- scripts/utils/migrate-plan-to-board.py (195 lines) — one-shot migration done

Ripple (5 files, all mailbox refs removed):
- commands/team-cleanup.md — drop Step 6 (reap mailbox), renumber 7-10→6-9, drop Mailbox column/cross-refs
- commands/team-build.md — drop 'mailbox/' from heartbeat/board infra prose
- docs/reference/env-vars.md — drop CLAUDE_MAILBOX_BASE row
- tests/hooks/runners/test-ch-orphaned-runners.sh — drop test-mailbox.sh from orphan-runner enumeration
- BOUNDARY.md — regen (0 mailbox mentions)

Gauntlet: 6/6 layers green. No counted plugin surface changed (no version bump).
wasikarn pushed a commit that referenced this pull request Jun 30, 2026
…cut (v0.6.3)

Verified zero live consumers for each (grep-confirmed) before removal.
- commands/dismiss-stale.md: permanent no-op (consumer hook + sensors.json absent).
- agents/inferential-structural-judge.md: dormant advisory (backing SessionEnd hook
  absent; input contract unsatisfiable). Swept live pointers in kbg-help.md,
  orchestrate/reference.md (13→12-agent fleet), ideate-critic.md. Design doc kept
  as history; harness-health.py verdict lens deferred to Wave D #13.
- skills/documentation-lookup: thin Context7 MCP wrapper; re-homed the non-native
  value (3-call cap, selection criteria, secret redaction) into
  docs/reference/mcp-catalog.md Context7 row before deletion.
- skills/repo-scan: only skill doing an install-time external git fetch;
  architecture-overview covered by codebase-onboarding + code-review-graph MCP.
- skills/harness-audit --coverage mode: wrapper execs a deleted .py (crashes);
  removed harness-coverage.sh + references/coverage.md + SKILL.md mode entry.
  --health desc claim deferred to Wave D #13 reconciliation.

Updated manifest descriptions (47 skills · 12 agents · 24 commands) and dropped
dismiss-stale/sensor-staleness keywords; fixed stale counts in onboarding.md +
kbg-help.md. Bumped both manifests v0.6.2 → v0.6.3. Gauntlet all green.
wasikarn pushed a commit that referenced this pull request Jun 30, 2026
…scan routing (v0.6.4)

- #18 Consolidate refactor-clean command onto refactor-cleaner agent (sync-seam
  drift: command covered 6 ecosystems, agent was JS-only). Moved the multi-lang
  tool table (vulture/deadcode/cargo-udeps) into agents/refactor-cleaner.md so the
  spawned agent no longer silently misses dead Python/Go/Rust code; rewrote
  commands/refactor-clean.md to delegate (agent: refactor-cleaner + subtask: true),
  keeping only usage/args/output contract. Precedent: security-scan delegation.
- #15 Fix security-scan dead routing: frontmatter `agent: everything-claude-code:
  security-reviewer` resolved to nothing (ECC plugin not installed); repointed to
  bare `security-reviewer` (kbg's own agent). Removed dead skills/security-scan/
  SKILL.md link from the Links section.

#14 (harness-audit desc --health claim) folded into Wave D #13 (--health owns it).
Bumped both manifests v0.6.3 → v0.6.4. Gauntlet all green.
wasikarn pushed a commit that referenced this pull request Jun 30, 2026
…ing doctrine (v0.6.6)

Operator-approved (open-questions A simplify, D re-point, F METHODOLOGY+skill).
- #16 ship-task: simplify the broken loop in place (accept-task + run-acceptance.py
  were deleted in v0.6.0, breaking Phase 3 + Phase 5). Phase 3 → "define done criteria"
  (no deleted skill); Phase 5 → project test-suite + type-check as the deterministic
  GREEN/AMBER/RED gate; dropped the stale post-edit-test hook ref + ux-reviewer.
  Rewrote pre-ship-verify.md to the test-runner auto-detect + criteria cross-check.
  Removed the dead accept-task/run-acceptance refs from fix-bug, ship-change,
  review-pr, ship-merge; trashed the two run-acceptance.sh wrappers.
- #17 recursive-improve: stripped dead recursive-improve-observe.py refs (Step 1 +
  Rule 5 verifier + .scratch phase-4 ref). Observe now runs harness-audit + MEMORY.md
  + transcript; Verify re-runs harness-audit (audit exit count = the loop's branchable
  score). DMI flag + per-mutation AskUserQuestion gate + no-model-self-start
  preserved (audit #30/#32 untouched). Orphaned KBG_DEBT_* removed from env-vars.md.
- #13 CLAUDE.md §Architecture reconciled to the 4-dir/7-hook reality (dropped the
  governance-events.jsonl claim); harness-health.py rewritten to a cost-only reader
  over the live costs.jsonl (verdict + staleness lenses retired — sources gone;
  cost lens re-pointed per open-question D); health.md rewritten to match; harness-
  audit desc + kbg-help --health row updated (#14 fold). Trashed the 2.1MB orphan
  ~/.claude/governance-events.jsonl. (audit.sh --staleness-only block + review-pr
  journaler degrade gracefully — noted as follow-on, not touched.)
- #F Decision Scoring Framework adopted as doctrine: METHODOLOGY Rule 14 (criteria
  + weights + score + pass/floor gates + trace + ข้อมูลไม่เพียงพอ block) generalizes
  score-not-feel from loop exits to all decisions; new kbg:score-decision skill
  (user-invoked, on-demand formal artifact). Refreshed plugin cache to clear the F1
  new-component transient; regenerated BOUNDARY.md.

Bumped both manifests v0.6.5 → v0.6.6 (47 skills · 11 agents · 24 commands).
Gauntlet all green.
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