Files
automaton/tasks/complete/fix-can-edit-path-prefix/SPEC.md
T
Lap Tran 4a2301b077
CI / build (push) Has been cancelled
Archive completed tasks, add cleanup commands, self-documenting dashboard UI
- Archive 79 completed framework-dev tasks from tasks/ -> tasks/complete/
- status.py: add --cleanup-done and --install-cleanup-schedule commands
- Add scripts/automaton-cleanup.sh for periodic task archiving
- Dashboard: rename 'Background' tab -> 'Agent', 'Cleanup' agent -> 'Completed Task Archiver', remove redundant group headers and pill badges, dim inactive agent placeholders
- .rules.md: add Self-Documenting UI Names rule
- New tests: test_cleanup_done.py, expanded test_app.py and test_task.py
2026-06-24 22:43:33 -04:00

1.3 KiB

Spec: fix-can-edit-path-prefix

Problem

--can-edit and --scope-check in scripts/status.py use str(file_path).startswith(proj_str) to verify a file is within the project directory. String startswith matches sibling directories: /home/user/project-evil/file.py matches prefix /home/user/project. This allows editing files outside the project boundary.

Affected locations:

  • scripts/status.py:951 (--can-edit --project --file)
  • scripts/status.py:1004 (--can-edit --task --file, framework case)
  • scripts/status.py:1010 (--can-edit --task --file, regular project case)
  • scripts/status.py:1047 (--scope-check)
  • scripts/status.py:1052 (--scope-check, framework check)

Fix

Append a trailing path separator to the prefix before comparison:

str(file_path).startswith(proj_str + os.sep)

Or use Path.relative_to() which correctly resolves path boundaries:

try:
    file_path.relative_to(project_dir.resolve())
except ValueError:
    # out of scope

Acceptance Criteria

  • A file in /home/user/project-evil/ is correctly rejected as out-of-scope when project is /home/user/project
  • A file in /home/user/project/subdir/ is correctly accepted as in-scope
  • Both framework and regular project cases work
  • Add a test in tests/test_status.py covering the sibling-directory edge case