A4: Make a messy repository agent-ready
At a glance
- Task: improve the supplied small, course-made synthetic messy repository with instructions, a blocking hook, structure and checks.
- Week: 5
- Weight: 2.5 points
- Due: Sunday 23:59 in the listed week
- Hand in: your revised repository, probe outputs, and
report.json. - Done when: a bad commit is rejected, a good commit and regression pass, and the map tells a new agent where to work.
- Time: published after a timed pilot; record your prediction and actual time.
Objectives
Create repository guidance and gates that support safe agent changes (LO2, LO4).
Prerequisites
Follow the safety practices in syllabus §9:
- Run the agent in a dedicated directory or container.
- Keep residency, employer and cloud credentials out of that environment.
- Keep keys out of repositories, prompts, screenshots and logs.
- Run injection demonstrations offline against the local machine only.
Use the mature coding-agent seat supplied for the course. Do not run an unknown generated command on a credential-bearing host.
Tasks
- Inspect. Copy
starter/, make the baseline commit described in its README, and map one behaviour to its files, tests and check command before asking for a change. The assigned bad commit addsprint("debug: leaked value")toapp.py; your hook must make thatgit commitexit non-zero. -
Generate. Ask the agent to propose an instruction file, a small pre-commit hook and a structural cleanup. Review every command before running it. Put the hook where Git and your reader can both find it:
```bash mkdir -p .githooks
write your hook to .githooks/pre-commit, then:
chmod +x .githooks/pre-commit git config core.hooksPath .githooks git add .githooks/pre-commit git commit -m "Add pre-commit hook" ```
core.hooksPathis a local setting and is not part of a commit, so name that command in your instruction file. The hook file itself must be committed; a hook left in.git/hooks/is not handed in. 3. Verify the gate. Run the three probes as commands and keep each command, exit code and output:```bash
bad commit: must exit non-zero
echo 'print("debug: leaked value")' >> app.py git add app.py git commit -m "bad probe"; echo "exit=$?" git restore --staged app.py && git restore app.py
good commit: a documentation or behaviour-preserving change; must exit zero
printf '\nReviewed.\n' >> NOTES.md git add NOTES.md git commit -m "good probe"; echo "exit=$?"
regression: must pass
python -m pytest -q; echo "exit=$?" ``` 4. Check structure. Confirm the instruction file names the same commands and invariants that the repository actually contains. 5. Revise. Fix one stale instruction or weak check and repeat all three probes. Write the decision line.
Generation is the agent's proposed repository change; verification is the three probes and direct file inspection.
Deliverables
Include the revised repository, the behaviour-to-code map, probe outputs and report.json. Name before and after revisions. Run:
python practice/a4/check.py path/to/submission
Grading
Criteria are usable instructions; a hook that blocks the assigned bad commit; passing good and regression checks; clear structure; and evidence for one revision. The public check verifies record consistency and cannot replace a code review.
AI use rules
Green: proposing documentation, a hook and refactoring ideas. Yellow: generated code after you inspect it and run the probes. Red: accepting a gate, interpreting a failure and making the decision. Keep credentials and private data out of the agent environment and logs. Attach one AI-use note ID.
Estimated time
Published after a timed pilot. Record predicted and actual time; ask for support when a hook or check behaves differently from its description.
Work record outline
A4 report
before_revision: TODO
after_revision: TODO
instruction_path: TODO
structure_evidence: [TODO]
probes: [{case: bad_commit|good_commit|regression, command: TODO, exit_code: TODO, evidence: [TODO]}]
explanation: TODO
ai_use_note: TODO
decision: accept | narrow | recheck | stop
because: evidence ID(s)
next: TODO