From 4d28bae86ff1feb8733941a0c5e6abe78277878d Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sun, 22 Nov 2026 13:08:08 +0100 Subject: [PATCH 1/2] Track ADRs and reconstruct the lost ones docs/ was gitignored, so ADRs were written but never committed and most were lost. Un-ignore docs/adr/ and rebuild the ADRs that CONTEXT.md, the tests and the code cite (0001, 0003, 0004, 0005, 0010) from the code, tests and PRs. Each rebuilt ADR says so at the top. The SysoutPipe ADR collided with the audio cooldown ADR on 0001; it is now 0002. 0006-0009 are not cited anywhere and stay unused. --- .gitignore | 1 + .../0001-audio-alert-cooldown-is-global.md | 18 +++++++++++++++++ docs/adr/0002-sysout-pipe-fire-and-forget.md | 12 +++++++++++ ...-character-substitution-is-display-only.md | 15 ++++++++++++++ ...zer-mask-type-glob-default-legacy-regex.md | 16 +++++++++++++++ ...0005-columnizer-selection-priority-enum.md | 20 +++++++++++++++++++ .../0010-stream-position-counts-raw-bytes.md | 20 +++++++++++++++++++ docs/adr/README.md | 19 ++++++++++++++++++ 8 files changed, 121 insertions(+) create mode 100644 docs/adr/0001-audio-alert-cooldown-is-global.md create mode 100644 docs/adr/0002-sysout-pipe-fire-and-forget.md create mode 100644 docs/adr/0003-control-character-substitution-is-display-only.md create mode 100644 docs/adr/0004-columnizer-mask-type-glob-default-legacy-regex.md create mode 100644 docs/adr/0005-columnizer-selection-priority-enum.md create mode 100644 docs/adr/0010-stream-position-counts-raw-bytes.md create mode 100644 docs/adr/README.md diff --git a/.gitignore b/.gitignore index f14740a2..d90508be 100644 --- a/.gitignore +++ b/.gitignore @@ -622,6 +622,7 @@ temp.txt # roots docs folder should be empty /docs/* !/docs/CODING_STANDARDS.md +!/docs/adr/ # test project logs should be ignored, this is for rolling logfile tests /src/tools/LogRotator/logs/* diff --git a/docs/adr/0001-audio-alert-cooldown-is-global.md b/docs/adr/0001-audio-alert-cooldown-is-global.md new file mode 100644 index 00000000..6f2cd296 --- /dev/null +++ b/docs/adr/0001-audio-alert-cooldown-is-global.md @@ -0,0 +1,18 @@ +--- +status: accepted +--- + +# Audio alert cooldown is global, and the active cooldown wins + +> Reconstructed on 2026-11-22 from the code (`LogExpert.Audio.AudioPlayer`), its tests and PR #581. The original ADR was lost. The decision numbers are kept because `AudioPlayerTests` cites "decision 2". + +Audio Alerts fire from tail-only highlight matches, so a burst of matching lines can trigger many alerts in a short time. We throttle them in one place, the static `AudioPlayer`: + +1. **One process-wide player and cooldown.** `AudioPlayer` is static and owns a single last-played timestamp. The cooldown applies to every Audio Alert in the application, not per Highlight Entry or per Log Window, so bursts from several entries or windows cannot overlap or rapid-fire. +2. **The active cooldown wins.** The cooldown of the most recently *played* alert gates every later attempt until it expires, whatever cooldown the new attempt passes in. A short-cooldown entry cannot cut a long-cooldown alert's quiet period short. A cooldown of `0` disables throttling for the next attempt only. +3. **Playback is fire-and-forget with a beep fallback.** Callers never block. An empty path, a missing file or a file NAudio cannot play falls back to the system beep and is logged at warn level, so the user still gets feedback. + +## Consequences + +- A suppressed alert is dropped, not queued. +- Tests must reset the shared state (`ResetCooldownStateForTesting`), because it is static. diff --git a/docs/adr/0002-sysout-pipe-fire-and-forget.md b/docs/adr/0002-sysout-pipe-fire-and-forget.md new file mode 100644 index 00000000..3c71143d --- /dev/null +++ b/docs/adr/0002-sysout-pipe-fire-and-forget.md @@ -0,0 +1,12 @@ +# SysoutPipe is fire-and-forget; temp file is not cleaned up + +When `ToolLaunchService` starts an External Tool with Sysout Capture, it creates a `SysoutPipe` and does not return it to the caller. The pipe's background reader thread closes the writer when the process stdout stream ends. The temp file created by `SysoutPipe` is never deleted. + +We chose not to return `IDisposable` from `ToolLaunchService.Launch` because there is no natural owner: the pipe outlives the launch call, the Log Window that displays it does not know about the pipe, and the process exit event is already wired internally. Returning the pipe would hand the caller an `IDisposable` with no clear disposal point. + +The temp-file leak is a known consequence. A future fix requires a lifetime-tracking mechanism (e.g. pipe registry keyed to the Log Window, cleaned up on tab close) — that scope belongs in a separate change. + +## Considered Options + +- **Return `SysoutPipe` in `ToolLaunchResult`** — rejected: no caller can determine when to dispose it without tracking the associated Log Window lifetime. +- **Delete temp file on process exit** — rejected: the Log Window may still be reading the file when the process exits. diff --git a/docs/adr/0003-control-character-substitution-is-display-only.md b/docs/adr/0003-control-character-substitution-is-display-only.md new file mode 100644 index 00000000..5c5c9567 --- /dev/null +++ b/docs/adr/0003-control-character-substitution-is-display-only.md @@ -0,0 +1,15 @@ +--- +status: accepted +--- + +# Control Character Substitution is display-only + +> Reconstructed on 2026-11-22 from the code (`LogExpert.UI.ControlCharDisplay`, `LogWindow.PaintCell`) and PR #582. The original ADR was lost. + +Logs can contain C0 control characters and DEL, which Windows draws as nothing or as a box. We show them as visible glyphs (Caret, C escape, Abbreviation, Unicode Control Pictures or ISO 2047), but only while a cell is painted. `ControlCharRenderer` splits the cell's text into raw and substituted segments inside `LogWindow.PaintCell`. Raw column data is never changed, so search, filter, highlight regexes and columnizer parsing all keep working on the real characters, and a regex for `\x07` still matches a BEL shown as `␇`. + +Substitution is off by default. By default it covers every C0 character plus DEL except TAB, LF and CR, which already have a visible effect. + +## Consequences + +- Copying copies the raw text by default. Copying what is shown is a separate opt-in (`ControlCharSettings.CopyDisplayedForm`, applied by `SubstitutedClipboardBuilder`), and only when substitution is on. diff --git a/docs/adr/0004-columnizer-mask-type-glob-default-legacy-regex.md b/docs/adr/0004-columnizer-mask-type-glob-default-legacy-regex.md new file mode 100644 index 00000000..036e6b79 --- /dev/null +++ b/docs/adr/0004-columnizer-mask-type-glob-default-legacy-regex.md @@ -0,0 +1,16 @@ +--- +status: accepted +--- + +# Columnizer masks: Glob for new entries, Regex for existing ones + +> Reconstructed on 2026-11-22 from the code (`MaskType`, `ColumnizerMaskEntry`, `LegacyPreferencesMigrator`). The original ADR was lost. + +Columnizer Mask Entries used to be .NET regular expressions only, which is surprising for users who type `*.log`. We added a per-entry **Mask Type** (`Glob` or `Regex`). New entries default to `Glob`, which matches the short file name with `*` and `?`. + +Settings saved before the field existed have no type. If they loaded with the new default, they would silently become globs and stop matching. `LegacyPreferencesMigrator` (settings version 0 → 1) therefore rewrites every existing entry to `Regex`, so old settings behave exactly as before. + +## Consequences + +- The migration depends on `SettingsVersion`. The migrator must run before the settings are used, and the version must be bumped for any later migration. +- `MaskType` is serialized by name. The converter still reads legacy integer values. diff --git a/docs/adr/0005-columnizer-selection-priority-enum.md b/docs/adr/0005-columnizer-selection-priority-enum.md new file mode 100644 index 00000000..a4687020 --- /dev/null +++ b/docs/adr/0005-columnizer-selection-priority-enum.md @@ -0,0 +1,20 @@ +--- +status: accepted +--- + +# Columnizer Selection Priority replaces the MaskPrio bool + +> Reconstructed on 2026-11-22 from the code (`ColumnizerSelectionPriority`, `ColumnizerResolver`, `LegacyPreferencesMigrator`). The original ADR was lost. + +Four sources can choose the columnizer a file opens with: its Session File, the Columnizer History, a Columnizer Mask Entry, and AutoPick. The old `Preferences.MaskPrio` bool could only swap History and Mask. Users who wanted a matching mask to win over a file's saved columnizer had no way to say so. We replaced the bool with a three-value enum, resolved in one place (`ColumnizerResolver`): + +- `HistoryThenMask` (default, the old behavior): Session File → History → Mask → AutoPick. +- `MaskThenHistory` (the old `MaskPrio = true`): Session File → Mask → History → AutoPick. +- `MaskOverridesPersistence`: Mask → Session File → History → AutoPick. Only the Session File's columnizer is overridden; its bookmarks, filters and other state still restore. + +AutoPick only runs when none of these produces a columnizer. + +## Consequences + +- `MaskPrio` is kept, marked obsolete, so old settings still load. `LegacyPreferencesMigrator` maps `MaskPrio = true` to `MaskThenHistory`, but only while the enum is still at its default, so a choice the user already made is never overwritten. +- The member name `MaskOverridesPersistence` keeps the old "persistence" wording because the enum is serialized by name. The user-facing term is **Session File**. diff --git a/docs/adr/0010-stream-position-counts-raw-bytes.md b/docs/adr/0010-stream-position-counts-raw-bytes.md new file mode 100644 index 00000000..e72196c0 --- /dev/null +++ b/docs/adr/0010-stream-position-counts-raw-bytes.md @@ -0,0 +1,20 @@ +--- +status: accepted +--- + +# The stream reader's position counts the raw bytes consumed + +> Reconstructed on 2026-11-22 from PR #756 (issue #639) and the code it introduced in `PositionAwareStreamReaderDirect`. The original ADR was lost. + +`LogfileReader` takes a file's size from the reader's byte `Position`, and tail mode treats a file whose size on disk is smaller than that as recreated: it reloads and the view jumps to the top. The readers used to advance `Position` by re-encoding the decoded text. Every invalid byte decodes to U+FFFD, which re-encodes as 3 UTF-8 bytes, so a log containing a binary block reloaded on every append. + +We decided that **`Position` always equals the raw bytes consumed, whatever they are**: valid, invalid, truncated sequences or any line ending. The Direct reader finds line terminators in the raw bytes, as code units of the encoding (`\r`/`\n` are one byte, or two/four for UTF-16/UTF-32, and never occur inside a multi-byte character), decodes each line on its own, and advances `Position` by the bytes the line and its terminator really occupy. How invalid bytes are displayed (U+FFFD) did not change. + +## Considered Options + +- **Keep the `System` and `Legacy` readers alongside Direct:** rejected, and both were removed. They read through `StreamReader`, which never reports the bytes it consumed, so neither could be made exact without becoming a copy of Direct. + +## Consequences + +- Every read path must keep this invariant. `ReadChar()`, which XML mode uses, still counts re-encoded characters (#757). +- Settings saved with the removed `ReaderType` still load: the unknown member is ignored. diff --git a/docs/adr/README.md b/docs/adr/README.md new file mode 100644 index 00000000..84a80c91 --- /dev/null +++ b/docs/adr/README.md @@ -0,0 +1,19 @@ +# Architecture Decision Records + +Format and numbering: `.claude/skills/grill-with-docs/ADR-FORMAT.md`. Take the next free number after the highest one here. + +| ADR | Decision | +|---|---| +| [0001](0001-audio-alert-cooldown-is-global.md) | Audio alert cooldown is global, and the active cooldown wins | +| [0002](0002-sysout-pipe-fire-and-forget.md) | SysoutPipe is fire-and-forget; temp file is not cleaned up | +| [0003](0003-control-character-substitution-is-display-only.md) | Control Character Substitution is display-only | +| [0004](0004-columnizer-mask-type-glob-default-legacy-regex.md) | Columnizer masks: Glob for new entries, Regex for existing ones | +| [0005](0005-columnizer-selection-priority-enum.md) | Columnizer Selection Priority replaces the MaskPrio bool | +| [0010](0010-stream-position-counts-raw-bytes.md) | The stream reader's position counts the raw bytes consumed | + +## History + +Until 2026-11-22, `docs/` was gitignored, so ADRs were written but never committed, and most were lost. 0001, 0003, 0004, 0005 and 0010 were reconstructed from the code, tests and PRs that cite them. Each says so at the top. + +- The SysoutPipe ADR was originally numbered 0001, which collided with the audio cooldown ADR that `CONTEXT.md` and the tests cite as 0001. It is now 0002. +- 0006–0009 are not cited anywhere, and their content is unknown. The numbers are left unused rather than reassigned, so an old reference can't point to the wrong decision. From bbd280b49512e0fb6ee7fae42e830371b571905e Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sun, 22 Nov 2026 13:19:28 +0100 Subject: [PATCH 2/2] Track docs/agents and drop an untracked citation from CONTEXT.md CLAUDE.md points agents to docs/agents/ for the read-only issue tracker policy, the triage label mapping and the domain-doc layout, but docs/ was gitignored, so a fresh clone had none of them. Un-ignore docs/agents/. CONTEXT.md cited docs/improve/logwindow-architecture-review.html, which is local-only; drop the citation. --- .gitignore | 1 + CONTEXT.md | 4 +--- docs/agents/domain.md | 34 ++++++++++++++++++++++++++++++++++ docs/agents/issue-tracker.md | 35 +++++++++++++++++++++++++++++++++++ docs/agents/triage-labels.md | 19 +++++++++++++++++++ 5 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 docs/agents/domain.md create mode 100644 docs/agents/issue-tracker.md create mode 100644 docs/agents/triage-labels.md diff --git a/.gitignore b/.gitignore index d90508be..6f5d592f 100644 --- a/.gitignore +++ b/.gitignore @@ -623,6 +623,7 @@ temp.txt /docs/* !/docs/CODING_STANDARDS.md !/docs/adr/ +!/docs/agents/ # test project logs should be ignored, this is for rolling logfile tests /src/tools/LogRotator/logs/* diff --git a/CONTEXT.md b/CONTEXT.md index 481992c7..39d20d12 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -287,9 +287,7 @@ worker thread**). *Avoid*: "GetTimestampForLine" / "GetTimestampForLineForward" / "FindTimestampLineInternal" as concept names — those were the pre-extraction -Log Window method names (candidate 6 of -`docs/improve/logwindow-architecture-review.html`); the Core module is the -**Timestamp Locator**. +Log Window method names; the Core module is the **Timestamp Locator**. ## Log Window roles diff --git a/docs/agents/domain.md b/docs/agents/domain.md new file mode 100644 index 00000000..f6aff08d --- /dev/null +++ b/docs/agents/domain.md @@ -0,0 +1,34 @@ +# Domain Docs + +How the engineering skills should consume this repo's domain documentation when exploring the codebase. + +## Before exploring, read these + +- **`CONTEXT.md`** at the repo root — the glossary of domain terms (Highlight Entry, Highlight Group, Trigger, …). +- **`docs/adr/`** — read ADRs that touch the area you're about to work in. + +This is a **single-context** repo: one `CONTEXT.md` and one `docs/adr/` at the root, covering the whole codebase. + +If any of these files don't exist, **proceed silently**. Don't flag their absence; don't suggest creating them upfront. The `/domain-modeling` skill (reached via `/grill-with-docs` and `/improve-codebase-architecture`) creates them lazily when terms or decisions actually get resolved. + +## File structure + +``` +/ +├── CONTEXT.md +├── docs/adr/ +│ └── 0002-sysout-pipe-fire-and-forget.md +└── src/ +``` + +## Use the glossary's vocabulary + +When your output names a domain concept (in an issue title, a refactor proposal, a hypothesis, a test name), use the term as defined in `CONTEXT.md`. Don't drift to synonyms the glossary explicitly avoids. + +If the concept you need isn't in the glossary yet, that's a signal — either you're inventing language the project doesn't use (reconsider) or there's a real gap (note it for `/domain-modeling`). + +## Flag ADR conflicts + +If your output contradicts an existing ADR, surface it explicitly rather than silently overriding: + +> _Contradicts ADR-0002 (sysout pipe fire-and-forget) — but worth reopening because…_ diff --git a/docs/agents/issue-tracker.md b/docs/agents/issue-tracker.md new file mode 100644 index 00000000..b5ac2aa6 --- /dev/null +++ b/docs/agents/issue-tracker.md @@ -0,0 +1,35 @@ +# Issue tracker: GitHub (read-only for skills) + +Issues and PRDs for this repo live as GitHub issues on `LogExperts/LogExpert`. + +**Write policy: read-only.** Skills read issues for analysis; **only humans post**. Never create, comment on, label, edit, or close an issue or PR — instead, produce the content as a draft and hand it to the user to post. + +## Conventions (reading) + +Use the `gh` CLI when available. Check that `gh` is actually installed before building a plan around it (see the Environment section of the root `CLAUDE.md`); for public reads, the REST API works unauthenticated as a fallback (`https://api.github.com/repos/LogExperts/LogExpert/issues/...` via `Invoke-RestMethod`). + +- **Read an issue**: `gh issue view --comments`, filtering comments by `jq` and also fetching labels. +- **List issues**: `gh issue list --state open --json number,title,body,labels,comments --jq '[.[] | {number, title, body, labels: [.labels[].name], comments: [.comments[].body]}]'` with appropriate `--label` and `--state` filters. +- **Read a PR**: `gh pr view --comments` and `gh pr diff ` for the diff. + +GitHub shares one number space across issues and PRs, so a bare `#42` may be either — resolve with `gh pr view 42` and fall back to `gh issue view 42`. + +## Pull requests as a triage surface + +**PRs as a request surface: no.** Triage looks only at issues; PRs are handled by humans as usual. + +## When a skill says "publish to the issue tracker" + +Do **not** run `gh issue create`. Write the issue as a markdown draft — title, body, and suggested labels — either inline in the conversation or as a file under `.scratch/`, and ask the user to post it. + +## When a skill says "fetch the relevant ticket" + +Run `gh issue view --comments` (reading is allowed). + +## When a skill says "apply a label" / "comment" / "close" + +State which label/comment/close action the skill calls for and let the user do it. Skills never mutate the tracker. + +## Wayfinding operations + +`/wayfinder` normally creates and claims issues, which the read-only policy forbids. When wayfinding this repo, keep the map and tickets as local markdown under `.scratch/wayfinder/` instead of GitHub issues. diff --git a/docs/agents/triage-labels.md b/docs/agents/triage-labels.md new file mode 100644 index 00000000..444c5a2f --- /dev/null +++ b/docs/agents/triage-labels.md @@ -0,0 +1,19 @@ +# Triage Labels + +The skills speak in terms of five canonical triage roles. This file maps those roles to the actual label strings used in this repo's GitHub issue tracker. + +**Read-only:** skills use these labels to read and filter issues; they never apply or remove labels themselves (see `docs/agents/issue-tracker.md`). When a skill would apply a label, it names the label and the user applies it. + +| Label in mattpocock/skills | Label in our tracker | Meaning | +| -------------------------- | -------------------- | ---------------------------------------- | +| `needs-triage` | `needs-triage` | Maintainer needs to evaluate this issue | +| `needs-info` | `question` | Waiting on reporter for more information | +| `ready-for-agent` | `ready-for-agent` | Fully specified, ready for an AFK agent | +| `ready-for-human` | `ready-for-human` | Requires human implementation | +| `wontfix` | `wontfix` | Will not be actioned | + +`question` and `wontfix` already exist in the repo; `needs-triage`, `ready-for-agent`, and `ready-for-human` need to be created by a human before first use. + +When a skill mentions a role (e.g. "apply the AFK-ready triage label"), use the corresponding label string from this table. + +Edit the right-hand column to match whatever vocabulary you actually use.