# DOX framework - DOX is highly performant AGENTS.md hierarchy installed here - Agent must follow DOX instructions across any edits ## Core Contract - AGENTS.md files are binding work contracts for their subtrees - Work products, source materials, instructions, records, assets, and durable docs must stay understandable from the nearest applicable AGENTS.md plus every parent AGENTS.md above it ## Read Before Editing 1. Read the root AGENTS.md 2. Identify every file or folder you expect to touch 3. Walk from the repository root to each target path 4. Read every AGENTS.md found along each route 5. If a parent AGENTS.md lists a child AGENTS.md whose scope contains the path, read that child and continue from there 6. Use the nearest AGENTS.md as the local contract and parent docs for repo-wide rules 7. If docs conflict, the closer doc controls local work details, but no child doc may weaken DOX Do not rely on memory. Re-read the applicable DOX chain in the current session before editing. ## Re-reading on Recheck Queries When asked to "recheck", "re-verify", "look again at", or similar re-query language for a topic, re-read the canonical source for that topic rather than relying on session memory. Session content is a cache, not a source of truth; the canonical file may have changed since it was last read. Examples: `GOALS.md` for goals, the nearest owning `AGENTS.md` for a subtree, `punkproject.toml` for project version. Re-scanning a directory for files not yet read this session is complementary, not a substitute for re-reading the canonical index. ## Update After Editing Every meaningful change requires a DOX pass before the task is done. Update the closest owning AGENTS.md when a change affects: - purpose, scope, ownership, or responsibilities - durable structure, contracts, workflows, or operating rules - required inputs, outputs, permissions, constraints, side effects, or artifacts - user preferences about behavior, communication, process, organization, or quality - AGENTS.md creation, deletion, move, rename, or index contents Update parent docs when parent-level structure, ownership, workflow, or child index changes. Update child docs when parent changes alter local rules. Remove stale or contradictory text immediately. Small edits that do not change behavior or contracts may leave docs unchanged, but the DOX pass still must happen. ## Doc Restructures Rules for any bulk restructure, normalisation, or migration of documentation (index reshapes, field-format normalisation, file moves/renames across many docs): - Conservation check before committing: extract the deleted lines from the diff and account for every non-blank one - it must be relocated verbatim somewhere in the new tree, be pure boilerplate/stub text (e.g. "see index (canonical)" placeholders), or be a deliberate drop named explicitly in the commit message. A preservation claim in a commit message ("bodies preserved untouched") must be backed by this check, not intent. Mechanics: `git diff | grep '^-[^-]'` (or the VCS equivalent), then `grep -F` each deleted line against the restructured files. - Structured-field normalisation is the highest-risk step: prose riding a structured line (a status field, a header mirror) is invisible to a "preserve bodies" intent and is exactly what normalisation deletes. Relocate such prose to a body section first, then normalise. - Separate moves from edits: a file move/rename commit is content-identical; any reconciliation edits land in an adjacent commit. Combined move+edit diffs are where losses hide. ## Hierarchy - Root AGENTS.md is the DOX rail: project-wide instructions, global preferences, durable workflow rules, and the top-level Child DOX Index - Child AGENTS.md files own domain-specific instructions and their own Child DOX Index - Each parent explains what its direct children cover and what stays owned by the parent - The closer a doc is to the work, the more specific and practical it must be ## Child Doc Shape - Create a child AGENTS.md when a folder becomes a durable boundary with its own purpose, rules, responsibilities, workflow, materials, or quality standards - Work Guidance must reflect the current standards of the project or user instructions; if there are no specific standards or instructions yet, leave it empty - Verification must reflect an existing check; if no verification framework exists yet, leave it empty and update it when one exists Default section order: - Purpose - Ownership - Local Contracts - Work Guidance - Verification - Child DOX Index ## Style - Keep docs concise, current, and operational - Document stable contracts, not diary entries - Put broad rules in parent docs and concrete details in child docs - Prefer direct bullets with explicit names - Do not duplicate rules across many files unless each scope needs a local version - Delete stale notes instead of explaining history - Trim obvious statements, repeated rules, misplaced detail, and warnings for risks that no longer exist ## Closeout 1. Re-check changed paths against the DOX chain 2. Update nearest owning docs and any affected parents or children 3. Refresh every affected Child DOX Index 4. Remove stale or contradictory text 5. If the change altered a mechanism described in `ARCHITECTURE.md`, update or prune the affected section in the same change-set and run `tclsh scriptlib/developer/architecture_lint.tcl` 6. Re-check modified `.tm` files for new procs lacking PUNKARGS `argdoc` blocks 7. Run existing verification when relevant 8. Report any docs intentionally left unchanged and why ## User Preferences When the user requests a durable behavior change, record it here or in the relevant child AGENTS.md - LF line endings are strongly preferred for all files in this repository. Converting a CRLF text file to LF when an edit touches it is correct and welcome - do not preserve CRLF for diff-minimisation. Preserve existing line endings only for files with deliberately mixed/CRLF endings (e.g. line-ending round-trip test data) or when explicitly instructed for a file. - If the active editor is on a source-derived snapshot, bootstrap copy, or generated output path such as `src/bootsupport/`, root `modules/`, root `lib/`, `modules_tcl8/`, `modules_tcl9/`, `lib_tcl8/`, or `lib_tcl9/`, confirm the intended target before editing unless the user explicitly named that path. - cmd.exe PATH truncation (this machine, and any Windows machine with a heavily populated PATH): cmd.exe truncates a long PATH, so a tool that resolves fine in PowerShell may be "not found" when invoked via `cmd.exe /c`. Use absolute executable paths inside any `cmd /c` command line, and prefer PowerShell-native invocation unless a console host is specifically required (e.g. hidden-console test harnesses). If a tool is missing only under cmd.exe, suspect truncation before absence. - Windows paths under POSIX shells (WSL, msys/git-bash): a `C:/...` path passed unconverted to a POSIX file command (`mkdir -p`, `cp`, output redirects) is a RELATIVE path - it silently creates a stray directory tree in the cwd whose first component is literally named `C:` (the NTFS-illegal `:` is stored as private-use character U+F03A, so it renders as `C` plus an odd dot/glyph in Explorer, and while the tree contains only empty directories it is invisible to git and fossil). Translate at the boundary (`wslpath` for WSL, `cygpath` for msys - msys auto-conversion does NOT cover paths inside quoted command strings or when MSYS_NO_PATHCONV/MSYS2_ARG_CONV_EXCL is set), and after WSL/msys-driven work glance at the repo root for a stray `C*` entry. (Origin: G-140 WSL smokes leaked an empty temp-dir skeleton into the repo root, found and removed 2026-07-31.) - Agent-authored text is plain ASCII by default: no em/en dashes, curly quotes, arrow or ellipsis characters, or other typographic Unicode - use ASCII equivalents (" - ", straight quotes, "->", "..."). The rule governs elements the agent generates, with extra force for outward-bound artifacts (ticket drafts, bug reports, emails, commit messages - anything likely to be pasted into an external system), which are verified before handover (e.g. grep for `[^\x00-\x7F]`). The exceptions are illustrative, not a closed list: non-ASCII subject matter (encoding/Unicode/ANSI-art test data, or documentation demonstrating such behaviour), verbatim quotes of existing material, and explicit user request are the common cases, but any good reason qualifies - state the reason when deviating. Content the agent did not author is outside the rule: existing files are never bulk-retrofitted, and while checking non-authored content (e.g. files being committed on the user's behalf) is fine, non-ASCII there is the author's prerogative - if unsure whether it is intentional, stop and ask rather than fix or block. - Tcl has no `-e`/`-c` one-liner flag (a reflex agents carry over from perl/python/node). Stock `tclsh`/`tclsh86`/`tclsh90` recognise only `-encoding name` as a leading option; any other argument starting with `-` is NOT treated as a script file - all arguments land in `$argv` and tclsh reads commands from stdin. On a console that hangs forever at an interactive prompt; with piped/redirected stdin it exits 0 having silently ignored the supposed one-liner and executed stdin instead. (The punk kits differ since G-077, achieved 2026-08-04: ` -e