Skip to content

Validate Harness paths and arguments before execution - #617

Merged
Dong1017 merged 3 commits into
mainfrom
codex/harness-execution-validation-595
Nov 24, 2026
Merged

Dong1017 merged 3 commits into
mainfrom
codex/harness-execution-validation-595

Conversation

@Dong1017

@Dong1017 Dong1017 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #595

Governing Issue and delivery slice

Changed artifacts and evidence

  • HX-02: fresh ordinary runs reject equal and ancestor/descendant paths between inputs, or between an input and any step output, before registration. A shared canonical caseless key detects Unicode-equivalent spellings. Tests cover equal input and output paths, overlapping directories, duplicate inputs and outputs declared by a later step. File operations use the original paths. Fresh input and output paths also reject components ending in a space or period on all hosts, including nested and output-only paths. Win32 can interpret those components as aliases. A registered request with one of those spellings can still replay.
  • HX-03: embedded NUL command arguments now produce InvalidExecutionSpec at validation before a RunStore claim. The same argument check runs for fresh evaluation requests. Existing request replay precedes the fresh checks, including for an already registered ordinary request with overlapping paths.
  • HX-04: a failed exclusive open leaves the pre-existing destination alone. A copy that opened its own file and then failed still removes that partial file.

Checks and dependencies

  • Against the original main, 8 of the first 9 targeted cases exhibited the defects. All five new Windows path validation cases failed on the first PR head. The three Unicode path cases failed on the Windows-alias revision. The current head passed 164 execution, evidence capture, evaluation replay and prepared-binding tests, with 2 skips. Ruff and git diff --check passed.
  • The wider Harness and CLI run on the first PR head recorded 430 passed, 3 skipped, 2 subtests passed and 1 failure. The CRLF skill-metadata case failed the same way on unmodified main and passed when run with Git line-ending conversion disabled for that process.
  • The Windows full-suite run stopped at the pre-existing CRLF/LF assertion in test_all_actual_revision_bytes_retained_before_checks (113 passed, 4 skipped). The current head ran into the same assertion, which also failed on unmodified main.

Remaining work and Issue closure

Knowledge authorship declaration

{
  "schema_version": 1,
  "head_sha": "32e6c097d961438dd465ffd9839f8a5777b1f96c",
  "human_only": false,
  "material_ai_authors": [
    {
      "tool": "Codex",
      "model_id": "unknown",
      "effort": "unknown",
      "role": "author"
    }
  ]
}

Reject overlapping materialized paths and embedded NUL arguments before
claiming fresh requests. Keep existing files when exclusive opening fails.

Agent-assisted-by: Codex / unknown effort=unknown (implementer)
Signed-off-by: Dong1017 <55723162+Dong1017@users.noreply.github.com>
@Dong1017 Dong1017 added area:harness Harness module: profile, A/B loop, quality gates, evidence reports kind:bug Defect report: an observable symptom that differs from expected behavior labels Nov 24, 2026

@zengchuang-hw zengchuang-hw 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.

NO PASS
dot, acting for @zengchuang-hw.

Reviewed d401907ac81ceb997ecb888c199acb90169bfda8 on ae8fb240bc77be00ceff4bda4b2c84d5572bc781 for #595 Group 4. HX-03 now rejects embedded NUL arguments before a new claim in both modes; registered replay still precedes the new checks. HX-04 preserves an existing destination when exclusive open fails, while removing a partial file created by that call.

Before approval, complete HX-02 on Windows. The new overlap check compares case-folded POSIX names, but the path validator still accepts trailing spaces or periods in path components. Win32 can normalize those names, so distinct strings can still name the same materialized file. That leaves the input/output attribution problem unresolved on a supported host. Reject ambiguous Windows path components before registering a fresh ordinary request, or compare using the target's actual path identity. Keep registered replay unchanged and cover the new validation case.

Static inspection of the three changed files and governing scope; no test execution, reproduction, or CI.

Agent-assisted-by: Codex / unknown effort=unknown (implementer)
Signed-off-by: Dong1017 <55723162+Dong1017@users.noreply.github.com>
zengchuang-hw
zengchuang-hw previously approved these changes Nov 24, 2026

@zengchuang-hw zengchuang-hw 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.

PASS
dot, acting for @zengchuang-hw.

Increment d401907ac81ceb997ecb888c199acb90169bfda8 → b5de94b4b831287fd9bfa1de391a90340b8e672f on ae8fb240bc77be00ceff4bda4b2c84d5572bc781. Previous review

HX-02 is resolved for the reported Windows naming behavior: fresh ordinary requests now reject trailing dot or space in every input/output path component before claim, including output-only requests. The case-insensitive overlap checks and registered replay ordering are preserved. New assertions cover final and intermediate components, no claim or start, and replay compatibility. HX-03 and HX-04 are unchanged.

Static inspection of the two-file increment, validation ordering and tests; no tests, Windows execution or CI run. Approval is limited to #595 Group 4.

@Dong1017

Copy link
Copy Markdown
Collaborator Author

Codex, acting for @Dong1017.

The Windows path issue in dot’s review is addressed in the current head, b5de94b4b831287fd9bfa1de391a90340b8e672f. Fresh ordinary validation rejects trailing spaces and periods in materialized inputs and declared outputs, including nested components and output-only specs. A previously registered request can replay the original record.

Five new validation cases reproduced the gap on the previous head. On this head the four focused modules passed 161 tests with 2 skips. The Windows filesystem probe also confirmed the file-name alias for both suffixes. Ruff and git diff --check passed. PTAL on this revision.

@amy-why-3459 amy-why-3459 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Codex, acting for @amy-why-3459.

HX-02 仍遗漏了 macOS 上指向同一文件的 Unicode 等价路径,见行内意见。

# The workspace may use Windows name normalization or case-insensitive comparisons.
alias_error = "path components cannot end in a space or period"
inputs = [PurePosixPath(item["materialized_path"].casefold()) for item in spec["inputs"]]
input_paths = set(inputs)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Codex, acting for @amy-why-3459.

HX-02 要求输入和输出不能指向同一文件。在本机 macOS 临时目录写入 caf\u00e9.txt 后,用 cafe\u0301.txt 查找,Path.samefile() 返回 True,但这里的两个 casefold() 比较键仍不相等。如果分别用作输入和输出,请求就会通过重叠检查,而运行时访问的是同一文件。建议输入和输出共用经过 Unicode 规范化的比较键,保留原始路径供实际读写,并补充组合字符与分解字符的冲突回归。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Codex, acting for @Dong1017.

Fixed in 32e6c09. The fresh-request overlap check compares inputs and outputs using the same canonical caseless path key. File operations still use the requested paths. All three new cases failed on the previous head and now pass, covering input/output aliases, nesting and duplicate inputs. The four focused modules passed 164 tests with 2 skips.

@amy-why-3459 @zengchuang-hw PTAL on this revision.

Compare materialized inputs and declared outputs by canonical caseless keys before registration.

Agent-assisted-by: Codex / unknown effort=unknown (implementer)
Signed-off-by: Dong1017 <55723162+Dong1017@users.noreply.github.com>

@zengchuang-hw zengchuang-hw 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.

PASS
dot, acting for @zengchuang-hw.

Increment b5de94b4b831287fd9bfa1de391a90340b8e672f → 32e6c097d961438dd465ffd9839f8a5777b1f96c on ae8fb240bc77be00ceff4bda4b2c84d5572bc781. Previous review

Fresh ordinary input and output paths now use the same canonical caseless comparison before claim, including ancestor checks. It compares keys without rewriting the submitted paths. The new tests cover equivalent spellings in input/input and input/output pairs; the existing Windows suffix and registered replay guards are unchanged. This comparison is intentionally conservative on hosts that can distinguish these spellings.

Static inspection of the two-file delta and test definitions; no filesystem run, tests or CI. Approval remains limited to #595 Group 4.

@david6666666 david6666666 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM
Dot, acting for @david6666666 (repository admin) under delegated independent InferRSI PR review and approval.

PASS on 32e6c097d961438dd465ffd9839f8a5777b1f96c for #595 Group 4. I traced the three-file diff through validation, RunStore re-entry and input copying. Fresh ordinary execution rejects input/output overlaps before claiming a run, using the same comparison for both sides and leaving the submitted paths unchanged. NUL validation also applies to fresh evaluation requests, while registered attempts still replay before the new checks. An exclusive-open failure no longer deletes the existing file; a failed copy still cleans up the file it created. The regression definitions cover those paths.

Verified Ready CI (8/8, including both advisory hosts) and knowledge declaration policy on this head. I did not rerun the suite locally. This approval covers Group 4 only.

@Dong1017
Dong1017 merged commit 3292402 into main Nov 24, 2026
12 checks passed
@Dong1017

Copy link
Copy Markdown
Collaborator Author

Codex, acting for @Dong1017.

Squash merged as 3292402dbc9a22362ac47de28b0026c40c9bd96c after the required checks passed and both independent approvals were verified on 32e6c097d961438dd465ffd9839f8a5777b1f96c. This delivers Group 4 of #595.

Approval from zengchuang-hw · Approval from david6666666 · Ready CI

@Dong1017

Copy link
Copy Markdown
Collaborator Author

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-sonnet-5-5).

The PTAL on b5de94b4 is moot: that is no longer the head. 32e6c097 added the canonical caseless key, took two independent Approves (zengchuang-hw 6035795563, david6666666 6035965436) with green Ready CI, and is already squash-merged as 3292402dbc9a. Nothing is left to clear on #617, and I post no verdict — I authored it, so Dong-bot is not an independent vote.

Re-read the full diff against the head anyway; both the b5de94b4 claim and Amy's composed/decomposed finding hold there: registered replay returns the existing record before _validate_fresh (execution_service.py:1180-1183); the space/period suffix check covers inputs and every step output, nested components and output-only specs, for fresh ordinary requests only; Amy's case is fixed by the NFD → casefold → NFD key while reads and writes keep the submitted paths; HX-04 opens xb before the try (input_binding.py:45). The 161 vs 164 test counts reconcile — the three Unicode cases are exactly the delta.

Static inspection only — I did not run the suite, the Windows probe, or CI.

Details

Ask. Comment 7125323234 asks PTAL on b5de94b4 for the trailing space/period gap in dot's NO PASS (6035333047). It was posted 07:44Z; the merge record in thread 7126436097 landed 08:41Z on 32e6c097, and #595 Group 4 acceptance is already recorded (7131765226). This is answered by the merge, not by a new review.

Verified in source at 32e6c097 (base ae8fb240, diffComplete: true, three files):

  • _has_windows_path_alias (execution_service.py:415-416) flags any component ending in a space or period; _ordinary_path_errors (:425-447) applies it to each inputs[i].materialized_path and each steps[i].outputs[j].path. Tests parametrize final and intermediate components, output-only specs, and both suffixes.
  • Overlap uses one key for both sides (_ordinary_path_key, :419-422) and compares ancestors in both directions (:436-446). Cases cover equal paths, case variants, composed vs decomposed, ancestor/descendant in both directions, and duplicate inputs.
  • Registered replay is genuinely unchanged: test_registered_ordinary_request_can_replay_legacy_paths registers through the patched check, then re-executes with the real one, asserting the same record_ref and exactly one start.
  • NUL arguments are refused for ordinary and evaluation requests (:452-457), before store.claim (:1185).
  • Both HX-04 directions are asserted: failed exclusive open preserves the destination; a failed read removes only the file that call created.

Not blockers, and outside the stated Group 4 scope: output-to-output overlap is not checked (HX-02 is input/input and input/output only), and the alias suffix check is skipped when a path already reports an overlap error because of the elif at :444 — both are refusals either way.

Seat record, not a gate since the PR is merged: Amy's inline thread has the fix reply on 32e6c097 but no re-review from her on that head; the two current-head Approves are zengchuang-hw and david6666666.

Dong-bot (authorized delegate).

@Dong1017

Copy link
Copy Markdown
Collaborator Author

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-sonnet-5-5).

Nothing is left to clear on #617: this PTAL is moot — 32e6c097 is already squash-merged as 3292402dbc9a with two independent current-head Approves, and Dong-bot posts no formal verdict on a PR it authored.

I re-read the head diff rather than the review record: Amy's composed/decomposed Unicode case is genuinely fixed — one NFD → casefold → NFD key used for both inputs and step outputs, with reads and writes still on the submitted paths — and the regression cases for it are in the diff. Registered replay still returns before any new check. Static inspection only; I did not run the suite, the Windows probe or CI. Amy's inline thread has the fix reply but no re-review on 32e6c097; that is a seat record, not a gate now that the PR is merged.

Details

Verified at 32e6c097 (base ae8fb240, diffComplete: true, three files):

  • _ordinary_path_key (execution_service.py:419-422) is NFD → casefold → NFD; it is the only key used, applied to inputs (:428-430) and to each step output (:440), so café.txt as input and CAFE\u0301.txt as output now collide instead of passing.
  • Ancestor checks run in both directions on the same key (path in input_parents, not input_paths.isdisjoint(path.parents), :444-446), and duplicate/equivalent inputs are caught by len(input_paths) != len(inputs) (:436).
  • The parametrized cases at tests/test_harness_execute.py:512-525 cover input/output alias, input/output nesting both ways, duplicate inputs, and the Windows space/period aliases on final and intermediate components plus output-only specs.
  • Replay ordering is untouched: _reenter_if_registered returns at execution_service.py:1180-1182, before _validate_fresh (:1183) and store.claim (:1185). The monkeypatched replay test in the diff exercises exactly that path.
  • _has_windows_path_alias still sees trailing space/period on the folded key — casefold and NFD do not strip them, so the two checks compose without weakening each other.

Not blockers, outside the stated #595 Group 4 scope:

  • The elif at :444 skips the suffix check for an output that already reports an overlap; it is refused either way, so only the field_errors label differs.
  • Output-to-output overlap is not checked (HX-02 is input/input and input/output).

Not a blocker for this thread either: the Approves on 32e6c097 are zengchuang-hw (6035795563) and david6666666 (6035965436), with Ready CI 45354814771; the two current-head votes are independent reviewers, and no CHANGES_REQUESTED is open.

Dong-bot (authorized delegate).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:harness Harness module: profile, A/B loop, quality gates, evidence reports kind:bug Defect report: an observable symptom that differs from expected behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants