# Dirty Work Investigation — 2026-06-06

## Trigger

A fresh-context agent implemented `.pi/extensions/questionnaire.ts` and reported it did not commit because the repo already had unrelated dirty work.

## Current Dirty Work Layers

Observed with `git status --short`:

### Layer A — Pre-existing operational/service work

These were already dirty before the current process-framework work began:

- `docs/server-change-log.md`
  - Adds SearxNG deployment entry for Proxmox `buntbox01`, LXC `103`, IP `192.168.0.133`.
- `tickets/active/2026-05-17-safe-web-browsing-and-prompt-injection-guard.md`
  - Adds SearxNG/prescan/isolated web researcher refinement.
- `runbooks/searxng-homelab.md`
- `tickets/active/2026-06-06-add-searxng-service.md`
- `tickets/artifacts/2026-06-06-add-searxng-service/`
- `tickets/artifacts/2026-05-17-safe-web-browsing-and-prompt-injection-guard/`

Likely root cause: another agent performed live SearxNG infrastructure deployment and documentation work but did not finish with a clean commit/handover boundary.

### Layer B — Nimrod process/framework work from this session

Created/modified while discussing DevOps QRSPI, handover, memory, AGENTS rewrite, defaults, and routing tests:

- `AGENTS.md`
- `systems/network-plan.md`
- `docs/context-hygiene-and-handover.md`
- `docs/devops-qrspi-framework.md`
- `docs/nimrod-memory-and-self-improvement.md`
- `docs/service-deployment-defaults.md`
- `docs/application-architecture-principles.md`
- `docs/question-asking-policy.md`
- `docs/hybrid-task-routing.md`
- `docs/fresh-context-routing-test-plan.md`
- handover/recovery templates
- `infra/proxmox-registry.yaml`
- `state/locks/README.md`
- multiple new process/coordination tickets
- fresh-context test artifacts

Root cause: useful process improvements were made while the repo already had unrelated dirty work. Because the dirty state was not first resolved, each additional improvement compounded the dirty tree.

### Layer C — Questionnaire extension work from another fresh agent

Created/modified:

- `.pi/extensions/questionnaire.ts`
- `.pi/extensions/README.md`
- `tickets/active/2026-06-06-interactive-pi-questionnaire-extension.md`

Root cause: the fresh agent correctly noticed unrelated dirty work and avoided committing, but still added another layer of dirty work to the same working tree.

### Layer D — User scratch/test file

- `test_agents_questions.txt`

Likely user-created scratch input for analysis. Should not be committed unless deliberately archived.

## Root Cause Summary

Primary root cause is not one bad file; it is lack of write isolation and commit/handover boundaries while multiple agents are working in the same repository.

Specific contributing factors:

1. Multiple agents used the same dirty working tree.
2. Agents did not stop or branch/worktree when pre-existing unrelated dirt was detected.
3. Infrastructure work and repo documentation work were mixed in the same tree.
4. Some agents produced useful output but did not leave a clean commit or scoped handover.
5. The repo lacks an enforced preflight decision: continue in-place, stop, create worktree, or ask user.

## Immediate Recommended Triage

Do not revert anything blindly.

Suggested grouping for review/commit/move decisions:

1. SearxNG operational deployment docs
   - server change log
   - SearxNG runbook
   - SearxNG ticket/artifacts
   - safe-web ticket refinement

2. Nimrod process framework docs
   - AGENTS rewrite
   - memory/handover/devops/defaults/hybrid/question policy docs
   - templates
   - infra registry/locks scaffold
   - process tickets

3. Questionnaire extension
   - extension implementation
   - extension README update
   - extension ticket

4. User scratch file
   - `test_agents_questions.txt`
   - likely leave untracked, move to artifact, or delete after confirmation

## Future Prevention

Before any write-capable task, agents should run:

```sh
git status --short
```

If unrelated dirty work exists, the agent should not continue writing in-place unless the user explicitly approves. It should propose one of:

1. **Stop and triage** dirty files.
2. **Create a new branch/worktree** for the new task.
3. **Use a separate clone/repo** for service-specific work.
4. **Proceed in-place only for documentation/recovery**, with a clear note that the tree is already dirty.

A write-capable agent should leave a scoped handover when it cannot commit.

## Suggested Policy Improvement

Add a stronger rule to `AGENTS.md` / repo isolation docs:

> If `git status --short` shows dirty files unrelated to the requested task, do not add new implementation work to the same tree. Either triage first, create an isolated worktree/branch, or ask the user for explicit approval to proceed in the dirty tree.
