Files
automaton/tasks/pre-existing-fixes/SPEC.md
T
gitea af66f5081d
CI / build (push) Has been cancelled
Fix pre-existing issues and update README for v2.0
- Fix _infer_state_from_artifacts: SPEC-only maps to research (was bug_find)
- Fix cmd_validate_folder: corrupted .state files now error instead of silent fallback
- Fix upgrade.sh: remove || true, add python3 check, use git rev-parse --git-dir
- Update README.md with --project flag, --can-edit modes, --upgrade, enforcement layers
- Add 6 new tests for inference and validation fixes
- Complete hook-install-process and readme-upgrade-docs tasks
2026-06-15 14:56:33 -04:00

3.4 KiB

Pre-existing Fixes

Goal

Fix 4 pre-existing issues in the enforcement layer.

Issues

1. _infer_state_from_artifacts heuristic bug

File: scripts/status.py lines 306-309 Problem: if "SPEC.md" in artifacts and "BUG_REPORT.md" not in artifacts: return "bug_find" — this is wrong. Having SPEC.md without BUG_REPORT.md could mean the task is in research, design, implement, etc. This condition is reached after line 304 checks for both SPEC+BUG_REPORT → adversarial_bug_find, so it only fires when BUG_REPORT.md is missing. But that's most tasks! The correct behavior is that SPEC.md alone should map to research (which line 318-319 already does). Fix: Remove lines 306-309 (the SPEC+no BUG_REPORT case). Also fix line 311 IMPLEMENTATION.md → bug_find — semantically, having only IMPLEMENTATION.md should map to implement completion, not bug_find. But since bug_find comes after implement, mapping to implement is wrong too. The safest fix: remove lines 308-311 so SPEC.md alone → research, IMPLEMENTATION alone → implement.

2. cmd_validate_folder unnecessary fallback after .state exists

File: scripts/status.py lines 563-566 Problem: After confirming .state exists (line 548-556 handles the no-state case), lines 563-566 fall back to _infer_state_from_artifacts if _read_state returns None. But if .state exists and _read_state returns None, that's a corrupted .state file — not something to silently paper over. Fix: After confirming .state exists, if _read_state returns None, error out instead of falling back to inference.

3. upgrade.sh silently swallows status.py --upgrade failures

File: scripts/upgrade.sh line 26 Problem: python3 "$STATUS_SCRIPT" --upgrade --project "$PROJECT_DIR" || true — the || true means failures are silently swallowed. With set -euo pipefail, this is even more dangerous because the script appears to succeed. Fix: Remove || true. If the upgrade fails, the script should fail. Add a clear error message.

4. upgrade.sh doesn't verify python3 is available

File: scripts/upgrade.sh Problem: The script runs python3 without checking it's installed. Fix: Add a python3 availability check at the top of the script.

5. Pre-commit hook doesn't handle bare repos or worktrees

File: scripts/upgrade.sh lines 60-62, scripts/git-hooks/pre-commit line 18 Problem: upgrade.sh checks for .git/hooks/ directory, and the pre-commit hook uses git rev-parse --show-toplevel. In bare repos, .git/ doesn't exist as a directory. In worktrees, .git is a file, not a directory. Fix:

  • upgrade.sh: Use git rev-parse --git-dir to find the hooks directory instead of assuming .git/hooks/
  • pre-commit: Already uses git rev-parse --show-toplevel which works for worktrees. No change needed there.
  • upgrade.sh: Use git rev-parse --git-dir to reliably find hooks dir

Acceptance Criteria

  • _infer_state_from_artifacts no longer returns bug_find for SPEC-only tasks
  • _infer_state_from_artifacts no longer returns bug_find for IMPLEMENTATION-only tasks
  • cmd_validate_folder errors on corrupted .state files instead of falling back
  • upgrade.sh fails loudly when status.py --upgrade fails
  • upgrade.sh checks python3 is available before proceeding
  • upgrade.sh uses git rev-parse --git-dir for hooks directory
  • All 200+ existing tests pass
  • New tests for each fix