Repository navigation
fix(repo): five readers of an event path follow a .. after a link (#1173) - #1223
Conversation
…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>
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 15 selected item(s). CI at Review details
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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
🚀 New features to boost your workflow:
|
…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
left a comment
There was a problem hiding this comment.
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.
@napetrov (#1223 (review)): Approval that recaps its checks; it asks for no change. No commit was made this round and the head stays 7b5862f. |
Summary
#1173:
guidance_readandguidance_searchedfollow a..after a link (#1174), but five other readers of areadoreditevent path have no workspace and collapse the..by name, so a path through a link matches the wrong file. Withalias -> docs/nestedandsub/alias -> /outside/nestedin the workspace, onmain:mainTranscript.reads(read_by_toolofrepo reach)alias/../AGENTS.mdAGENTS.mddocs/AGENTS.mdarm_uptake(events, ["AGENTS.md"], [], "/ws")alias/../AGENTS.mdreadsis 1docs/AGENTS.mdskill_usage(events, ["x"], None).claude/skills/x/alias/../SKILL.mdskills_usedis['x']security._outside_workspacesub/alias/../xFalse/outside/xfirst_usefulwith the globsub/xsub/alias/../xsub/x)<link target>/xThe fix is the first option of the issue: each reader takes an optional
resolve(the workspace's links,HeldGuidance.resolved, asprocess_metricsand_workspace_pathalready 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 theevents.jsonlformat and its schema, and #1174 fixed the same cause the first way. A reader called with noresolvekeeps the by-name result, so a caller with no workspace is unchanged.Closes #1173
Changes
event_format.followed_pathis the one rule for all five readers and for_workspace_path: only a path with a..is followed, the directories before the last name asresolvemakes of them and the last name as written (a guidance link keeps the name the globs match); aresolvethat returns None leaves the workspace (..). With noresolve, with no..or for an absolute path it isposixpath.normpath, as before.Transcript.reads,reach.classify,uptake.arm_uptake,arms.skill_usage,security._outside_workspaceanduseful.hits/first_usefultakeresolve.run_cellpassesheld.resolvedtoskill_usage, tofirst_usefuland, through_finish_record'sarm_usetuple and_add_arm_use, toarm_uptakeand theguidance:as-skillcheck;run_reachbuildsHeldGuidance(workspace, [])once after_prepareand passes it to everyclassifycall.repo scanbuilds the resolver from a cell's keptworkspace/(the agent's final tree), walked once and only when a path with a..asks; an edit isedit-outside-workspacewhen 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 noworkspace/directory, or one that is itself a link, is checked by name alone.docs/repo-evaluation-contract.md(first_useful,skills_used,uptake,fetched) anddocs/behavioural-security.mdsay how a..after a link is read.HeldGuidance.resolvedreads 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, soalias -> /eval/run/workspace/docs/nestedwith an edit ofalias/../xis the in-workspacedocs/x, not anedit-outside-workspacefinding; it holds for every reader that takes the resolver,guidance_readincluded.tests/test_repo_useful.py: the stub that replaceshitstakes the newresolveargument; its assertions are unchanged.Risk
A cell of
repo run,repo reachorrepo scanwhose trace has a..after a link in a read or edit path now credits the file the system opens:uptake.reads,skills_used,first_usefulandread_by_toolcan drop or gain a credit they gave before, andrepo scancan add anedit-outside-workspacefinding. A path with no.., and a cell whose workspace has no such link, gives the same result. Theresult.jsonkeys and shapes, andevents.jsonl, are unchanged.repo scanuses 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.pyimports and seeding), #1214 (security.pyrules), #1211 (arms.py_uncopyable), #1195 (runner.pybatch_lock) and #1201 (event_format.pykinds) change other functions;git merge-treeof this branch with each of their heads is clean.Testing
On a Linux review host, at
7b5862f1(onmain602de14):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 ofalias/../x): without the rebase of the target it fails (_outside_workspacereturns 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 intmp_path, andrepo runend to end with a fake agent that reads and edits throughalias/..): onmain's code, with the new keyword accepted and ignored, 20 fail and 7 pass (they pin the by-name results); the first reader assertion isarm_uptake(...)["reads"]1 where 0 is expected.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, failstests/test_repo_dotdot_links.py.Open questions
None.
Revert
A plain revert restores the by-name reading of a
..in the five readers. Nothing is stored:result.jsonandevents.jsonlkeep their shapes.Checklist
pytestpassesruff,mypy, and schema checks passAGENTS.mdraise/exit and test names the doc, contract or issue it traces to.github/.licenserc.yaml)