Skip to content

fix(repo): five readers of an event path follow a .. after a link (#1173) - #1223

Merged
antonwolfy merged 2 commits into
intel:mainfrom
antonwolfy:fix/dotdot-link-readers
Nov 25, 2026
Merged

antonwolfy merged 2 commits into
intel:mainfrom
antonwolfy:fix/dotdot-link-readers

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

#1173: guidance_read and guidance_searched follow a .. after a link (#1174), but five other readers of a read or edit event path have no workspace and collapse the .. by name, so a path through a link matches the wrong file. With alias -> docs/nested and sub/alias -> /outside/nested in the workspace, on main:

Reader Path On main The system
Transcript.reads (read_by_tool of repo reach) read alias/../AGENTS.md holds AGENTS.md opens docs/AGENTS.md
arm_uptake(events, ["AGENTS.md"], [], "/ws") read alias/../AGENTS.md reads is 1 opens docs/AGENTS.md
skill_usage(events, ["x"], None) read .claude/skills/x/alias/../SKILL.md skills_used is ['x'] opens another file
security._outside_workspace edit sub/alias/../x False writes /outside/x
first_useful with the glob sub/x edit sub/alias/../x a hit (sub/x) writes <link target>/x

The fix is the first option of the issue: each reader takes an optional resolve (the workspace's links, HeldGuidance.resolved, as process_metrics and _workspace_path already take it) and the call sites that know the workspace pass it. The second option, recording the resolved path in the event at run time, would change the events.jsonl format and its schema, and #1174 fixed the same cause the first way. A reader called with no resolve keeps the by-name result, so a caller with no workspace is unchanged.

Closes #1173

Changes

  • event_format.followed_path is the one rule for all five readers and for _workspace_path: only a path with a .. is followed, the directories before the last name as resolve makes of them and the last name as written (a guidance link keeps the name the globs match); a resolve that returns None leaves the workspace (..). With no resolve, with no .. or for an absolute path it is posixpath.normpath, as before.
  • Transcript.reads, reach.classify, uptake.arm_uptake, arms.skill_usage, security._outside_workspace and useful.hits / first_useful take resolve.
  • run_cell passes held.resolved to skill_usage, to first_useful and, through _finish_record's arm_use tuple and _add_arm_use, to arm_uptake and the guidance:as-skill check; run_reach builds HeldGuidance(workspace, []) once after _prepare and passes it to every classify call.
  • repo scan builds the resolver from a cell's kept workspace/ (the agent's final tree), walked once and only when a path with a .. asks; an edit is edit-outside-workspace when its by-name form or its followed form leaves the workspace, so a link the agent changed later does not lose a finding. A cell with no workspace/ directory, or one that is itself a link, is checked by name alone.
  • docs/repo-evaluation-contract.md (first_useful, skills_used, uptake, fetched) and docs/behavioural-security.md say how a .. after a link is read.
  • HeldGuidance.resolved reads an absolute link target equal to or under /eval/run/workspace (the workspace as the container names it) as that path under the workspace's real root, so alias -> /eval/run/workspace/docs/nested with an edit of alias/../x is the in-workspace docs/x, not an edit-outside-workspace finding; it holds for every reader that takes the resolver, guidance_read included.
  • Changelog fragment (Fixed).
  • tests/test_repo_useful.py: the stub that replaces hits takes the new resolve argument; its assertions are unchanged.

Risk

A cell of repo run, repo reach or repo scan whose trace has a .. after a link in a read or edit path now credits the file the system opens: uptake.reads, skills_used, first_useful and read_by_tool can drop or gain a credit they gave before, and repo scan can add an edit-outside-workspace finding. A path with no .., and a cell whose workspace has no such link, gives the same result. The result.json keys and shapes, and events.jsonl, are unchanged. repo scan uses the links of the final tree, which the agent may have changed; the by-name form still counts, so no finding is lost.

Open PRs on the same files: #1222 (reach.py imports and seeding), #1214 (security.py rules), #1211 (arms.py _uncopyable), #1195 (runner.py batch_lock) and #1201 (event_format.py kinds) change other functions; git merge-tree of this branch with each of their heads is clean.

Testing

On a Linux review host, at 7b5862f1 (on main 602de14):

  • make ci-local: 0 failed, 38 passed, 15 skipped (docker-only and PR-only jobs, the other Python versions, micromamba, semgrep, the fuzz job). 28412 tests passed, 23 skipped; changed-line coverage 100% of 58 lines; the mutation job killed 32 of 32 mutants of the changed lines.
  • tests/test_repo_dotdot_link_readers.py::test_a_link_to_a_container_path_of_the_workspace_is_followed_inside_it (alias -> /eval/run/workspace/docs/nested, edit of alias/../x): without the rebase of the target it fails (_outside_workspace returns True, 1 of 3 cases fails; the other two, a link to the workspace root and to /eval/run/workspace-other/docs, are outside either way and pin that the rebase does not widen); with it, all 3 pass.
  • tests/test_repo_dotdot_link_readers.py (27 tests, real links in tmp_path, and repo run end to end with a fake agent that reads and edits through alias/..): on main's code, with the new keyword accepted and ignored, 20 fail and 7 pass (they pin the by-name results); the first reader assertion is arm_uptake(...)["reads"] 1 where 0 is expected.
  • 25 mutants, one break each: 24 (a reader that ignores the links, a call site that drops them, each branch of followed_path, the by-name or the followed form of _outside_workspace, a workspace that is a link) each fail the new tests, and the 25th, in _workspace_path, fails tests/test_repo_dotdot_links.py.
  • Not run: the other Python versions (3.11, 3.12, 3.14), and a real agent or a Windows host.

Open questions

None.

Revert

A plain revert restores the by-name reading of a .. in the five readers. Nothing is stored: result.json and events.jsonl keep their shapes.

Checklist

  • Tests added/updated and pytest passes
  • 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)

…ntel#1173)

Transcript.reads (reach's read_by_tool), arm_uptake, skill_usage, security._outside_workspace and useful.hits took the `..` of a read or edit path by name, so `alias/../AGENTS.md` with `alias -> docs/nested` matched `AGENTS.md` where the system opens `docs/AGENTS.md`, and an edit of `sub/alias/../x` with `sub/alias -> /outside/nested` was neither an `edit-outside-workspace` finding nor kept out of a `first_useful` glob `sub/x`.

Each reader takes an optional `resolve` (the workspace's links, `HeldGuidance.resolved`), and a new `event_format.followed_path` applies the rule `_workspace_path` had: only a path with a `..` is followed, the directories before the last name as `resolve` makes of them and the last name as written; `_workspace_path` uses it too. `run_cell` passes `held.resolved` to skill_usage, arm_uptake and first_useful, `run_reach` the links of its probe workspace, and `repo scan` the links of a cell's kept `workspace/`, where an edit is outside when its name form or its followed form leaves the workspace. A reader called with no `resolve` keeps the by-name result.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy
antonwolfy requested a review from a team as a code owner November 25, 2026 17:45
@antonwolfy antonwolfy self-assigned this Nov 25, 2026
@exai-bot

exai-bot commented Nov 25, 2026 •

Copy link
Copy Markdown

✅ OpenCodeReview: Review complete: 0 finding(s) across 15 selected item(s).

CI at 7b5862f: 25 passing, 4 skipped.

Review details
  • Commit reviewed: 7b5862f against merge base 602de14
  • Coverage: 15 files in 2 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 372k tokens (233k from cache), 1m23s
  • Tool calls: 36 (19 file_read, 6 code_search, 3 file_read_diff, 2 local_check_results, 2 pr_comments, 2 pr_threads, 1 ci_log_search, 1 ci_status)
  • Dotdot-link security contract, shared handling, and regression coverage: 6 files
  • Repository readers and runner integration with safe link handling: 9 files

Comment thread dokimi/dokimi/repos/security.py Resolved
@codecov-commenter

codecov-commenter commented Nov 25, 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.06%. Comparing base (602de14) to head (7b5862f).
⚠️ Report is 1 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1223      +/-   ##
==========================================
- Coverage   96.07%   96.06%   -0.02%     
==========================================
  Files         496      496              
  Lines       65209    65297      +88     
  Branches    11317    11331      +14     
==========================================
+ Hits        62652    62727      +75     
- Misses       1583     1590       +7     
- Partials      974      980       +6     
Files with missing lines Coverage Δ
dokimi/dokimi/repos/arms.py 96.19% <100.00%> (ø)
dokimi/dokimi/repos/event_format.py 100.00% <100.00%> (ø)
dokimi/dokimi/repos/held_guidance.py 100.00% <100.00%> (ø)
dokimi/dokimi/repos/process_metrics.py 100.00% <100.00%> (ø)
dokimi/dokimi/repos/reach.py 98.71% <100.00%> (+<0.01%) ⬆️
dokimi/dokimi/repos/runner.py 97.88% <100.00%> (ø)
dokimi/dokimi/repos/security.py 94.18% <100.00%> (+0.15%) ⬆️
dokimi/dokimi/repos/transcript.py 97.46% <100.00%> (+0.03%) ⬆️
dokimi/dokimi/repos/uptake.py 96.82% <100.00%> (+0.05%) ⬆️
dokimi/dokimi/repos/useful.py 98.23% <100.00%> (ø)

... and 8 files with indirect coverage changes

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

…rkspace

Review point (exai-bot, security.py): an agent link `alias -> /eval/run/workspace/docs/nested` was resolved against the host's filesystem, so `alias/../x` came out as `../..` and was reported as `edit-outside-workspace`, though the container writes `docs/x`.

HeldGuidance.resolved now rebases an absolute link target equal to or under `/eval/run/workspace` onto the workspace's real root before following it, so every reader that takes its resolver (reach, uptake, skill usage, the security scan, first_useful, guidance_read) sees the link as the container does. A test covers the targets inside, at the root of, and beside the workspace.

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

@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: CONTRACT (head 7b5862f)

  • Contract: changed. defaults dokimi/dokimi/repos/event_format.py:35; defaults dokimi/dokimi/repos/security.py:347
  • Responsibility: none
  • Dependency: none
  • Review depth: check the changed surface: callers, docs, tests pin new behaviour
  • Coverage gaps: none

I traced the workspace resolver through the five consumers, including the fallback used by callers without a workspace and the mapping of container-absolute links into the saved workspace. The previous namespace finding is addressed. GitHub CI passed. Coverage was static locally.

@antonwolfy

Copy link
Copy Markdown
Contributor Author

(approved) ### Change class: CONTRACT (head 7b5862f)

@napetrov (#1223 (review)): Approval that recaps its checks; it asks for no change. No commit was made this round and the head stays 7b5862f.

@antonwolfy
antonwolfy merged commit cbc8e9c into intel:main Nov 25, 2026
29 checks passed
@antonwolfy
antonwolfy deleted the fix/dotdot-link-readers branch November 25, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

repo: readers of event paths that have no workspace take a .. after a link by name (reach, uptake, skill usage, edit-outside-workspace, first_useful)

4 participants