Skip to content

feat(repo): process:guidance_searched counts the guidance files an agent searched, and guidance_read lists only files the workspace held - #1003

Merged
antonwolfy merged 25 commits into
intel:mainfrom
antonwolfy:fix/guidance-searched
Nov 22, 2026
Merged

antonwolfy merged 25 commits into
intel:mainfrom
antonwolfy:fix/guidance-searched

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

process:guidance_read is the row a reader of repo compare uses to answer "did the guidance reach the agent", and on main it is wrong in two directions (#626):

One Bash call in a trace main Now
grep -n -i "deprecat|warn" dpnp/AGENTS.md dpnp/tests/AGENTS.md shell_walk gives ([], False, 0): no record of either file; guidance_read [] guidance_read [], guidance_searched ["dpnp/AGENTS.md", "dpnp/tests/AGENTS.md"]
rg -n warn dpnp/tests/AGENTS.md ([], False, 0) guidance_searched ["dpnp/tests/AGENTS.md"]
git grep -n warn -- dpnp/AGENTS.md ([], False, 0) guidance_searched ["dpnp/AGENTS.md"]
cat dpnp/tests/AGENTS.md; ls dpnp/tests/third_party/; cat dpnp/tests/third_party/AGENTS.md 2>/dev/null; cat dpnp/tests/third_party/cupy/AGENTS.md 2>/dev/null, in a workspace that holds only dpnp/tests/AGENTS.md guidance_read lists all three paths: a call with several reads gives each rc 0, since its exit does not say which file failed, and process_metrics matched the path as a string guidance_read is ["dpnp/tests/AGENTS.md"]

The issue offers a second per-cell list or a note under the row. This PR adds the list, guidance_searched, because a note leaves the number unknown. guidance_read keeps its meaning (files a print command named; head -n 1 AGENTS.md lists the file, so the list does not show that the whole file reached the agent). For the second part, the issue offers keeping only paths that exist in the run's workspace or that the arm wrote. This PR keeps the guidance files the workspace held when the agent started: the arm's files and the base's own are in that set, and a file the agent created itself is not.

Closes #626

Closes #1013

The same cause was checked in the other readers of read events: skill_usage and arm_uptake filter by the installed skills and the arm's added files, which exist at the start, so a path that never existed is not counted there (first_useful counts edits and commands only; reach seeds its probe files and aliases in the workspace). Copilot's own grep tool call is still not parsed, and is tracked in #1002.

Changes

  • Commit 1 (guidance_read): held_guidance.held_guidance lists the workspace files guidance.globs match; run_cell takes it right after prepare_workspace and before the agent starts, and run_process_metrics keeps a guidance_read path only when it is in that set. The rc rules, unknown_reads, tool_calls, denied reads and path normalisation are unchanged, and process_metrics keeps its is_guidance callable. Nothing is added to meta.json.
  • Commit 2 (guidance_searched): the shell walker in cli_traces.py also follows grep, egrep, fgrep, rg and git grep (new shell_search.py, over the option tables of probes.py, which search_words now exposes instead of _operands keeping them private). shell_walked returns the reads and the searched files, and shell_walk keeps its tuple. A piped search counts only when every later stage is a head or tail with known options that passes lines (_search_stage, cuts_lines).
  • The searched files go in an optional searched list on the command event (Claude Code Bash, Codex, Copilot bash) and on the tool event of a Claude Code Grep call with a path and output_mode content. No event kind or read event is added, so tool_calls is unchanged. repo_event.v2.json (the version the writer emits) declares the field as a list of strings, and repo_event.v1.json is unchanged; docs/events-format.md documents the field.
  • A search that failed as one search of one file is dropped as a failed read is (drop_failed_searches for Codex and Copilot, _note_searched for Claude Code). A relative file after an earlier call's cd is dropped and is not added to unknown_reads, which counts reads.
  • drop_failed_searches judges a search piped into head or tail by failed_search alone: grep warn AGENTS.md | head -n 1 with exit 141 (grep killed by the closed pipe after it showed a line) keeps searched for Codex and Copilot, and the same pipeline with exit 1 still drops it.
  • process_metrics builds guidance_searched (sorted, distinct, glob-matched, held at start); process_counts counts it as a list (LIST_KEYS), which gives repo compare a process:guidance_searched row and repo report the figure next to guidance_read.
  • The sed helpers of cli_traces.py moved unchanged to shell_sed.py: the file was at 796 of the 800-line cap.
  • Docs: contract §4.1 (guidance_read states the held-at-start rule; new guidance_searched row; the pipe/grep/rg sentence and §7's "stays unseen" point to it), docs/events-format.md, docs/reviewing.md.
  • Tests: test_repo_events_search.py (walker, Claude/Codex/Copilot traces, Grep tool, schema), test_repo_run_guidance.py (fake runs: held set, arm-removed file, searched list), and cases in test_repo_process_metrics.py and test_repo_process_counts.py (the compare row and the report line). Four existing tests pinned the whole process object or the measure list, and now include the new key: test_no_events_counts_zero, test_process_counters_are_descriptive_measures, test_run_isolates_the_agent_and_grades_each_cell, test_process_metrics_reach_result_json.
  • The first stage of a piped search no longer moves the shell: _Walk.words() takes staged, and the piped-search step passes it, so a computed directory change cut out of a pipeline (eval "$(conda shell.bash hook)" 2>&1 | tail -2, cd $D | head, source $ENV | tail) loses no directory, as the whole pipeline part did not. Without it, one such command emptied guidance_read for every later relative read of the trace. Commit 5dea4ff2.
  • A value attached to a short option is no longer read as flags: probes._option_names ends a short cluster at its first value option of the program, so rg -tc warn AGENTS.md (-t with the type c) and rg '-g*.lock' warn AGENTS.md are searches of AGENTS.md, while grep -cm1 and grep -nc still read the count flag. Commit 08302210.
  • probes._value_span reads a short cluster from the left too: the first value letter ends the options, and the next word is its value only when that letter is the last one. rg -g'*.md' warn AGENTS.md and rg -g'*.C' warn AGENTS.md (clusters ending in -d and -C, rg's value options) no longer take warn as that value and lose AGENTS.md; rg -tm pat f likewise. This changes probes._operands for those command lines only, so a probe path pattern on a file such a grep or rg names is found as well (no probe test pinned the old result). Commit 181a7ca3.
  • Review round, commit a8c05745: a keyword before a piped search (if grep x f | head, while, elif, then) is dropped as the unpiped path does, ! still ends it. A trailing head or tail counts only with known options, no file, a nonzero count (-n 0, -c 0, --lines=0 pass nothing; tail -n +0 is all lines), no --help or --version, and no shell function of that name defined in the call (cuts_lines in shell_search.py). probes.search_words reads -e/-f with an attached value, alone or in a cluster (grep -ewarn AGENTS.md, rg -nefoo, grep -fpats AGENTS.md), so the file operand is no longer taken for the expression. A refused Grep tool event drops its searched list (events._deny). held_guidance moves to held_guidance.py and returns a HeldGuidance that resolves a path through links: alias/AGENTS.md with alias -> docs counts, a dangling or looping link (sub/AGENTS.md -> missing.md) is no held file, for reads and searches. shell_sed.py gains tests for the attached -e script and --, and loses a branch that returned the same empty list as the general one.
  • Second review round, commit f5748d93: HeldGuidance records the workspace's links when the agent starts and resolves an event path through them, so alias/AGENTS.md still counts after the agent removed alias or put a directory of its own there. _search_stage strips the harmless stderr redirects (2>/dev/null, 2>&1, 2>file) from each head or tail stage before cuts_lines reads its options (new _without_stderr, which _Walk.words uses too), so grep warn AGENTS.md | head -n 20 2>/dev/null searches AGENTS.md; | head > out.txt and | tail 2>/dev/null 1>&2 still do not. Contract §4.1 and the fragment say so.
  • Third review round, commit acaedab5: --help and --version stop a search only as options the parser sees, so grep -e --help AGENTS.md and rg -e --version AGENTS.md search AGENTS.md (searched_files reads them from the parsed flags; the argument scan in searching is gone). A match limit of zero (-m0, -m 0, --max-count=0, -nm0) searches nothing: search_words now also returns the value of the last -m/--max-count. The valued-option tables gain grep's --include, --exclude, --exclude-dir, --exclude-from, --group-separator and rg's --type-clear, --ignore-file, --pre, --pre-glob, --color, --colors, --engine, --max-filesize, the separators, the size limits and --hyperlink-format, so grep -e warn --exclude AGENTS.md other.txt searches other.txt only. A head/tail cut stage takes -- and - when no other file follows (head -n 20 --, tail -n 20 -), refuses an attached value on a valueless long option (--quiet=bad; tail --follow=descriptor and its prefixes stay valid) and reads only GNU's size suffixes (1k, 2KiB, 3MB; not 1qq, 2kb). HeldGuidance resolves from the path's anchor (C:\ with ntpath rules), restarts a rooted or absolute link target on the drive of the link and reads link targets with overlay_paths._link_target.
  • Fourth review round, commit 73d5e541: a relative path of a Claude Code Grep call starts at the directory the harness started in (sub/AGENTS.md with cwd="sub"; an absolute path is unchanged). A tail stage with a value the tool refuses (--follow=bad, --pid=x, --pid with no number, -s x, --sleep-interval=x, --max-unchanged-stats=-1, and a count that is no number even when a later -n 5 follows) no longer passes lines, so grep warn AGENTS.md sub/AGENTS.md | tail --follow=bad searches nothing. For grep, egrep, fgrep and git grep an unambiguous prefix of a long option is read as the option (--qui, --cou, --files-witho); an ambiguous one (--co) and any rg option are read as written. probes._match_limit loses a loop exit no input reaches, the partial line codecov names.
  • Fifth review round, commit b182121c: a Claude Code Grep result that is empty or says No matches found (an offset past the last line) keeps no searched on its event, as an error result does not. HeldGuidance.resolved returns None for a path that follows more than 40 links, and membership refuses it, so alias -> alias/../docs (each pass of the pending .. returns to docs) no longer leads alias/AGENTS.md to docs/AGENTS.md. probes.search_words writes a GNU grep long option in full (_gnu_long, the table moved from shell_search.py) before it decides the option's value span, so grep -e warn --exclude-d AGENTS.md other.txt searches other.txt only and --max=0 is a zero match limit (guidance_searched counts a grep with an abbreviated zero match limit (--max=0) #1013); an ambiguous prefix (--exclu) and rg options are read as written.
  • Sixth review round, commit 29cc666a: a Claude Code Bash call, Codex command or Copilot bash command whose result is the empty text keeps no searched (grep warn AGENTS.md | head exits 0 when nothing matched, so the exit code could not tell); a result that carries no text field keeps its searched, since only an explicitly empty text shows that nothing printed. tail --follow=name and its prefixes (n, na, nam) no longer pass lines: tail refuses to follow its input by name before it prints one (tail: cannot follow '-' by name). HeldGuidance snapshots the workspace's directories with its links, and a link whose target goes .. out of a name that was no directory at the start (alias -> missing/../docs, or out of a file) leads to no held file, as the system fails there; a target on another drive (Windows) returns None instead of raising ValueError from os.path.relpath, which lost the cell's whole process object. searched_field moved to shell_search.py: cli_traces.py was over the 800-line cap with the change.
  • Seventh review round, commits 188a5c09 and a75ee080: HeldGuidance keys its held files, links and directories by os.path.normcase, so under Windows rules DOCS/AGENTS.md is held where docs/AGENTS.md is, while POSIX stays case-sensitive and resolved() keeps the spelling it was given. A command whose searches are all in its last part and exits 1 lists none of its files (failed_search, used by drop_failed_searches and _note_searched; Claude Code's error counts as exit 1, except for a last part that pipes the search into head or tail). A relative Claude Code Grep path after a Bash call that may have moved the shell is dropped (_settle_grep). grep -V, rg -V and rg -h search nothing (grep -h stays a search). A cut stage may be a system path to head/tail or start with NAME=value words, |& is a pipe (shell_split.py no longer reads its & as backgrounding), and git --no-pager, -P and -c key=value may come before grep; git -C still does not. docs/reviewing.md says guidance_searched: [] is not "never searched". The redirect helpers moved to shell_redirects.py: cli_traces.py was at the 800-line cap.
  • Eighth round, commit 92c84964: an rg --passthru (or --passthrough) prints every line of its files, matching or not, and exits 1 when none matched, so it is no failed search: failed_search and _failed_read keep its files (shell_search.passes_through, _Walk.passthru). failed_search no longer compares the number of searched paths of the whole script with that of its last part walked alone; the walker records where the last part began (_Walk.last_start), so an earlier search is found in the same walk as the whole script's. grep x AGENTS.md; cd "$D"; grep y docs/AGENTS.md that exits 1 keeps AGENTS.md: the final relative operand was lost after the computed cd, and the old counts were both 1. A Claude Code Grep path that is absolute on Windows (C:/ws/AGENTS.md, C:\ws\AGENTS.md, a UNC path) is no relative grep for _settle_grep (events._absolute), so a Bash cd before it keeps its searched.
  • Ninth round, commit 97f2cf19: the } that closes a brace group is no longer the script's last part (_Walk.last_start), so echo hi; { grep zzz AGENTS.md docs/AGENTS.md; } that exits 1 lists none, as without the braces. _Walk.passthru is set only by an rg --passthru that names files it shows lines of, so echo hi; rg --passthru -q x other.txt; grep nomatch AGENTS.md that exits 1 lists none. A head/tail count and a match limit are tested for zero by digit, not through int(), so a value of 5000 digits no longer raises ValueError (it aborted the Claude Code conversion, and dropped the record in Codex and Copilot).
  • Tenth round, commit dd31b7cf: a Claude Code Bash call that failed and whose last part pipes a search into head or tail keeps its searched when the result has text (set -o pipefail; grep x AGENTS.md | head -n 1 can fail with grep killed by the closed pipe after head showed a line); with the empty text it still keeps none, and a known exit 1 of Codex or Copilot still drops them (failed_search(..., exit_known=False), _Walk.cut; _settle_bash now always asks _note_searched for a call that was not refused). git grep is its own program in the option tables, so git grep --max-depth 0 AGENTS.md -- other.txt searches other.txt, not AGENTS.md; git grep -h stays a search, as in git.
  • Thirteenth round, commit 226e5968: probes._gnu_long expands an abbreviated long option against git grep's own options for git grep (_GIT_GREP_LONG), not GNU grep's, so git grep --max-d 0 AGENTS.md -- other.txt reads 0 as the value of --max-depth and searches other.txt only. --hostname-bin is added to rg's valued options, so rg --hostname-bin /bin/hostname AGENTS.md other.txt searches other.txt only.
  • Fifteenth round, commit f6c1c964: a brace group whose output goes to a file or a pipe ({ rg --passthru zzz other.txt; } >/dev/null) is dropped from the reads with its searches, and now also its rg --passthru mark: _Walk.open_group records passthru and close_group restores it beside unknown. { rg --passthru zzz other.txt; } >/dev/null; echo hi; grep nomatch AGENTS.md that exits 1 lists none; the leftover mark made failed_search false and credited AGENTS.md.
  • Sixteenth round, commit c7594b1d: a match limit written with a leading plus (grep -m +0, -m+0, --max-count=+00, rg -m +0) is a zero limit and searches nothing, as -m 0 does: searched_files strips one leading + before it tests the value for zero (strtoimax and Rust's integer parse take the plus), so grep -m +0 warn AGENTS.md; echo done no longer credits AGENTS.md. docs/reviewing.md and the fragment no longer call guidance_read a list of files printed whole: head -n 1 AGENTS.md and sed -n 1p AGENTS.md list the file, so the list does not show that the whole file reached the agent, and agent.stdout does.
  • Seventeenth round, commit 909e7011: searched was declared in repo_event.v1.json, the retired version, so a string searched was rejected on v1 and accepted on the v2 lines the writer emits. It is declared in repo_event.v2.json now (a list of strings, for every kind that carries it) and repo_event.v1.json is as on main; the schema test validates v2 lines, and a second test checks the lines events_jsonl() writes (v: 2) for a Bash search and a Grep call. A search of several files lists every file it named once the command showed a line, without attributing lines to files: grep -n visible AGENTS.md docs/AGENTS.md with the output AGENTS.md:1:visible lists both. Contract §4.1, docs/events-format.md, docs/reviewing.md and the fragment say so, and a test pins the example.
  • Changelog fragment (Fixed, Added); the Fixed entry names the probe path pattern case of an earlier commit, and the later commits add no other entry, as they fix this PR's own Added change, apart from the sentences the fourth to seventeenth rounds append to the Added entry.

Risk

Testing

On a Linux review host, at f825045c (on main 5e96beb):

  • make ci-local: 35 passed, 2 failed, 14 skipped. The two failures are the gitleaks download (Install gitleaks: curl error 504 four times, then Scan commits finds no binary, exit 127), which this host cannot fetch; the Docker steps, the pinned Claude Code install, the conda-forge, fuzz and semgrep steps, the Intel matrix legs, deploy and report jobs are skipped. 25847 tests passed, 19 skipped; mutation of changed lines: the step passed.
  • Merging main into the branch conflicted in repos/cli_traces.py: main made _HEREDOC a HeredocPattern and replaced the STDOUT_AFTER_STDERR regex with the linear _stdout_after_stderr (fix(text): scan openers with no closer in linear time at ten regex sites #933), while this branch had moved the redirect regexes to repos/shell_redirects.py. The merge keeps HeredocPattern and the branch's module, and without_stderr and close_group call main's _stdout_after_stderr; the branch's regex is dropped. git diff --stat origin/main HEAD lists only this PR's files; test_repo_cli_traces.py, test_repo_events_search.py, test_unclosed_openers.py, test_repo_run_guidance.py, test_import_architecture.py and test_growth_ratchet.py pass (982 passed).
  • Earlier merge of main (before this one) conflicted in repos/events.py (the import block and the end of _claude_stream_json); both sides were kept.
  • On main's code the new tests fail on assertions: test_repo_events_search.py 83 failed (the first: assert [None] == [['dpnp/AGENTS.md']] for the issue's grep), test_repo_run_guidance.py 3 failed (['sub/AGENTS.md', 'sub/x/AGENTS.md', 'sub/x/y/AGENTS.md'] == ['sub/AGENTS.md']), test_repo_process_metrics.py 4 failed, 38 passed, test_repo_process_counts.py 2 failed, 11 passed, test_repo_run.py 2 failed, 92 passed. main has no shell_walked or held parameter, so the copy of main used for these runs gave them main's behaviour under those names.
  • grep warn AGENTS.md | head -n 1 with exit 141 and output AGENTS.md:1:warn: searched was lost (None) for Codex and Copilot, and is ["AGENTS.md"] now. With the old condition restored on a copy, the 3 new tests in test_repo_events_search.py fail (3 failed, 278 passed).
  • With the two later commits' tests on the code before each fix: the pipe tests fail (5 failed, 83 passed in test_repo_events_search.py at 6ee0bea1, the first on assert ([], True, 1) == (['AGENTS.md'], False, 0)), the short-option tests fail (3 failed, 97 passed at 5dea4ff2, the first on assert [] == ['AGENTS.md'] for rg -tc); the operands test passes in both; the cluster-value tests fail at 08302210 (5 failed, 102 passed, the first on assert () == ('AGENTS.md',) for rg -g*.md).
  • Mutants: 40 breaks of the changed code (the held-set filter, each quiet/listing/counting flag, git grep, the negation and pipe rules, the failed-search and refused-call rules, the cd rule, the Grep modes, the list counting and the row order, the staged guard, the whole-cluster flag reading, the last-letter rule of _value_span) each fail at least one new test.
  • With the review round's tests on the code at 181a7ca3: test_repo_events_search.py and test_repo_cli_traces.py fail 27 cases (the first: grep -fpatterns.txt AGENTS.md and if grep warn AGENTS.md | head -n 20; then echo yes; fi give no searched file); test_repo_run_guidance.py cannot import held_guidance.py. Behaviour now: grep warn AGENTS.md | head -n 0, | head --help, head() { :; }; grep warn AGENTS.md | head and if ! grep warn AGENTS.md | head; then ... search nothing; grep -ewarn AGENTS.md and if grep warn AGENTS.md | head -n 20; then echo yes; fi search AGENTS.md.
  • Review-round mutants: 13 breaks (the keyword strip, the ! rule, the zero-count rule, the --help/--version rule, the function check, the -n/-c count option, the -f letter of an attached cluster, the attached expression value, the refused-Grep pop, the dangling-link filter, the link resolution, the attached -e of sed, sed's --) each fail at least one test; the one that first survived (a pattern file named patterns.txt, whose e read as -e) is killed by -fpats.
  • Second round: with alias -> docs linked at the start and then replaced by a directory, alias/AGENTS.md stays in guidance_read and guidance_searched; grep warn AGENTS.md | head -n 20 2>/dev/null, rg warn AGENTS.md 2>&1 | tail -n 5 2>/dev/null and | tail -3 2>&1 search AGENTS.md, | head --quiet too; | head 2>/dev/null > out.txt, | tail -n 5 2>/dev/null 1>&2 and an unsplittable stage search nothing.
  • Second-round mutants: 4 breaks (no link snapshot, no stderr strip on the cut stages, _cut_long refusing a flag without a value, cuts_lines accepting a stage shlex cannot split) each fail at least one new test: 6 failed for the first two, and 5 failed in test_repo_events_search.py with the other two added.
  • Third round: grep -e --help AGENTS.md, rg -e --version AGENTS.md, grep -e warn --exclude AGENTS.md other.txt (other.txt only), rg warn --ignore-file AGENTS.md other.txt, | head -n 20 --, | tail -n 20 - and | head -c 2KiB search the file; grep -m0 warn AGENTS.md | head, -m 0, --max-count=0, --help -e warn AGENTS.md, grep -e warn --exclude AGENTS.md, | head --quiet=bad, | head -n 1qq, | head -c 2kb, | head -n 20 -- other.md and | tail -n 5 - other.md search nothing. A Windows alias (alias -> docs under C:\repo\workspace, an absolute C:\... target, a rooted \repo\... target, a ..\ target) leads to the held docs/AGENTS.md under ntpath rules, and a link loop leaves the path unheld.
  • Third-round mutants: 9 breaks (the --help scan over all arguments, the zero limit, --exclude and --ignore-file dropped from the tables, the attached value on a flag, the permissive suffix pattern, -- refused, - refused, the drive dropped from the anchor) each fail at least one new test: 7, 10, 2, 2, 6, 3, 2, 1 and 1 failed.
  • Fourth round: with cwd="sub" a Grep call with path="AGENTS.md" persists searched=["sub/AGENTS.md"] and one with /ws/AGENTS.md persists ["AGENTS.md"]; grep warn AGENTS.md sub/AGENTS.md | tail --follow=bad (also --pid=x, --pid, -s x) and grep --qui warn AGENTS.md / grep --cou warn AGENTS.md search nothing in the Claude Code, Codex and Copilot converters; tail --follow=d, --pid=123 -s 0.5, grep --line-n warn AGENTS.md, grep --co warn AGENTS.md and rg --cou warn AGENTS.md search the file. shell_search.py is at 100% line and branch coverage under the search tests, and the probes.py line codecov named is gone from the missing list.
  • Fourth-round mutants: 4 breaks (the Grep path not anchored at the start directory, grep's long-option prefixes not expanded, the value check of tail's valued long options dropped, and that plus the --follow mode check dropped) each fail at least one new test: 1, 10, 6 and 10 failed in test_repo_events_search.py.
  • Fifth round: a Grep call in content mode on AGENTS.md with offset 50 and the result No matches found (or empty, or blank) persists no searched and gives guidance_searched []; with alias -> alias/../docs and docs/AGENTS.md held, alias/AGENTS.md is not held and docs/AGENTS.md is; grep -e warn --exclude-d AGENTS.md other.txt, --exclude-f=AGENTS.md search other.txt only, --max 1, --aft 2 and --max=1 search AGENTS.md, --max=0 searches nothing; rg -e warn --exclude-d AGENTS.md other.txt searches both files.
  • Fifth-round mutants: 3 breaks (the empty-result rule of Grep dropped, the hop limit continuing past the 40th link instead of returning None, _gnu_long not applied in search_words) each fail at least one new test: 3, 1 and 4 of the new cases, and the older --qui and --cou cases fail with the third (the --max=0 case was added after this run).
  • Sixth round: grep warn AGENTS.md | head and grep warn AGENTS.md sub/AGENTS.md with a result of the empty text persist no searched in the Claude Code, Codex (started and completed-only) and Copilot converters, and with the text AGENTS.md:1:warn they do; a Codex item without an aggregated_output field keeps its searched. grep warn AGENTS.md sub/AGENTS.md | tail --follow=name (also =n, =nam) searches nothing, | tail --follow, --follow=d and --follow=descriptor search both. With dangling -> missing/../docs, afile -> docs/AGENTS.md/../../docs and fine -> docs/../docs, dangling/AGENTS.md and afile/AGENTS.md are not held and fine/AGENTS.md is, also after missing is made later; under ntpath rules a link to D:\external from C:\repo\workspace leaves ext/AGENTS.md unheld and raises nothing.
  • Sixth-round mutants: 10 breaks (name accepted again, in the cut-stage, Codex and Copilot tests; the Claude Code empty-result flag unset, and its use in _note_searched; the Codex finished and completed-only empty rules; the Copilot empty rule; the .. check on a link target's names; ValueError not caught) each fail the test that pins them: 3, 2, 1, 2, 2, 1, 1, 1, 1 and 1 failed.
  • Seventh round: grep warn AGENTS.md sub/AGENTS.md, echo hi; grep zzz AGENTS.md and cd sub && grep zzz AGENTS.md with an error result list nothing, and with an ok result list their files; grep a AGENTS.md; grep b sub/AGENTS.md with an error keeps both; a Codex grep warn AGENTS.md sub/AGENTS.md lists nothing on exit 1 and both files on exit 0 and 2, and a Copilot one the same on exit 1 and 2. After cd sub in a Bash call, a Grep call with path="AGENTS.md" persists no searched and one with /ws/AGENTS.md persists ["AGENTS.md"]; before the cd, or after a refused one, the relative path counts. grep -V, rg -V and rg -h search nothing, grep -h warn AGENTS.md searches the file; | /usr/bin/head, | LC_ALL=C head -n 3, |& head -n 2, git --no-pager grep, git -P grep and git -c k=v --no-pager grep search AGENTS.md, while | ./head, | /opt/bin/head and git -C sub --no-pager grep search nothing. Under ntpath rules DOCS/AGENTS.md, docs/agents.md, ALIAS/AGENTS.md and Dots/AGENTS.md are held where docs/AGENTS.md and the aliases to it are.
  • Seventh-round mutants: 20 breaks (the case folding of the held files and of the link lookup; failed_search never true, ignoring earlier searches, and true for any exit; the Claude Code empty no_match flag; the Grep drop after a cd off, counting a refused cd and dropping an absolute path; V and rg's h dropped from the no-line options and grep -h added to them; the |& strip and the shell_split.py rule; the system path and the NAME=value rule of a cut stage and a cut stage taking any path; --no-pager, -P and -c not skipped before grep) each fail the test that pins them. With these tests on the code of 29cc666a 18 fail (the first: grep warn AGENTS.md sub/AGENTS.md with an error result still lists both files).
  • Eighth round: with an exit 1 and the output # a\nline\n, rg --passthru zzz AGENTS.md sub/AGENTS.md, rg --passthru zzz AGENTS.md, rg --passthrough zzz AGENTS.md and cd sub && rg --passthru zzz AGENTS.md | head keep their files in the Claude Code, Codex and Copilot converters, while the same commands without the option and with the empty output list none. grep x AGENTS.md; cd "$D"; grep y sub/AGENTS.md and grep x AGENTS.md; cd $(dirname $F) && grep y sub/AGENTS.md with exit 1 keep ["AGENTS.md"] in the three converters; failed_search is false for both, and true for echo hi; cd "$D"; grep y /ws/AGENTS.md. After a Bash cd sub, a Grep call with C:/ws/AGENTS.md, C:\ws\AGENTS.md (workdir C:/ws) persists searched ["AGENTS.md"] and a UNC path persists itself, while a relative AGENTS.md still persists none.
  • Eighth-round mutants: 3 breaks each fail at least one new test: passes_through always false (4 failed), the old count comparison in failed_search back (2 failed of the lost-directory test, plus 4 of the passthru test, which the old code also fails) and events._absolute reading only a leading / (3 failed). Replacing the earlier-search check by a constant false fails only the older grep a AGENTS.md; grep b sub/AGENTS.md cases, as the last part alone finds nothing after the lost cd.
  • Ninth round: with exit 1 and the output hi\n, echo hi; { grep zzz AGENTS.md docs/AGENTS.md; } (also with 2>/dev/null after the brace), echo hi; rg --passthru -q x other.txt; grep nomatch AGENTS.md and the same with --count list nothing in the Claude Code, Codex and Copilot converters, and failed_search is true for each. grep x AGENTS.md | head -n N and grep -m N x AGENTS.md with N of 5000 nines or zeros, or 5000 zeros and a 1, raise nothing in the three converters: the nines and the last value list AGENTS.md, the zeros list nothing.
  • Ninth-round mutants: 3 breaks each fail at least one new test: the closing-brace rule dropped (2 failed), rg --passthru marking the walk without a file (2 failed), and the int() zero test back in cuts_lines (3 failed) or in searched_files (3 failed ValueError, with the cuts_lines fix kept).
  • Tenth round: with an error result and the text AGENTS.md:1:x, set -o pipefail; grep x AGENTS.md | head -n 1 persists ["AGENTS.md"] and cd sub && grep x AGENTS.md | tail -3 persists ["sub/AGENTS.md"]; with an error and the empty text both persist none; failed_search with a known exit 1 is still true for both. git grep --max-depth 0 AGENTS.md -- other.txt searches ["other.txt"] and gives guidance_searched []; git grep -h warn -- AGENTS.md and git grep --threads 2 -m 1 warn AGENTS.md search AGENTS.md. Run with git 2.53: git grep -h x AGENTS.md AGENTS.md printed the line, and with a missing second file it exited 128, not a help exit 129.
  • Tenth-round mutants: 2 breaks each fail at least one new test: the walk.cut guard of failed_search disabled (2 failed) and git grep converted to grep again (2 failed).
  • Thirteenth round: git grep --max-d 0 AGENTS.md -- other.txt and git grep --max-depth=0 AGENTS.md -- other.txt search ["other.txt"] and give guidance_searched []; rg --hostname-bin /bin/hostname AGENTS.md other.txt the same.
  • Thirteenth-round mutants: 2 breaks each fail the test that pins them: _gnu_long using GNU grep's options for git grep again (test_git_grep_reads_an_abbreviated_max_depth_as_git_does, 1 failed) and --hostname-bin dropped from _RG_VALUES (test_rg_hostname_bin_takes_the_next_word_as_its_value, 1 failed).
  • Fifteenth round: with exit 1 and the output hi\n, { rg --passthru zzz other.txt; } >/dev/null; echo hi; grep nomatch AGENTS.md and { rg --passthru zzz other.txt; } | cat; echo hi; grep nomatch AGENTS.md list nothing in the Claude Code, Codex and Copilot converters, and failed_search is true for each.
  • Fifteenth-round mutant: restoring no passthru in close_group fails the two new cases of test_a_no_match_search_in_a_brace_group_or_after_a_quiet_passthru_shows_no_line (2 failed, 284 passed in test_repo_events_search.py).
  • Sixteenth round: grep -m +0 warn AGENTS.md, grep -m+0 warn AGENTS.md, grep --max-count=+00 warn AGENTS.md and rg -m +0 warn AGENTS.md search nothing, and a Codex command grep -m +0 warn AGENTS.md; echo done with exit 0 and the output done persists no searched, while grep -m +1 warn AGENTS.md; echo done persists ["AGENTS.md"]. I could not run GNU grep with -m +0 here (the host's grep is ugrep); the reading rests on strtoimax and Rust's usize parse accepting a leading +.
  • Sixteenth-round mutant: reading the limit without stripping the + fails 6 cases (4 option forms of test_a_search_that_shows_no_line_of_a_file_is_not_searched, and test_codex_searches_follow_the_same_rules started and completed only; 6 failed, 284 passed in test_repo_events_search.py).
  • Seventeenth round: schema_errors("repo_event.v2", ...) rejects a command event whose searched is a string or holds an integer and accepts a list of paths, for a command and a tool event; repo_event.v1.json still accepts a string searched; the searched events of a converted Bash search and Grep call, as events_jsonl() writes them, carry v: 2 and validate. grep -n visible AGENTS.md docs/AGENTS.md with the output AGENTS.md:1:visible gives guidance_searched ["AGENTS.md", "docs/AGENTS.md"]. python -m dokimi.schema_compat --base origin/main is OK (a warning for the new searched property).
  • Seventeenth-round mutants: 3 breaks each fail at least one new test: searched dropped from repo_event.v2.json (test_the_schema_takes_a_list_of_paths_in_searched), searched added to repo_event.v1.json again (test_the_retired_version_1_schema_is_unchanged_by_searched), and _note_searched keeping only the first file (test_a_multi_file_grep_lists_every_file_it_named_when_only_one_showed_a_line); the writer stamping v: 1 fails test_the_searched_events_the_converter_writes_validate_under_the_version_it_writes.
  • Not run: Python 3.11, 3.12 and 3.14, Windows and macOS, semgrep, the Docker-based steps, and a real Claude Code, Codex or Copilot run: the traces are hand-written, and Claude Code's Grep default output_mode (files_with_matches) is not shown by any fixture in the repo.

Open questions

  • Claude Code reports only error or ok, so a search of two files that matched in one and hit a missing file in the other (exit 2) loses both files there, while Codex and Copilot keep them on exit 2. Is dropping on any error the wanted side to err on for Claude Code?
  • Grep in content mode with a path counts unless its result is an error, empty or the text No matches found; no fixture in the repo shows what Claude Code prints for no match, so that text is the assumed one, and any other wording for it would still count. For a Bash, Codex or Copilot command the empty text is the only result taken as no line shown.

Revert

A plain revert restores the old guidance_read (which lists a path the workspace never held) and drops guidance_searched. Stored result.json files keep the guidance_searched key and stored events.jsonl lines keep searched; the reverted code ignores both, and nothing else is stored.

Checklist

  • Tests added/updated and pytest passes (25847 passed, 19 skipped; make ci-local failed only on the gitleaks download)
  • ruff, mypy, and schema checks pass
  • Docs updated (or N/A) — see the docs-drift checklist in CONTRIBUTING.md
  • Self-reviewed per "Before opening a PR" in AGENTS.md
  • Each new raise/exit and test names the doc, contract or issue it traces to
  • No ad-hoc run artifacts committed
  • New files carry the SPDX license header (or are exempt in .github/.licenserc.yaml)

… when the agent started (intel#626)

A Bash call with several reads (`cat dpnp/tests/AGENTS.md; ls x; cat dpnp/tests/third_party/AGENTS.md 2>/dev/null`) gives each read `rc` 0, since a failing exit does not say which file failed (contract §4.1). `process_metrics` then matched a path that never existed against the guidance globs as a string, so `guidance_read` listed `dpnp/tests/third_party/AGENTS.md` for a workspace that never held it.

`run_cell` now takes the workspace files `guidance.globs` match right after `prepare_workspace` and before the agent starts (`workspace.held_guidance`), and `run_process_metrics` keeps a path only when it is in that set. A path that never existed, a file the arm removed and a file the agent created itself are not listed. The `rc` rules, `unknown_reads`, `tool_calls`, denied reads and path normalisation are unchanged, and `process_metrics` keeps its `is_guidance` callable.

Part of intel#626: the grep and rg half follows in the next commit.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
…hed with grep, rg or Grep (intel#626)

`guidance_read` counts files printed whole, so an agent that only ran `grep -n warn dpnp/AGENTS.md dpnp/tests/AGENTS.md` had `guidance_read` 0 although part of both files reached its context.

The walker in `cli_traces.py` now also recognises `grep`, `egrep`, `fgrep`, `rg` and `git grep` (`shell_search.py`, over the option tables of `probes.py`, which `search_words` now exposes). A file named as an operand of a search that shows lines of it goes into an optional `searched` list on the `command` event, and a Claude Code `Grep` call in `content` mode with a `path` puts its path on its `tool` event. No event is added, so `tool_calls` is unchanged. `process_metrics` builds `guidance_searched` from those lists (sorted, glob-matched, held when the agent started), `process_counts` counts it as a list, and `repo compare` and `repo report` show a `process:guidance_searched` row.

Not counted: `-q`, `-l`, `-L`, `-c`, `--count`, `--files`, a directory or glob operand, stdout sent to a file, a negated, refused or subshell command, a pipe into anything but `head` or `tail`, and a search that failed as one search of one file. The `cd` rules are `guidance_read`'s; a relative file after an earlier call's `cd` is dropped and not added to `unknown_reads`, which counts reads. The sed helpers moved to `shell_sed.py` to keep `cli_traces.py` under the file cap; `repo_event.v1` is widened in place by the optional `searched` field.

Part of intel#626: the guidance_read half is the previous commit.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
…ger moves the shell (intel#626)

The piped-search step cut the first stage out of a pipeline and ran it through the walker's words(), which treats a computed directory change (cd $D, source $ENV, eval "$(...)") as run in this shell, because the stage alone has no pipe left. So `eval "$(conda shell.bash hook)" 2>&1 | tail -2` set shell_moved and dropped every later relative guidance read of the trace.

words() now takes `staged`: the first stage of a pipeline ran in a subshell, so it never loses this shell's directory. words() has no other side effect on the walker.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
…el#626)

search_words put every letter of a short-option word into the flag set, also the letters of a value attached to an option that takes one. So `rg -tc warn AGENTS.md` read `-c` (count) and `rg '-g*.lock' warn AGENTS.md` read `-l` and `-c`, and the searched file was dropped although rg shows its lines.

A short cluster now ends at its first letter that is a value option of the program (`_SEARCH_VALUES`); the rest of the word is the value. `grep -cm1` and `grep -nc` still read the count flag, which comes before the value option. The operands of a searcher are unchanged.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
…el#626)

`probes._value_span` read a short cluster by its last letter: `-g*.md` ends in `d` (rg's `--max-depth`) and `-g*.C` in `C` (`--context`), so the next word, the pattern, was taken as that value, the file became the pattern and `rg -g'*.md' warn AGENTS.md` lost `AGENTS.md`, as did a probe path pattern on a file such a command names.

`_value_span` now reads the cluster from the left, as `_option_names` does: the first letter that takes a value ends the options; when it is the last letter the value is the next word, when letters follow it they are its value (`rg -tm pat f` is `-t` with the type `m`). A cluster with no value letter, long options and `--name=value` are unchanged.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@exai-bot

exai-bot commented Nov 19, 2026 •

Copy link
Copy Markdown

OpenCodeReview: Commit f825045 was not reviewed. This PR has reached its review limit (6 reviews).

CI at `f825045`: 7 still running, 18 passing, 2 skipped
Check Status
Fidelity golden (claude-code 2.1.318) still running
Mutation of changed lines still running
Package install smoke test (py3.11) still running
Test Linux Python 3.14 still running
Test Linux Wheels Python 3.14 still running
Tests (py3.14) still running
self / repo tasks check fix-degrade-pre still running

To review this commit: re-request review from exai-bot in the Reviewers list.

<details><summary>Last review (c7594b1): 1 medium</summary>

Open threads from the bot: 0

</details>

Comment thread dokimi/dokimi/repos/cli_traces.py Resolved
Comment thread dokimi/dokimi/repos/cli_traces.py Resolved
Comment thread dokimi/dokimi/repos/cli_traces.py Resolved
Comment thread dokimi/dokimi/repos/events.py Resolved
Comment thread dokimi/dokimi/repos/probes.py Resolved
Comment thread dokimi/dokimi/repos/shell_search.py Resolved
Comment thread dokimi/dokimi/repos/workspace.py Resolved
Comment thread dokimi/dokimi/repos/workspace.py Resolved
@codecov-commenter

codecov-commenter commented Nov 19, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.05%. Comparing base (5e96beb) to head (f825045).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1003      +/-   ##
==========================================
+ Coverage   96.03%   96.05%   +0.02%     
==========================================
  Files         456      460       +4     
  Lines       60406    60741     +335     
  Branches    10425    10489      +64     
==========================================
+ Hits        58013    58347     +334     
- Misses       1481     1482       +1     
  Partials      912      912              
Files with missing lines Coverage Δ
dokimi/dokimi/repos/cli_traces.py 98.85% <100.00%> (+1.09%) ⬆️
dokimi/dokimi/repos/events.py 97.84% <100.00%> (+0.28%) ⬆️
dokimi/dokimi/repos/held_guidance.py 100.00% <100.00%> (ø)
dokimi/dokimi/repos/probes.py 93.09% <100.00%> (+2.07%) ⬆️
dokimi/dokimi/repos/process_counts.py 100.00% <100.00%> (ø)
dokimi/dokimi/repos/process_metrics.py 100.00% <100.00%> (ø)
dokimi/dokimi/repos/runner.py 97.77% <100.00%> (+<0.01%) ⬆️
dokimi/dokimi/repos/shell_redirects.py 100.00% <100.00%> (ø)
dokimi/dokimi/repos/shell_search.py 100.00% <100.00%> (ø)
dokimi/dokimi/repos/shell_sed.py 100.00% <100.00%> (ø)
... and 1 more

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…l cuts, links and denials

Settles the review threads on intel#1003 and the codecov gap in shell_sed.py.

- A keyword before a piped search (`if grep x f | head`, `while`, `then`, `elif`) is dropped as the unpiped path does, but `!` still ends it.
- A trailing `head` or `tail` counts only when its options are known, it names no file, its count is not zero (`-n 0`, `-c 0`, `--lines=0`; `tail -n +0` is all lines), it is not `--help` or `--version`, and the call defines no function of that name (`cuts_lines` in shell_search.py).
- A short cluster holding `-e` or `-f` with its value attached (`-ewarn`, `-nefoo`, `-fpatterns.txt`) marks the expression as given, so the file operand is no longer taken for the pattern (`search_words`).
- A refused Grep tool event drops its `searched` list, so the persisted event agrees with the events format.
- The held-guidance check moves to held_guidance.py and resolves a path through links: `alias/AGENTS.md` with `alias -> docs` counts, a dangling or looping link is no held file.
- sed tests cover the attached `-e` script and `--`; the `sed -n` with no script and no `-e` branch, which gave the same empty result as the general one, is removed.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
Comment thread dokimi/dokimi/repos/held_guidance.py Resolved
Comment thread dokimi/dokimi/repos/runner.py Resolved
Comment thread dokimi/dokimi/repos/shell_search.py Resolved
…e ignores its stderr redirect

Settles the review threads on `held_guidance.py` and `shell_search.py`.

- `HeldGuidance` records the workspace's links when the agent starts and resolves an event path through them, so a read or search through `alias/AGENTS.md` still counts after the agent removed or retargeted `alias`.

- `_search_stage` strips the harmless stderr redirects (`2>/dev/null`, `2>&1`, `2>file`) from each `head` or `tail` stage before `cuts_lines` checks its options, as `_Walk.words` does for the first stage; a stdout redirect still refuses the stage. The strip is one helper, `_without_stderr`.

- Tests cover both, and the cut-stage `--quiet` option and an unsplittable stage that the coverage report named.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
Comment thread dokimi/dokimi/repos/cli_traces.py Resolved
Comment thread dokimi/dokimi/repos/held_guidance.py Resolved
Comment thread dokimi/dokimi/repos/probes.py Resolved
Comment thread dokimi/dokimi/repos/probes.py Resolved
Comment thread dokimi/dokimi/repos/shell_search.py Resolved
Comment thread dokimi/dokimi/repos/shell_search.py Resolved
Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
…syntax and a Windows alias as the tools and the platform do

A search names a guidance file only when the shell would show its lines. The command line is now read as the tools read it.

`--help` and `--version` count as options of the search only where the parser sees an option, so `grep -e --help AGENTS.md` searches for the text and keeps the file. A match limit of zero (`-m0`, `-m 0`, `--max-count=0`, in a cluster too) shows no line and leaves the file out. The valued options of grep (`--include`, `--exclude`, `--exclude-dir`, `--exclude-from`, `--group-separator`) and of rg (`--ignore-file`, `--pre`, `--color`, `--colors`, `--engine`, and the other options that take a separate value) no longer leave their value among the operands.

A `head` or `tail` stage that cuts lines accepts the end of options `--` and the explicit stdin `-` when no file follows, refuses a value on a valueless long option (`--quiet=bad`) and reads only the size suffixes GNU reads (`1k`, `2KiB`, `3MB`), so `head -n 1qq` and `head -c 2kb` no longer count as a cut.

The links of the held workspace are resolved from the drive or share anchor (`C:\`) instead of a drive-relative `C:`, a rooted or absolute link target restarts from that anchor with the drive of the link, and the link targets are normalized as `overlay_paths._link_target` does, so an alias through a directory link leads to the held file on Windows.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
Comment thread dokimi/dokimi/repos/events.py Resolved
Comment thread dokimi/dokimi/repos/shell_search.py Resolved
Comment thread dokimi/dokimi/repos/shell_search.py Resolved
…tail's values and reads grep's long-option prefixes

A Claude Code Grep call with a relative path now starts at the directory the harness started in, as a Bash call does (`sub/AGENTS.md`, not `AGENTS.md`).

A `tail` whose `--follow` mode, `--pid`, `--sleep-interval`/`-s` or `--max-unchanged-stats` value, or whose `-n`/`-c` count, the tool refuses is no stage that passes lines, so the search before it is not counted.

For `grep`, `egrep` and `fgrep` an unambiguous prefix of a long option (`--qui`, `--cou`) is read as the option it abbreviates before the output modes are checked; rg reads no abbreviation and is left alone.

`_match_limit` loses a loop exit no input reaches (the caller has already found the value letter), which is the partial line codecov names.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
Comment thread dokimi/dokimi/repos/events.py Resolved
Comment thread dokimi/dokimi/repos/held_guidance.py Resolved
Comment thread dokimi/dokimi/repos/probes.py Resolved
…link and an abbreviated option's value

A Claude Code Grep result that is empty or says "No matches found" (an offset past the last line gives it) no longer keeps `searched` on its event, as an error result already did not.

A link whose target returns to itself through a `..` component (`alias -> alias/../docs`) now makes `HeldGuidance.resolved` return None past 40 links, so the path is not held, instead of finishing the pending components and landing on `docs/`.

GNU grep long options are normalized to their full name while `search_words` reads them, so `--exclude-d AGENTS.md` takes `AGENTS.md` as the value of `--exclude-dir` and not as an operand, and `--max=0` is read as the zero match limit it is (intel#1013); rg is not normalized.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy

Copy link
Copy Markdown
Contributor Author

Review points answered at b182121; failed: Test Linux Python 3.11, Test Linux Python 3.14, Test Linux Wheels Python 3.11, Test Linux Wheels Python 3.14, Tests (py3.11), Tests (py3.14).

Declined, with the evidence in the replies:

Follow-up issues opened:

Test Linux Python 3.11 fails the same tests on main (its latest run, at 264cbde): not this PR's change.
Test Linux Python 3.14 fails the same tests on main (its latest run, at 264cbde): not this PR's change.
Test Linux Wheels Python 3.11 fails the same tests on main (its latest run, at 264cbde): not this PR's change.
Test Linux Wheels Python 3.14 fails the same tests on main (its latest run, at 264cbde): not this PR's change.
Tests (py3.11) fails the same tests on main (its latest run, at 264cbde): not this PR's change.
Tests (py3.14) fails the same tests on main (its latest run, at 264cbde): not this PR's change.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy
antonwolfy requested a review from exai-bot November 19, 2026 21:25
Comment thread dokimi/dokimi/repos/cli_traces.py Resolved
Comment thread dokimi/dokimi/repos/cli_traces.py Resolved
Comment thread dokimi/dokimi/repos/events.py Resolved
Comment thread dokimi/dokimi/repos/held_guidance.py Resolved
Comment thread dokimi/dokimi/repos/held_guidance.py Resolved
Comment thread dokimi/dokimi/repos/shell_search.py Resolved
…ame, a dangling link target and a cross-drive link

Settles review points 4635357721, 4635357740, 4635357745 and 4635357752 of intel#1003.

A Bash call, Codex command or Copilot bash command whose result is the empty text drops its searched list: `grep x AGENTS.md | head` exits 0 when nothing matched, so the exit code could not tell. A result that is absent from the trace is not taken for empty.

`tail --follow=name` (and its prefixes) is no stage that passes lines: tail refuses to follow its input by name before it prints one.

A link whose target goes `..` out of a name that was no directory at the start (`alias -> missing/../docs`) leads to no held file, decided from the directories the workspace had at the start.

A link target on another drive (Windows) leads to no held file instead of raising ValueError in os.path.relpath, which lost the cell's whole process object.

`searched_field` moves to shell_search.py so cli_traces.py stays under the 800-line cap.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
…thru as the last search, and reads a huge count

Settles the three exai-bot threads on cli_traces.py:157, cli_traces.py:363 and shell_search.py:126.

The `}` that closes a brace group no longer becomes the script's last part, so `echo hi; { grep zzz AGENTS.md docs/AGENTS.md; }` that exits 1 lists no file.

`rg --passthru` marks the walk only when it names files it shows lines of, so `rg --passthru -q x other.txt; grep nomatch AGENTS.md` that exits 1 lists none.

A head/tail count and a grep `-m` value are tested for zero by digit, not through int(), so a 5000-digit value no longer raises ValueError.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy
antonwolfy requested a review from exai-bot November 20, 2026 13:22
Comment thread dokimi/dokimi/repos/cli_traces.py Resolved
Comment thread dokimi/dokimi/repos/shell_search.py Resolved
Comment thread dokimi/dokimi/repos/shell_search.py Resolved
…nd reads git grep's own options

Settles the three open threads on the Claude pipeline exit and git grep.

Claude Code reports only that a call failed, so a failed `grep x AGENTS.md | head` under `set -o pipefail` may be grep killed by the closed pipe after head showed a line. A last part that pipes the search into head or tail is no failed search when the exit is unknown; a result with no text still drops it, and a known exit 1 (Codex, Copilot) still does.

`git grep` is now its own program in the search option tables, so `--max-depth 0` takes its value word and the pattern is no longer read as a file. `git grep -h` is --no-filename in git (it ran and printed the line here), so it stays a search.

Test-narrowed: the case `cd sub && grep zzz AGENTS.md | head` moves from the failed-search parametrization to the new pipeline test, since a Claude error on a cut pipeline no longer proves no match.
Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy
antonwolfy requested a review from exai-bot November 20, 2026 14:26
Comment thread dokimi/dokimi/repos/cli_traces.py Resolved
…hat exited 141

Settles the review point that Codex and Copilot lost `searched` for `grep x AGENTS.md | head -n 1` with exit 141: `drop_failed_searches` also asked `_failed_read`, which is true for any non-zero exit of a one-file command, and `failed_search` could not override it. A search piped into head or tail is now judged by `failed_search` alone, whose exit 1 rule still drops a search that matched nothing.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy
antonwolfy requested a review from exai-bot November 20, 2026 15:19
Comment thread dokimi/dokimi/repos/probes.py Resolved
Comment thread dokimi/dokimi/repos/probes.py Resolved
… rg --hostname-bin's value

Settles the two review threads on probes.py: `git grep --max-d 0 AGENTS.md -- other.txt` now expands `--max-d` against git grep's own long options (it was matched against GNU grep's, which has no `--max-depth`), so `0` is the value and AGENTS.md the expression; `--hostname-bin` is added to rg's valued options so `/bin/hostname` is no longer taken as the expression.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
dokimi/dokimi/repos/events.py: the import block conflicted (main added `claude_events` from `.turn_events`, this branch imports `failed_search`, `shell_walked` and `_from_cwd`); both sets are kept.

dokimi/dokimi/repos/events.py: the end of `_claude_stream_json` conflicted (main keeps the parsed trace in `trace` for `claude_events`, this branch calls `_settle_grep` first); the branch's `_settle_grep` call and main's `trace` variable are both kept.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy
antonwolfy requested a review from exai-bot November 20, 2026 17:14
Comment thread dokimi/dokimi/repos/cli_traces.py Resolved
…searches

Settles the review thread on cli_traces.py:367. `{ rg --passthru zzz other.txt; } >/dev/null; echo hi; grep nomatch AGENTS.md` that exits 1 kept the walk's `passthru` flag after `close_group` dropped the group's searches, so `failed_search` returned false for the final no-match grep and credited AGENTS.md.

`open_group` now records the flag and `close_group` restores it where it removes the group's reads, as it does for `unknown`.

The test gains the redirected and piped group cases, run through the Claude Code, Codex and Copilot converters. The changelog fragment names the case.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy
antonwolfy requested a review from exai-bot November 20, 2026 18:18
Comment thread dokimi/docs/reviewing.md Resolved
Comment thread dokimi/dokimi/repos/shell_search.py Resolved
… not read as whole-file delivery

Settles the two review threads on the PR.

A zero match limit written with a leading plus (`grep -m +0`, `rg -m +0`, `--max-count=+00`) is now a zero limit, as `-m 0` is: strtoimax and Rust's parse both accept the plus, so the search prints no line and credits no guidance file. The tests cover the option forms and a completed-converter case with a trailing `echo done`.

The reviewing guide and the changelog fragment no longer say `guidance_read` lists files printed whole: `head -n 1 AGENTS.md` and `sed -n 1p AGENTS.md` list the file, so the list does not show the whole file reached the agent, and `agent.stdout` does.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy
antonwolfy requested a review from exai-bot November 20, 2026 19:23
@antonwolfy

Copy link
Copy Markdown
Contributor Author

Review points answered at c7594b1; 11 checks still pending (Build docs (strict), CLI interface diff, CodeQL (actions), CodeQL (python), External catalog smoke test (uxlfoundation/skills), Linux Python 3.14, Linux Wheels Python 3.14, Static checks (ruff, schema, zizmor, licenses, pre-commit, bandit, secrets, changelog, schema com..., benchmark, mypy, self / repo validate); every other check passed.

codecov has not reported on this head yet.

@napetrov napetrov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change class: ARCHITECTURAL (head c7594b1)

  • Contract: changed. defaults dokimi/dokimi/repos/cli_traces.py:138; defaults dokimi/dokimi/repos/cli_traces.py:291
  • Responsibility: changed. move bare from dokimi/dokimi/repos/cli_traces.py to dokimi/dokimi/repos/shell_redirects.py; move _SedScan.init from dokimi/dokimi/repos/cli_traces.py to dokimi/dokimi/repos/shell_sed.py
  • Dependency: none
  • Review depth: design read: new dependency/responsibility, ask for rationale
  • Coverage gaps: none

2 blocking findings. I checked the shell and tool event paths, workspace filtering, the per-cell count and the version emitted by Transcript.

Focused tests on c7594b1d4: 299 passed in 3.15s. CI on head c7594b1: 0 failing Actions jobs; merge base 5d4e205 is behind base tip 36075a0.

Comment thread dokimi/docs/reviewing.md Resolved
…ile search is documented as naming its files

The `searched` field was added to the retired `repo_event.v1.json`, which tightened a frozen format and left the field unchecked on the lines the writer emits (`v: 2`). It is now declared as a list of strings in `repo_event.v2.json`, and `repo_event.v1.json` is back as it was. The schema test validates under v2, and a converted trace's lines are checked under the version the writer stamps.

A `grep` of several files lists every file it named once the command showed a line, without attributing lines to files. The contract, events format, reviewing guide and changelog fragment now say so, and a test pins the example `grep -n visible AGENTS.md docs/AGENTS.md` with output only from the first file.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy

Copy link
Copy Markdown
Contributor Author

(commented) ### Change class: ARCHITECTURAL (head c7594b1)

@napetrov (#1003 (review)): This review lists the two threads above (the v2 schema and the multi-file search); each has its own reply. The change class is as the review states it; no further change.

Conflict in dokimi/dokimi/repos/cli_traces.py: main made the heredoc pattern a HeredocPattern and replaced the STDOUT_AFTER_STDERR regex with the linear _stdout_after_stderr in shell_words, while this branch had moved the redirect regexes into shell_redirects. The merge keeps HeredocPattern for _HEREDOC, keeps the redirect helpers in shell_redirects, and makes shell_redirects.without_stderr and close_group call main's _stdout_after_stderr; the branch's STDOUT_AFTER_STDERR regex is dropped.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy

Copy link
Copy Markdown
Contributor Author

Review points answered at f825045; CI is green.

No review of this head yet from exai-bot.

@antonwolfy
antonwolfy merged commit 06341ca into intel:main Nov 22, 2026
28 checks passed
@antonwolfy
antonwolfy deleted the fix/guidance-searched branch November 22, 2026 12:44
xaleryb added a commit to xaleryb/dokimi that referenced this pull request Nov 23, 2026
…e when cue

tests/test_shell_search_rg_follow.py pins how process:guidance_searched reads rg -L, which belongs to intel#1003. It has no license header, so Static checks failed on this PR, and nothing in this PR reads it.

Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
antonwolfy added a commit that referenced this pull request Nov 23, 2026
…ues (#743)

* fix(validate): count the ja いつ cue only before a use verb

A bare いつ also matched inside 思いつく, 追いつく, 食いつく and こいつ, so a
Japanese capability-only description lost the description-no-when warn.
Accept いつ only when a use verb follows (いつ使う, いつ呼び出す, ...).

Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>

* fix(validate): do not read 耗时, 超时 or 延时 as a zh when cue

时 after 耗/超/延 (time-consuming, timeout, delay) before 调用/执行 matched the
时+verb cue, and 当事人 opened a 当…时 span. Exclude them there; the closing
时 of a 当… span keeps its class, since 当请求超时 is a when clause.

Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>

* fix(validate): count de beim only next to a use verb

A bare beim matched "Hilft beim ..." and "Unterstützt beim ...", which state
a capability, so those descriptions lost the description-no-when warn.
Accept beim only with verwenden, nutzen, benutzen, einsetzen or aufrufen
in the same sentence.

Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>

* docs(external): say which capability words are not when cues

Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>

* fix(validate): keep when cues for de beim, zh 超时 and ja いつ

Fixes the narrowed cues that turned real when-clauses into
description-no-when:
- de: no 60-character cap, imperative and separable use verbs
  (ruf auf, setz ein), either order, z. B. does not end the sentence
- zh: 超时/延时/耗时 followed by a comma or 请 and a use verb counts
  again; 当事人签字时 counts
- ja: いつ with an object before the use verb counts
- de: a full stop before an acronym ends the sentence
- zh: 当事人 with an unrelated 用时 is no cue
- ja: そいつ, あいつ and どいつ are no いつ cue
- tests: one case per verb or character in the cue lists

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>

* fix(validate): read german beim per sentence, narrow zh 当事人 guard

- German `beim` is matched per sentence after dropping abbreviation dots,
  so `z. B. GitHub` no longer ends a sentence and a quote-led sentence no
  longer joins the previous one; the lazy regex spans are gone, so a long
  description without a terminator stays linear.
- The 当事人 guard ends the 当…时 span only on a duration 时 (耗/延/用,
  超 before a noun), so `当事人使用时` and `当事人确认超时后` keep their cue
  and `查询耗时和超时次数` is still no cue.

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>

* fix(validate): tighten de, zh and ja when cues after review

Fixes: German conjugated use verbs (nutzt, verwendest, benutzt) did not
count with beim; a capitalised noun (Ruf, Nutzen) counted as a use verb;
zh 当事人 span accepted a terminal 超时 before punctuation; ja いつ accepted
noun characters such as 商用 as a use verb. Adds the beim Verwenden
capability cases.
Fixes: German conjugated use verbs (nutzt, verwendest, benutzt) did not
count with beim; a capitalised noun (Ruf, Nutzen) counted as a use verb;
zh 当事人 span accepted a terminal 超时 before punctuation; ja いつ accepted
noun characters such as 商用 as a use verb. Adds the beim Verwenden
capability cases.
A capitalised use verb after a label, bullet or opening quote stays a
verb: Einsatz: Verwende diesen Skill beim Deployen.

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>

* fix(validate): read a German use verb after beim in linear time (#454)

_de_verb_in copied the text before every rejected capitalised candidate, so a description with 200000 'Ruf' after 'beim' took seconds. The character before the match is now found by looking back over the spaces.

Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>

* fix(validate): a German abbreviation like Nr. or Abs. does not end the sentence before beim (#454)

'Verwende diesen Skill laut Nr. 3 beim Deployen.' lost its cue because the dot after Nr ended the sentence between the use verb and beim. Nr, Abs, Art, Kap, Tel, Bd, Hrsg, zzgl, exkl, Mio and Mrd join the abbreviations that keep a sentence going.

Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>

* fix(validate): a duration word before 处理 keeps the cue of a following use verb (#454)

'当事人需要超时处理,请使用本技能重试。' lost its cue because 超时 closed the 当事人 span before 处理. 超时处理 now takes a comma or 请 and a use verb like the bare duration word does. The changelog names this and the German abbreviations.

Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>

* fix(validate): read an いつ cue up to the sentence end, not 20 characters

いつ followed by a use verb more than 20 characters later was no longer
a when cue; the verb is now looked for up to the sentence end.

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>

* fix(validate): bound the いつ cue lookahead, count German scans (#454)

- ja: いつ looked for a use verb to the end of the sentence at every いつ, so
  a long text of いつ without one was quadratic; it now looks 80 characters on.
- tests: the German linear-time test counted elapsed time; it now counts the
  text read, and the いつ case is pinned by a growth test and a bound test.
- ja: いつ looked for a use verb to the end of the sentence at every いつ, so
  a long text of いつ without one was quadratic; the cue is now found per
  sentence, with the verb searched once after the first いつ.
- tests: the German linear-time test counted elapsed time; it now counts the
  text read, and the いつ case is pinned by a growth test and a distance test.
- changelog: the fragment says the いつ cue has no distance limit within its sentence.

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>

* fix(validate): a German abbreviation before a capitalised use verb ends the sentence (#454)

`Erstellt Berichte, Tabellen usw. Verwende diesen Skill beim Deployen.`
was read as one sentence, so `Verwende` counted as a noun and the
`beim` cue was dropped. An abbreviation followed by a capitalised
imperative use verb (`Verwende`, `Nutze`, `Benutze`) now keeps its
sentence end; a noun such as `Nutzdaten` or `Ruf` after `z. B.` does not.

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>

* fix(validate): read Nutzen Sie after an abbreviation, bare verb after 超时处理 (#454)

An abbreviation followed by Nutzen/Benutzen/Verwenden/Einsetzen/Rufen/Setzen Sie
now ends the sentence, so the formal instruction before beim counts as a cue.
超时处理 followed by a comma and a bare use verb is no cue; it needs 请.

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>

* test(repo): pin rg -L as a search that shows lines, grep -L as none

rg -L follows links, so rg -L warn AGENTS.md is a counted search; grep -L
lists files without a match and is not.

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>

* test(repo): drop the rg -L pin, it tests guidance_searched and not the when cue

tests/test_shell_search_rg_follow.py pins how process:guidance_searched reads rg -L, which belongs to #1003. It has no license header, so Static checks failed on this PR, and nothing in this PR reads it.

Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>

* fix(validate): 耗时, 超时 and 延时 are no cue only directly before 调用 or 执行, any other use verb keeps its cue (#454)

The generic zh cue excluded every use verb after 耗/超/延 + 时, so 超时使用本工具重试。 and 请求超时触发本技能重试。 were True on main and False here, while the PR text names only 耗时调用, 超时调用 and 延时执行. The exclusion is now those two verbs; a comma or 请 between the duration word and the verb restores them, as before. The changelog fragment and docs say the same.

Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>

* test(validate): pin the 使お form of the ja いつ cue

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>

---------

Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
Co-authored-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
Co-authored-by: Anton Volkov <antonwolfy@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

6 participants