Skip to content

Prevent ad-hoc diagnostic probes from writing scratch files into repo root #146

Description

@vicondoa

Problem

The repo root was repeatedly polluted with untracked scratch files such as test_mkfs.c, test_seek.c, test_fallocate.img, segfault.c, segfault, print_args.c, print_args, a.out, and similar one-off probe artifacts.

This was not caused by committed nixling test harnesses. A repository search for those exact scratch basenames finds no checked-in producer. The current root is clean after manual cleanup.

Root cause found

Recent ad-hoc diagnostic commands were executed with the working directory set to the repository root and used relative output paths/default compiler outputs. Examples found in session tool requests include:

cat <<EOF > test_mkfs.c
...
gcc test_mkfs.c && ./a.out

which created test_mkfs.c, test.img, and a.out in $ROOT.

Another probe did:

cat <<EOF > test_seek.c
... open("test_fallocate.img", ...) ...
gcc test_seek.c && ./a.out

which created test_seek.c, test_fallocate.img, and a.out in $ROOT.

GDB diagnostics similarly created segfault.c, segfault, print_args.c, and print_args in $ROOT. Some later probes were correctly moved to /tmp, which supports that the problem is the ad-hoc probe cwd/path pattern, not normal repo tests.

Why this matters

These files are not meant to be ignored. They should not be created in the checkout at all. Root-level scratch artifacts are noisy, can be accidentally committed, and violate the repo disk-hygiene contract.

Proposed fix

Do not solve this with .gitignore. Instead add guardrails that make the source obvious and prevent recurrence:

  1. Add a lightweight root-scratch denylist guard to an early local gate (check-tier0 or existing meta/policy gate) that fails if suspicious root-level probe artifacts exist (a.out, test*.c, test*.rs, test*.img, print_args*, segfault*, result.json, etc.).
  2. Update AGENTS.md / test guidance to require ad-hoc diagnostics and compiler probes to run in a temp directory outside $ROOT (for example mktemp -d "${TMPDIR:-/tmp}/nixling-probe.XXXXXX") or the session files directory, never the repository root.
  3. Consider adding a small helper script/function for diagnostics, e.g. tests/tools/probe-scratch.sh, that creates a tempdir and prints cd instructions so agents have a low-friction safe default.

Acceptance criteria

  • Running the root-scratch guard on a clean checkout passes.
  • Creating a representative root scratch file such as test_mkfs.c or a.out makes the guard fail with a clear remediation.
  • Guidance explicitly says ad-hoc probes must use /tmp or session scratch, not $ROOT.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions