Skip to content

fix(jev): support secure scoped capture on native Windows - #8620

Merged
huangruiteng merged 9 commits into
loopx-project:mainfrom
xiaobaifly7:fix/jev-windows-safe-capture
Nov 17, 2026
Merged

huangruiteng merged 9 commits into
loopx-project:mainfrom
xiaobaifly7:fix/jev-windows-safe-capture

Conversation

@xiaobaifly7

@xiaobaifly7 xiaobaifly7 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Goal And Delivered Outcome

The optional Jev drift observer originally rejected native Windows because os.O_NOFOLLOW is unavailable. This PR adds native, identity-checked no-follow capture within the existing provider. It also applies the existing scope exclusions to canonical handle paths, including the deepest existing ancestor of a future file.

The latest change request identified a lifecycle defect: a missing file selected through an excluded Git directory alias initialized successfully; once it appeared, a real owner refresh succeeded but Jev discarded its baseline and emitted no event. Native Windows reproduction now rejects that selection during initialization, without creating observer state. An ordinary future file selected through a real directory alias still produces an event and local receipt after creation.

PR base: main. Fetched origin/main at e72fc2433dcb7577971d2cea521826a4b8999987. Merge simulation passed, so no rebase or history rewrite was necessary. The latest local commit is 8e0d846193bb944ffe51c0c672a0e01222f9b2c4, directly following reviewed head be915c2b2466a7a52c4b3ab91c0c04d3b3aad477. This handoff is local; a human reviews and pushes.

Author Declaration

Written by: model_agent — OpenAI Codex, GPT-6 family.

Implemented against the scoped-capture contract in packages/loopx-jev/DRIFT_SHADOW.md, both change requests on PR #8620, and the existing capture / stable_capture callers in drift.initialize and drift.prepare.

Approach And Scope

  • Preserve the existing Windows directory pinning, reparse rejection, final-component no-follow open, bounded reads and before/after file identity checks. Directory identity remains device/inode only; file identity does not depend on ctime.
  • Obtain each opened, identity-checked ancestor's canonical path with GetFinalPathNameByHandleW. Apply the existing workspace containment and validate_paths checks to that canonical ancestor plus the complete remaining suffix before either missing-path return. The deepest existing ancestor is therefore checked even when an intermediate directory is absent.
  • Fail closed if the workspace itself disappears, identity is unavailable or changes, native directory sharing prevents traversal, or canonical-path acquisition fails. Retain the canonical opened-file check before reading.
  • Reject ambiguous Windows scope spellings containing trailing dots/spaces, drive-relative components or alternate-stream syntax. Native sibling tests demonstrated that some previously became accepted absence; unresolved components cannot be normalized through a handle.
  • Keep the fix in the current capture owner. No runtime dependency, configuration option, public API, receipt schema, provider dispatch or shared control-plane behavior was added. POSIX capture and default-off routing retain their existing implementation. Both language guides describe the boundary.

Bounded refactoring: reused the existing scope validator and handle helpers; the native short-name test setup is shared by its active test callers. Further production abstraction is unnecessary for this bounded repair. UI impact: none; the existing optional CLI is the affected entrypoint.

Sibling Cases Deliberately Covered

Boundary Proof
Existing file, missing leaf, missing intermediate directories Native long-name, mixed-case, extended/device-prefix and real 8.3 representations, for root and nested .git; no-read guard for existing files
Initialization of an excluded future file test_windows_missing_git_alias_cannot_initialize: real short alias, valid pinned-model configuration, CLI exit 2, no observer directory
Ordinary future files and ordinary aliases Native PLAIN~1 / mixed-case alias absent-to-created capture and delta; real CLI refresh enqueues an event for missing leaf and missing intermediate directories
Unusable ancestors Real disappearing workspace, real junctions with existing/missing descendants, regular-file intermediate component, directory leaf, unavailable identity and native no-share directory handle
Ancestor races / containment Existing workspace-junction replacement test now includes a missing descendant; outside canonical-path result is injected at the OS helper boundary
Canonical-name failures Win32 failure/insufficient-buffer results for root, parent and opened-file queries; exact capture_path_unavailable error and selected query count asserted before any read
Positive guards Stable Windows ctime-skew read, ordinary regular-file/CRLF capture, regular hard links, original successful event and real refresh/default-off cases
Other Windows representations Trailing dot, trailing space, directory-stream syntax, drive-relative names and ambiguous missing suffixes fail closed

Validation

Native Windows, CPython 3.12.13, local NTFS with 8.3 alias creation available. The existing disposable environment imports this exact checkout; executable and module provenance were verified. Temporary workspaces, state, caches and File authority stayed within this worktree. No installed LoopX runtime, uv tools, real Harness, Magpie or other worktree was modified.

Check Result
Test-first native regression matrix Before production changes: 24 failed / 72 passed across 96 cases. After: all the same cases pass. Two additional opened-file API-failure guards bring the final suite to 98 passed, no skips. Native aliases and sharing conflicts use actual Win32/NTFS behavior.
Full package before fix 134 passed / 12 failed, using an earlier test matrix. Five existing package failures also occur after the fix; the other seven were early versions of the new regression cases.
Package plus shared consumers 212 passed / 6 failed / 4 setup errors. This run included the 96-case capture matrix; the final 98-case capture suite subsequently passed with stricter query/error assertions. All earlier positive cases remain passing.
Actual CLI / File authority, before For both GIT~1/newfile and GIT~1/absent/newfile: baseline_created, then file creation and real refresh-state with appended=true, followed by capture_failed, baseline null, zero events. Ordinary short-name controls queue normally.
Actual CLI / File authority, after Both excluded selections return unavailable/exit 2 without observer state. Both ordinary controls initialize, create the future path, complete real refresh, queue one event, report zero capture failures and write one receipt. Egress is disabled: not_evaluated / egress_denied, dispatch not_sent, zero provider attempts. Disposable runtimes were stopped.
Ruff and formatting ruff check and ruff format --check pass for both changed Python files.
Typecheck Win32 strict mypy retains the same existing os.O_NOFOLLOW attribute error: one before and one after. A Linux-stub target also reports the same nine pre-existing Win32 API/attribute errors before and after. No typecheck pass is claimed; this optional package is outside the root mypy allowlist.
Repository checks git diff --check, staged diff check and the bilingual RFC staged gate pass. New commit has the requested DCO sign-off and preserves the existing parent.

Commands were run from the worktree in non-login PowerShell with . .local/isolate.ps1; no user PowerShell profile was loaded:

. .local/isolate.ps1
.\.venv\Scripts\python.exe -u -m pytest packages/loopx-jev/tests/test_drift_capture.py -q -p no:cacheprovider --basetemp=.local/pytest-8620-regression-before
.\.venv\Scripts\python.exe -u -m pytest packages/loopx-jev/tests/test_drift_capture.py -q -p no:cacheprovider --basetemp=.local/pytest-8620-capture-proved
.\.venv\Scripts\python.exe -m pytest packages/loopx-jev/tests -q -p no:cacheprovider --basetemp=.local/pytest-8620-before
.\.venv\Scripts\python.exe -u -m pytest packages/loopx-jev/tests tests/capabilities/test_progress_review.py tests/test_progress_review_criterion_binding.py -q -p no:cacheprovider --basetemp=.local/pytest-8620-final
.\.venv\Scripts\python.exe -u .local/missing_alias_e2e.py before
.\.venv\Scripts\python.exe -u .local/missing_alias_e2e.py after
.\.venv\Scripts\python.exe -m ruff check packages/loopx-jev/src/loopx_jev/drift_capture.py packages/loopx-jev/tests/test_drift_capture.py
.\.venv\Scripts\python.exe -m ruff format --check packages/loopx-jev/src/loopx_jev/drift_capture.py packages/loopx-jev/tests/test_drift_capture.py
$env:PYTHONPATH = "$PWD\.local\typecheck-deps;$env:PYTHONPATH"
.\.venv\Scripts\python.exe -m mypy --strict --follow-imports=skip --platform win32 --cache-dir=.local/mypy-8620-before packages/loopx-jev/src/loopx_jev/drift_capture.py
.\.venv\Scripts\python.exe -m mypy --strict --follow-imports=skip --platform win32 --cache-dir=.local/mypy-8620-after packages/loopx-jev/src/loopx_jev/drift_capture.py
.\.venv\Scripts\python.exe -m mypy --strict --follow-imports=skip --platform linux --cache-dir=.local/mypy-8620-linux-base .local/typecheck-8620-base/loopx_jev/drift_capture.py
.\.venv\Scripts\python.exe -m mypy --strict --follow-imports=skip --platform linux --cache-dir=.local/mypy-8620-linux packages/loopx-jev/src/loopx_jev/drift_capture.py
.\.venv\Scripts\python.exe scripts/check_rfc_bilingual.py --base origin/main --staged
git diff --check
git diff --cached --check

The two before pytest commands describe separate test-first runs; test cases were expanded between them. The baseline Linux-stub typecheck uses an exact copy of the reviewed source exported from Git within a disposable directory. The CLI script's before/after arguments assert the expected behavior of the corresponding revision; they do not switch production code.

Remaining package failures: Unix executable-bit and mode-0600 expectations, LF/CRLF evidence comparison, generated snapshot CRLF/LF mismatch, and the existing recorded sentinel replay mismatch (cause not investigated here). Shared consumers retain one mode-0600 assertion failure and four SQLite fixture setup errors (unable to open database file); their failure signatures match the earlier local baseline. File-provider criterion-binding consumers pass.

Risks And Unverified

Windows paths with the ambiguous spellings listed above now return unavailable rather than being accepted as absent. During capture, directory handles deny write/delete sharing and can conflict with concurrent directory mutation; capture never falls back to weaker checks. Missing components may later be created or replaced, so every capture repeats the checks; this is not an atomic filesystem snapshot.

Native Windows alias creation, case/prefix handling, junctions, root renaming and sharing failure were executed without skips. Win32 API failure/truncation and outside-canonical-path responses were injected at the OS boundary because these invalid results cannot be reliably produced for a healthy pinned local handle. ctime skew remains a stat-boundary positive injection because ordinary lstat/fstat ctimes matched on this host. The POSIX no-follow branch is simulated on Windows.

🤖 Generated with Claude Code

Signed-off-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>

@loopx-agent loopx-agent 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.

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · max

本次评审对应提交 042e315368b5e9b30b985132353daa450bfc234d。

[P2] 新 Windows 采集分支还需按规范路径核验范围。

动机 / Motivation

在 Windows 或 POSIX 上运行可选 Jev drift wrapper 的操作者。主干在没有 O_NOFOLLOW 的 Windows 上显式不可用;macOS/Linux 继续沿既有 O_NOFOLLOW。原 POSIX 路径继续可用,实际 wheel 与合成 File authority 验证本地 baseline、真实 refresh 和 egress_denied 回执。新 Windows 实现保留 reparse 与身份检查;范围规范化仍需要补足。独立运行环境为 macOS。Windows 路径对照模拟 OS 命名和属性边界,未运行 Win32/NTFS、ACL 或远端 CI;本机 Windows 正常和现有 race 结果引用作者声明,不当作独立验证。Windows 分支只按输入拼写检查被排除的路径,规范路径目前只用于判断是否仍在工作区内。用等价路径解析的隔离对照可到达实际读取;作者的本机用例覆盖 reparse、替换和权限冲突,尚未覆盖这个规范路径边界。

改动思路 / Approach

Windows 必须用现有 capture owner 内的平台 IO,保留现有有界读取和原 Git/receipt 逻辑。 分支补足原生打开能力,但 scope 必须约束已打开的对象,不应只验证输入字符;两种语言的运行说明也要跟上。 评审依据 packages/loopx-jev/DRIFT_SHADOW.md 的 scoped files 合同。继续用同一个可选 Jev owner 采集文件。Windows 的句柄校验要同时守住路径范围;微软的路径命名说明 明确一个对象可以有多种路径表示。

具体改动 / Changes

关键代码讲解

POSIX-OFF-PARITY:精确 04958a89abbbf6b7d3f79327437e2d6deae97453 与 042e315368b5e9b30b985132353daa450bfc234d 的 wheel 都在 macOS 实跑 init → refresh → drain → status,并写回本地 not_evaluated/egress_denied;原 refresh 记录不变,未启用 observer 时不产生观察目录。HANDLE-IDENTITY:新分支对目录句柄、最终文件和 reparse 属性做校验。作者的本机 Windows 验证覆盖了普通文件、链接、句柄冲突和置换;我单独复跑了 portable 用例和实际 POSIX 路径。

对主干的风险 / Risks

CANONICAL-SCOPE:validate_paths 仅对输入路径的文本组件执行排除规则;resolve() 的结果只用于确认仍在工作区内。文件句柄的身份一致也不能说明其规范路径符合范围。在模拟 Windows 名称解析、使用真实 capture 和 Git 的隔离对照中,规范对象相同的两种表示给出不同结果。这个观察没有执行 Win32 或 NTFS。请在读前把同一范围规则施加到已绑定身份的规范路径,补本机 Windows 负例和普通文件对照。两份运行指南还将 Windows 写作未验证,需要与实际支持范围同步。

语义与 CI 对齐

macOS 主干 126 项通过,新头 143 项通过、4 个 Windows-only 用例跳过。两个精确 wheel 的实际 CLI、POSIX 拒绝用例、Ruff 与标准预检通过。作者说明中的 Windows 包/共享用例失败仍保留,macOS 结果不能为它们归因或视作通过;没有查询远端 CI。

我的整体评价 / Verdict

请求修改。保留现有 handle identity 与 POSIX 边界,补规范路径的统一范围校验及 Windows 本机验收。这是已有可选 Jev CLI 的平台采集路径,未改变视觉界面。未验生产安装、原生 Windows ACL 或真实模型。

English verdict: REQUEST_CHANGES. Validate the canonical opened path against the same capture scope, then demonstrate the rejection on native Windows. The packaged POSIX path and default-off behavior passed independently.

Signed-off-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>
@xiaobaifly7

Copy link
Copy Markdown
Contributor Author

Addressed CANONICAL-SCOPE in drift_capture.py. Before reading, Windows now obtains normalized paths from the identity-checked workspace and file handles with GetFinalPathNameByHandleW, makes the file path workspace-relative, and applies the existing scope validator. Failed or incomplete canonical-path queries stop capture. Existing no-follow, reparse, directory-pinning and identity checks remain in place.

test_windows_rejects_native_git_path_representations proves the finding on native Windows: the fixture creates a real GIT~1 alias for .git, verifies both spellings identify the same file, and traps any attempted read. Both short-name variants reached that trap before the fix and now reject with invalid_scope_path. Long names, mixed case and extended/device prefixes are also rejected before reading. 8.3 creation is enabled on the tested volume; neither alias case was skipped.

test_windows_fails_closed_without_final_path injects API failure and insufficient-buffer results at the Win32 boundary. Ordinary regular-file capture and the stat-boundary ctime-skew positive pass. The native capture suite is 30 passed, no skips; the isolated real CLI init/refresh/drain/status journey also passes with zero capture failures and no provider dispatch.

Both run guides now describe Windows support and its limits. The combined package/shared run changes from 141 passed / 10 failed / 4 errors to 146 passed / 6 failed / 4 errors: the four new negative failures are fixed and the added positive passes. The six existing failures, four SQLite setup errors and existing native mypy os.O_NOFOLLOW error remain disclosed in the PR draft.

@loopx-agent loopx-agent 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.

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=max

复审提交:be915c2b2466a7a52c4b3ab91c0c04d3b3aad477。
[P2] 缺失文件的 Git 元数据别名仍可写入观察范围。 缺失分支

动机 / Motivation

在 Windows 上用 Jev 观察所选工作区文件的开发者。 上次发现的已有文件别名现在会在读取前拒绝。但如果经同一目录别名选择的文件尚未创建,初始化会接受这个范围,文件一出现,观察器就无法形成这一轮证据。 注入 Windows 的路径映射并执行真实 Jev 和 LoopX CLI 时,缺失元数据文件的别名会保存为有效范围。文件出现后,原刷新仍写入,观察器报 capture_failed、清空基线且没有事件。 独立验证在 macOS,注入 Windows 路径及文件身份观察。作者另外报告原生 NTFS 结果。本轮未独立运行原生 Windows、ACL 或网络共享,也未查询 CI。

让初始化和后续采集对同一 Git 元数据父目录使用同一范围规则。 范围合同 允许未来出现的普通文件。更新后的 Git 元数据排除 仍需覆盖已知父目录。 核验项:opened_alias_is_rejected_before_read, excluded_scope_cannot_be_initialized。

改动思路 / Approach

沿用现有 capture、范围校验和 Windows 句柄,不引入第二套范围或证据状态。现有元数据拒绝应同时覆盖已知父目录。 保留 POSIX 路径和可选观察器边界,把修复收在 Windows 路径校验。 GetFinalPathNameByHandleW 支持已打开目录和文件。既有代码已经取得父目录句柄,缺失分支可以先检查规范位置再记录缺失。 Microsoft 文档

具体改动 / Changes

  • Windows 捕获 已存在的对象在读取前核验规范路径。上一提交对已有别名返回 0 并读取了合成文件。当前返回 2,不写基线且未调用 read。
  • 初始化 已有的 Git 元数据目录通过短名选中时,目标尚未创建会得到 baseline_created。目标出现后,源刷新成功,Jev 报 capture_failed、清空基线且无事件。没有读取被排除的字节。
  • 英文指南、中文指南 已说明 Windows 的验证边界。真实 Jev CLI 接受一个尚未创建的普通文件。创建后产生一个本地事件,关闭外发时记录 not_evaluated / egress_denied。 PR 基点 macOS 包测试 93 项通过,当前提交 111 项通过及 12 个原生 Windows 项跳过;两边已有真实 refresh 和关闭状态用例都通过。 三个独立 CLI 用例还验证了当前已存在别名、缺失别名和正常缺失文件。

对主干的风险 / Risks

影响的是观察器证据。已知排除范围初始化成功后,常规刷新仍可能追加 Core 运行记录,而该观察器的基线被清空。原 POSIX 和关闭状态用例保持通过。Ruff、差异检查、签署、双语 RFC 和当前主干合入模拟通过。观察器初始化后范围固定,后续的 Core 刷新不会替换其中错误的文件选择。操作者需另建观察范围才能避免同一故障。

我的整体评价 / Verdict

请求修改。初始化应在已有父目录可核验时拒绝该范围,避免把不可用的选择保存到后续轮次。 在把文件记为缺失前,取最深已打开父目录句柄的规范相对路径,使用现有范围规则检查。保留普通未创建文件的正例。 建议在同一项原生 NTFS 验证中确认前述拒绝和普通路径恢复。

English verdict: REQUEST_CHANGES. Head be915c2. The existing alias is rejected before read. A missing leaf under an already excluded Git directory alias still initializes; when it appears, a real refresh succeeds but Jev loses its baseline and emits no event. Validate the canonical existing parent before accepting absence.

Signed-off-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>
@xiaobaifly7

Copy link
Copy Markdown
Contributor Author

Addressed the latest missing-path finding in commit 8e0d846193bb944ffe51c0c672a0e01222f9b2c4.

Before accepting absence, Windows now checks the canonical path of each identity-checked, held directory handle plus the complete remaining suffix against the existing workspace/scope rules. This covers both a missing leaf and missing intermediate directories. A missing workspace root, unusable identity or unavailable canonical path fails closed. The canonical opened-file check and existing no-follow, reparse, directory-pinning and ctime-independent identity checks remain intact. Native sibling tests also exposed ambiguous trailing-dot/space and directory-stream spellings; Windows scope validation now rejects those, drive-relative names and stream syntax consistently.

test_windows_missing_git_alias_cannot_initialize uses a real native GIT~1 alias and valid CLI configuration, and proves exit 2 with no observer state. The expanded test_windows_rejects_native_git_path_representations covers existing files, missing leaves and missing intermediate directories, root and nested Git metadata, case variants, real 8.3 aliases and extended/device prefixes; its existing-file guard forbids reads.

The real native CLI counterexample reproduced before the fix: initialization succeeded, then file creation and a successful real refresh left capture_failed, a null baseline and zero events. After the fix, both excluded future paths are rejected at initialization. Ordinary directory-alias controls still initialize, produce one event after file creation and real refresh, and write a local egress-denied receipt with zero capture failures/provider attempts.

Test-first matrix: 24 failed / 72 passed → all 96 passed; two further opened-file API-failure guards bring the final capture suite to 98 passed, no skips. Sibling coverage includes disappearing roots, sharing conflicts, unusable identities, junction descendants, canonical-name failure/overflow, and ordinary ctime-skew, regular-file and hard-link positives. Injected canonical-name/ctime cases are limited to their OS/stat boundaries.

@loopx-agent loopx-agent 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.

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=max
Reviewed commit: 8e0d846193bb944ffe51c0c672a0e01222f9b2c4 · merge base 04958a89abbbf6b7d3f79327437e2d6deae97453.

[P2] 同一文件经大小写别名选中时漏记 Git 暂存区变化。 在不区分大小写的工作区跟踪 record.txt,通过 RECORD.txt 选中这个普通文件,然后只改索引中的 blob。 真实刷新写回成功,状态却从按登记名查询的 index_only_change_unknown 变成 no_delta。Windows 分支用规范地址验证并打开文件,两次 Git 查询仍按原样匹配路径。这个漏报在 macOS 分支基线上也能复现,当前 PR 将相同缺口带入新增的 Windows 文件分支。 请让暂存区查询使用与已验证文件一致的本地 Git 路径,或明确拒绝无法可靠映射的别名。把同一映射用于两次有界查询,保留普通缺失文件和曾跟踪现已删除文件的行为。 代码位置

动机 / Motivation

使用 Jev 观察任务进展的操作者会明确选择文件,再通过真实 refresh-state 保存并查询观察状态。 在分支基线上,Windows 缺少 O_NOFOLLOW 时直接拒绝。旧头开始支持 Windows,但仍接受经 .git 短名选中的缺失文件。 本次支持 Windows 的普通文件和未来路径,并修了缺失 .git 别名的旧反例。选中同一普通文件的别名时,暂存区变化仍可能被漏报。 原有 Jev shadow 仍是可选观察器,采用现有边界只读 Git,不授予 Goal 的执行或变更权限。

改动思路 / Approach

现有 drift_capture 负责打开和校验文件。Git 索引由现有有界读取器提取,drift.enqueue 比对文件与索引后保存观察状态。 Windows 分支固定目录句柄并核对身份,用规范路径校验最深已存在的祖先和剩余后缀。现有 POSIX 分支保留 O_NOFOLLOW。 索引读回和文件读取应覆盖同一批已选中的 Git 路径。先验证规范地址和范围,再取该文件的暂存区证据。 Git for Windows 在有 icase 标志时才走不区分大小写的路径比较。 匹配代码

具体改动 / Changes

按 packages/loopx-jev/DRIFT_SHADOW.md 在 5e5256cf7d476867cecae4dab4f8c5c5287b1503 的条款评估。index_only_change_unknown 仍不满足。scoped capture 相关路径保持:范围限于显式文件,排除 Git 元数据,普通未来文件仍允许建立基线。

关键代码讲解

  • validate_paths:校验相对范围,Windows 分支按大小写检查 .git 并排除有歧义的写法。
  • _windows_descriptor:通过现有 Windows 系统 API 以拒绝 reparse 和固定祖先的方式获取句柄。
  • _windows_capture:用规范路径检查祖先、未创建的剩余段及打开的文件。
  • capture 的索引读取:仍把原始 paths 用于前后的字面 Git 查询。
  • enqueue 的状态:用 index_digest 区分 no_delta 和 index_only_change_unknown。

采集器 173 增 13 删,两版指南同步。新增的采集测试覆盖别名、路径失败、硬链接、身份变化和 POSIX 保持;协议测试把不支持平台的替身明确标为其他平台。 上一轮评审 的反例在当前提交重新验证。旧版缺失路径被接收的问题已通过两种缺失层级对照。新的反例使用普通现有文件并改变暂存区。

对主干的风险 / Risks

PASS:当前头在 Win32 句柄边界的对照中拒绝了经 .git 别名选择的缺失叶子和缺失中间目录,旧头均接受。POSIX 真实普通文件、明确关闭时无观察器状态、按 Git 登记名观察暂存区变化均通过。 本地分支基线 126 项通过,当前头 157 项通过和 67 项平台跳过,包含 Jev、核心进展评审及 criterion binding。复审使用真实 Git、真实 File authority 和 refresh-state,单独注入 Windows 的路径/文件句柄边界。 当前头的缺失路径修复由隔离句柄路径夹具独立验证。以漏报事件为反例,不根据作者的原生测试数量推断结果。

FAIL:在大小写不敏感的工作区,把 record.txt 加入 Git,再以 RECORD.txt 初始化观察器。只替换 Git 索引中的 blob,保持工作文件字节不动。相同文件用登记名返回 index_only_change_unknown,用别名成功初始化并返回 no_delta。两条对照的核心刷新均成功追加,诊断和保存的事件一致。 在 NTFS 上用普通文件的登记名、大小写别名和可用的 8.3 名做对照,只改暂存区,要求同一个观察状态或明确拒绝含糊选择。

语义与 CI 对齐

复用已在采集时验证的规范相对路径,或对无法可靠映射至 Git 索引的别名明确拒绝。保留无通配的有界查询和缺失文件路径。 Git 差异检查与提交签署通过;与检查时的主干模拟合并有实质差异且无冲突。可重跑 PYTHONPATH=packages/loopx-jev/src uv run --extra test python -m pytest -q packages/loopx-jev/tests tests/capabilities/test_progress_review.py tests/test_progress_review_criterion_binding.py 并加入上述对照。Windows 原生 NTFS 的测试来自作者,本评审未独立运行。独立对照使用 macOS 的真实 Git 与核心命令,Windows 句柄和名字解析通过夹具验证;未评估 hosted CI、安装态和网络共享。

我的整体评价 / Verdict

启用 Windows 支持扩大了可用范围,按别名漏掉选中范围内的证据会让后续回看无法区分未变化和只改过索引。 普通文本采集和关闭路径可用。需要知道暂存区是否改动的操作者会收到随路径写法变化的状态。 本补丁改的是可选 CLI 和两版指南,不涉及首屏。 已经初始化的路径保留用户输入的名称;若协商 Git 路径身份,至少要保持显示名和已选范围,按既有入口处理不明确或失效的基线。

English verdict: REQUEST_CHANGES — Validated the excluded-alias guard at the filesystem adapter boundary. The same selected file still yields no_delta on a real index-only change when addressed through an accepted case alias.

…file

On a case-insensitive workspace a scoped path such as RECORD.txt opens the
tracked record.txt, but the literal index query matched nothing, so an
index-only change was reported as no_delta. Both bounded index reads now
use a case-insensitive literal pathspec when core.ignorecase is set.

Signed-off-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@xiaobaifly7

Copy link
Copy Markdown
Contributor Author

Addressed the P2 in commit c18ffd5d6.

Cause. On a case-insensitive workspace RECORD.txt opens the tracked record.txt, but both bounded index reads used a literal pathspec, which matches the index spelling exactly. The index evidence for the alias was therefore empty, and an index-only change became no_delta.

Fix. Both index reads go through one helper. When core.ignorecase is true it queries each selected path as :(icase,literal)<path>, so the entry for the same file is read whatever spelling selected it; otherwise it keeps the literal query. Because the same mapping is used before and after the file read, the existing "index changed during capture" comparison still holds. A missing ordinary file still has no index entry, and a tracked-then-deleted file is still found through its index entry.

I chose mapping over rejecting the alias because the file capture already accepts it, and a case-sensitive workspace must keep treating the two spellings as different files.

Tests. test_index_only_change_is_seen_through_case_alias (exact spelling and case alias) stages different content and restores the working file, then asserts the content digest is unchanged while the index digest differs. The alias case fails without the fix; it is skipped on case-sensitive workspaces. tests/test_drift_capture.py: 100 passed on native Windows.

Three cases in tests/test_drift.py fail on this Windows host with and without this commit (test_deletion_mode_and_no_final_newline_remain_visible, test_private_file_permissions_and_secret_like_scope_rejection, test_evidence_only_work_is_not_dropped_as_no_code_delta); I left them alone. Not run: macOS, where the same alias gap exists on the default filesystem.

@loopx-agent loopx-agent 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.

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=max

评审提交 c18ffd5d6999f1e58509077885c16dcd91420919。合并基点为 04958a89abbbf6b7d3f79327437e2d6deae97453,用主干 8d7d234c6f55fa45fa5db0ad5a156dcaaf726d32 检查了合并树。

[P2] 继承字面路径设置后,原名文件的暂存变化也会漏报。 在 core.ignorecase=true 的仓库用原名选中 plain.txt,给 Jev 进程设置 GIT_LITERAL_PATHSPECS=1,只修改暂存内容并恢复工作文件。 旧头的真实 Jev 刷新报告 index_only_change_unknown,当前报告 no_delta。Git 把新路径前缀当成字面文件名,查询成功但不返回条目。原 LoopX 刷新在两版都提交成功。 在现有 Git 查询边界隔离 pathspec 环境,或使用已验证的精确 Git 路径。保留字面通配符语义,用继承设置和干净环境复验原名。 代码位置

[P2] 非 ASCII 大小写别名仍会漏掉真实暂存变化。 在不区分大小写的 APFS 中用 CAFÉ.txt 选中 Git 跟踪的 café.txt,核实同一 inode,仅改索引。 原名读回索引摘要变化,当前别名的真实刷新仍报告 no_delta。Git 此处的 icase 规则与文件系统解析不同。ASCII 别名已验证修复。 用已核验的文件身份对应唯一索引项,或明确报告证据不足。在原生 Windows 及 APFS 复验非 ASCII、普通缺失和已删除但仍跟踪的文件。 代码位置

动机 / Motivation

用 Jev 观察进展的开发者选择少数工作文件,期待一次真实刷新能区分暂存变化与没有变化。 在默认不区分大小写的工作区,用文件别名选中普通文件,暂存新内容,再恢复工作文件。 工作文件相同的两次观察若少读了索引,就会漏掉已经暂存的工作,之后需要手工复核。 候选新增 Windows 句柄检查并修复普通 ASCII 大小写别名。索引遗漏仍会把真实暂存变化报成没有变化。 范围是显式选择的文件观察和原刷新。原生 Windows 和网络共享仍需区分作者结果与本次独立证据。

改动思路 / Approach

drift_capture 负责工作区和所选文件身份。Git 返回暂存证据。drift 的初始化、准备与入队管理观察,现有 LoopX refresh-state 持有工作结果。 此前的缺失父目录问题已有具体修复。打开每一层现有目录后,按句柄取得其规范路径,把余下可能未创建的部分拼接回去,再检查是否仍在允许范围。本地跑过可执行的模拟边界,原生短文件名和文件共享的证据来自作者。最新提交的两次索引查询都走同一个 helper,两次读取能发现并发变化,但前提是先正确匹配同一个索引项。

由 Jev 现有采集统一文件和 Git 条目身份。现有刷新、队列与可选消费者各保有权威。 范围是显式选择的文件观察和原刷新。原生 Windows 和网络共享仍需区分作者结果与本次独立证据。

具体改动 / Changes

此前审阅提交为 8e0d846193bb944ffe51c0c672a0e01222f9b2c4。本轮覆盖当前提交的完整变更。五文件 +894/-25。Windows 句柄和索引集中在原 scoped capture,测试占新增规模的大部分。 规范版本是 04958a89abbbf6b7d3f79327437e2d6deae97453。显式选定文件、允许未来普通文件、排除 Git 元数据与真实证据分类约束现有消费者。 现有规范

  • scoped_capture 已核对本轮适用证据。限显式选择范围并保留正常未来文件。 代码或规范
  • index_evidence 仍有实测缺口。选定文件的暂存变化应可见。 代码或规范
  • refresh_passthrough 已核对本轮适用证据。关闭或未设置保持原刷新。 代码或规范

关键代码讲解

  • _windows_capture 固定目录和真实打开文件。规范祖先和未建后缀受同样检查。查询异常拒绝采集。 源码
  • _index 选择实际 Git 索引路径。Git 配置与文件系统别名不等价。读不到时明确未知。 源码
  • capture 比较文件和索引。使用同一规则。检测到竞态拒绝。 源码
  • enqueue 从实际刷新和摘要导出观察。空索引无法证明暂存没有变化。暂存变化归为未知。 源码

对主干的风险 / Risks

  • PASS 普通文件和 ASCII 别名。同一 APFS 文件用普通 ASCII 别名选中且仅改索引时,旧头报 no_delta,新头正确报 index_only_change_unknown。源码真实 File refresh、证据入队与关闭观察器路径通过。
  • PASS 独立相关验证。基线的三套既有调用 64 项通过。当前四套合计 97 项通过、67 项条件跳过。Git 检查与配对通过。

独立运行 macOS APFS、Git 2.56 与源码 File refresh。67 项 Windows 或平台条件用例跳过,未独立运行原生 NTFS、ACL 或网络共享。Windows 100 项为作者报告。

语义与 CI 对齐

复用现有 Jev 观察状态和有界 Git 读取。修复后重跑真实 drift init、Jev 代跑 refresh-state,并分别用原名、ASCII 别名、非 ASCII 别名和继承字面路径环境。Git 的全局字面模式关闭 pathspec magic。 Git 命令文档

我的整体评价 / Verdict

REQUEST_CHANGES。ASCII 已修复。原名的 Git 环境回归仍阻断,非 ASCII 原名和别名需要一致证据。 直接路径精确比对可沿用。别名用唯一可核验映射,无法对齐时返回明确的证据缺口。

English verdict: REQUEST_CHANGES at c18ffd5. ASCII aliases work on the tested APFS checkout. Inherited literal pathspec mode now hides staged edits at the exact path, and a non-ASCII alias still hides them.

The case-insensitive pathspec only folds ASCII and is reinterpreted by an
inherited GIT_LITERAL_PATHSPECS, so index-only changes were still missed.
Isolate pathspec environment for every Git read, and on a case-insensitive
workspace resolve an alias through the directory's index entries, matching
the folded name and, when both exist, the same file.

Signed-off-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@xiaobaifly7

Copy link
Copy Markdown
Contributor Author

Addressed both P2 findings in commit 2824e9123.

Inherited pathspec mode. Every Git read in the capture now runs with GIT_LITERAL_PATHSPECS, GIT_GLOB_PATHSPECS, GIT_NOGLOB_PATHSPECS and GIT_ICASE_PATHSPECS removed from its environment, so an inherited mode cannot reinterpret the capture's own pathspecs. The exact-name read keeps its explicit --literal-pathspecs, which preserves literal wildcard semantics.

Non-ASCII aliases. I stopped relying on Git's icase to resolve an alias, since it does not fold the way the file system does. On a case-insensitive workspace, a selected path with no exact index entry is now resolved through the index itself:

  1. The existing leading directories are spelled as their parents list them, matched by file identity (so an aliased or short-name directory resolves to its real name).
  2. The index entries directly inside that directory are streamed from a file-backed read (not held in memory), and entries whose leaf folds to the same key (NFC, lower-case) are kept.
  3. If both the selected file and the candidate entry exist on disk they must be the same file; two files that merely share a key stay distinct.

The exact-name case is unchanged and still a single read, and a case-sensitive workspace keeps the literal query only. A missing ordinary file, an untracked file and a differently named neighbour all keep empty index evidence; a deleted but still tracked file is found through its index entry under either spelling.

Tests (native Windows, NTFS, core.ignorecase=true): exact, ASCII alias, non-ASCII alias (CAFÉ.txt for tracked café.txt) and aliased directory, each with a clean environment and with GIT_LITERAL_PATHSPECS=1; deleted-but-tracked through ASCII and non-ASCII aliases; missing, untracked and distinct neighbours. Seven of these fail on the previous commit. tests/test_drift_capture.py: 109 passed. The same three tests/test_drift.py cases as before fail on this host with and without the change.

Not verified: APFS. The fold key is NFC plus lower-case, which I expect to cover APFS normalization aliases, but I could only run NTFS. One case remains unresolved by design: a directory that was renamed on disk to a spelling that differs from the index only by non-ASCII case; the directory glob still uses Git's ASCII-only folding there.

@loopx-agent loopx-agent 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.

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=max

评审提交 2824e91,GitHub 当前列示的目标分支提交 04958a8。

[P2] 按实际文件身份识别别名的暂存区变化。 在不区分大小写 APFS 上核实两个拼法指向同一文件、内容不变且真实 blob 已改变,原 LoopX 刷新成功;以 Git 登记名读得 index_only_change_unknown,以别名却读得 no_delta。希腊文词尾 sigma、ß/SS 和一个只改变非 ASCII 大小写的上级目录均可复现。当前代码在核对文件身份前用小写键剔除候选,目录枚举也仍可能漏掉旧 Git 拼法。 复用有界索引读取,把能用实际身份验证的候选保留下来,或在无法唯一对应 Git 路径时报告证据不足。保留原名、缺失文件和曾跟踪后删除的行为;对前后两次 Git 读取使用同一映射。 位置。

动机 / Motivation

可选 Jev 此前拒绝原生 Windows 的安全读取。上一修订增加该分支,却会因 Git 的继承设置或部分别名悄悄漏掉只发生在暂存区的变化。 在不区分大小写的卷上使用 Jev 的本地操作人员;相同观察者也覆盖已有 POSIX 路径。 在既有 Jev 捕获中验证 Windows 路径身份;已启用的捕获按真实文件范围读取 Git 索引,修复继承设置及别名。 用 Git 跟踪文件,两个拼法都能打开同一文件;只更新 Git 暂存区中的 blob,再恢复原工作文件,运行真实 Jev drift init/refresh。 前两个用例已修;若改用系统确认同文件的 ς / Σ、ß / SS 或改名后的非 ASCII 上级目录,仍只有 Git 登记名正确报告暂存区改变。 独立复验为本机不区分大小写的 APFS,不以它推断原生 Windows、NTFS 重解析点或真实安装;67 项跳过保留为未检,未查远端 CI。

改动思路 / Approach

Jev 是选择启用的观察者。现有捕获、Git 证据与运行的 CLI 写回保持分属原有 owner;工作文件字节与索引结果都需要独立验证。 保留现有捕获与索引查询边界。已有文件用受限的、可验证的实际文件身份对应 Git 路径;无可证明的唯一关系时明确保留证据不足。 只修既有 Jev 本地捕获;没有新的启动方式、状态协议或执行权。

对照 既有规范 的使用者结果和边界。当前主干未改动本包;以其合并树检查通过。作者的原生 Windows 结果与本轮 APFS 结果各自保留,不互相代替。

  • EXACT-OR-SAFE-CAPTURE:只捕获明确选择且确切属于工作区的文件;不确定证据须保持可见。 已复核适用分支。
  • STAGED-BLOB-EVIDENCE:索引变而工作文件不变,沿现有契约报告 index_only_change_unknown。 未通过。

具体改动 / Changes

五个文件:可选捕获实现、双语指南、原生 Windows 测试及协议测试。最新修订扩展共享 Git 环境处理、上级目录枚举和索引解析;不只是 Windows 分支。

  • _git_env: 在现有 Git 读取边界移除继承的 pathspec 语义。
  • _windows_capture: 持有已验证目录句柄,拒绝超范围与不可确认路径。
  • _disk_parent: 按真实目录名称构建候选父级,Git 搜索仍可能用另一拼法。
  • _index: 前后两次索引读取共享此映射;此处在 samefile 前过滤候选。

上一次评审;修后说明。上一精确候选在继承 Git 路径设置和 café 别名两个用例返回 no_delta;登记名对照按预期识别暂存区变化。 前两个用例已修;若改用系统确认同文件的 ς / Σ、ß / SS 或改名后的非 ASCII 上级目录,仍只有 Git 登记名正确报告暂存区改变。

对主干的风险 / Risks

  • PASS — 本地捕获、漂移和协议套件 105 通过、67 跳过。差异格式检查通过;off 保留原调用的回归包含在套件。 在本机 APFS + File:继承 GIT_LITERAL_PATHSPECS 的原名和 CAFÉ.txt 别名均由漏报修成 index_only_change_unknown。
  • FAIL — 在真实 APFS 上持有相同文件身份,仅改变暂存 blob,分别选登记和替代拼法;加入非 ASCII 上级目录改名以及缺失、删除与不同文件邻居对照。原生 Windows 另验实际身份。
  • UNVERIFIED — 独立复验为本机不区分大小写的 APFS,不以它推断原生 Windows、NTFS 重解析点或真实安装;67 项跳过保留为未检,未查远端 CI。

我的整体评价 / Verdict

REQUEST_CHANGES。复用有界索引读取,把能用实际身份验证的候选保留下来,或在无法唯一对应 Git 路径时报告证据不足。保留原名、缺失文件和曾跟踪后删除的行为;对前后两次 Git 读取使用同一映射。 检查了 Jev CLI 与实际输出;此差异无视觉、界面或聊天渲染变动。

English verdict: REQUEST_CHANGES at 2824e91. The earlier inherited pathspec and café alias cases pass on APFS. Other spellings of the same file still report no_delta for a real staged-blob change; the Git spelling reports index_only_change_unknown. Native Windows was not independently exercised.

Lower-case keys filtered candidates before the identity check, and the
directory glob used Git's ASCII-only folding, so final sigma, sharp s and
a parent renamed by non-ASCII case still lost staged changes. Stream the
index once: an existing file matches entries in the same directory by
identity, a missing file matches by Unicode caseless name.

Signed-off-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@xiaobaifly7

Copy link
Copy Markdown
Contributor Author

Addressed in commit 717ecf7ca.

Cause, as you described. Candidates were filtered by a lower-case key before the identity check, and the directory listing used Git's icase glob, which only folds ASCII. So an alias that the file system resolves differently from both rules (final sigma, ß/SS, a parent renamed by non-ASCII case) never reached the identity check.

Fix. On a case-insensitive workspace, a selected path with no exact index entry is now resolved through one file-backed stream of the whole index (bounded memory, same 5 s Git limit), identity first:

  • Existing file: an index entry matches only if it is the same file. To keep this bounded, entries are compared only within the selected file's directory: the directory of each entry is checked once (cached) for identity with the selected file's parent, and only entries in that same directory get a per-file samefile. No name key is applied before this, so any folding the volume uses is honoured, and a parent renamed on disk is found through the index's own spelling.
  • Missing file (deleted but still tracked, or not yet created): there is no identity, so entries match by Unicode caseless name (NFD + full case folding) on the whole path, with existing leading directories spelled as the disk lists them. Every entry that could be the file is kept, so an index change is never reported as no_delta.

The exact-name read and its literal semantics are unchanged; a case-sensitive workspace keeps the literal query only; the same mapping is used for both index reads in a capture.

Tests. New test_index_only_change_follows_file_identity changes only the index blob (hash-object + update-index --cacheinfo, working file untouched) for final sigma, ß/SS, and a parent renamed to a non-ASCII-case spelling. Each case skips when the volume does not resolve both spellings to one file. On NTFS only the renamed-parent case applies (NTFS does not fold ς/Σ or ß/SS); it passes here and fails on the previous commit. tests/test_drift_capture.py: 110 passed, 2 skipped on native Windows.

Not verified here: APFS, where the sigma and sharp-s cases would run; the identity path is what should cover them, but I could not execute it on this host. The same three tests/test_drift.py cases as before fail on this host with and without the change.

@loopx-agent loopx-agent 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.

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=max

评审提交 717ecf7ca681ee2e9f679d7d7f42e4bf4cae5b01,实际 Git 共同基点 04958a89abbbf6b7d3f79327437e2d6deae97453。与主干 59e68906d4082f43fae52e4219e374c5e97539a9 的合树检查通过。 上一轮评审

[P2] 范围外的 Git 路径会让合法采集失败。 在不区分大小写的 Git 仓库登记一个范围外的 0xFF 字节路径。用 drift init 选择普通跟踪文件和一个未来文件。 真实 CLI 的共同基点返回 baseline_created,当前提交返回 invalid_configuration_or_local_evidence,未生成基线。_index_records 在候选筛选前尝试把整条输入逐一解为 UTF-8。 在后备枚举中过滤到相关记录,再处理这些记录的编码。用原始记录或无损文件系统表示匹配,保持现有摘要和范围内非法输入的拒绝。 位置

动机 / Motivation

用可选 Jev 观察一次任务的操作者需要采集指定文件的前后证据,所选文件可以尚未创建。 共同基点仅依靠 POSIX 文件原语。候选增加 Windows 的原生句柄校验,并让大小写不敏感工作区按文件身份核对 Git 登记名。 在真实 macOS Git 仓库选择一个普通跟踪文件和一个尚未创建的文件。加入范围外的 0xFF 索引记录后,基点仍创建基线,当前提交退出 2。只选普通跟踪文件时当前提交成功。 本地验证覆盖 APFS、真实 Git 索引和源码 CLI。原生 Windows、NTFS 安全边界及网络共享仍需独立实跑。

改动思路 / Approach

Windows 的 no-follow、目录和文件身份校验适合留在可选采集器。别名对应 Git 记录也必须保持原来按明确范围采集的承诺。 当前改动适合交付原生 Windows 采集及别名索引匹配。先让后备枚举忽略无关记录的解码问题,继续使用现有捕获和失败语义。

保留原来的直接查询,普通文件不需要读取整份索引。旧逻辑适合 POSIX,对 Windows 别名需补文件身份证据。本提交用原生句柄处理 Windows 的访问与重解析点,索引字节应到达范围匹配后再转换。

具体改动 / Changes

完整差异共 5 个文件,增加 1129 行,删除 26 行。与上一头相比,先按真正的目录及文件身份匹配,移除了近似大小写过滤对现有文件候选的误判。

以 packages/loopx-jev/DRIFT_SHADOW.md 在 04958a89abbbf6b7d3f79327437e2d6deae97453 的约定为依据。

  • Scoped files。只观察明示的文件,允许尚未创建的文件,范围外内容不参与。 当前反例仍需修复。
  • Workspace binding。拒绝无效路径、越界和无身份的读回,保留已选可读文件的基线。 当前对照通过。
  • Windows qualification。判断新增 Windows 路径,用真实原生文件系统覆盖外部连接和失败。 原生 Windows 仍需独立运行。

关键代码讲解

  • 输入路径须为明确且安全的相对文件名。 validate_paths
  • 固定目录句柄,逐层验证 canonical 路径,读文件前后比对身份。 _windows_capture
  • 有界 Git 命令输出按 NUL 分帧,目前在候选筛选前严格解码每条记录。 _index_records
  • 命中精确路径优先,只用已存在文件的身份以及尚未创建文件的旧索引拼写补足摘要。 _index
  • 在读取前后比较同一 HEAD 和同一选择的索引摘要。 capture

对主干的风险 / Risks

上一轮的已存在文件别名问题在当前版本通过。按同一 APFS 文件身份复核 sigma、ß 与非 ASCII 上级目录,并重跑历史特殊 pathspec、已删除文件和 off 模式。源码验证 109 项通过、67 项跳过。本地预合并 5 项直接检查通过。 检查了同一个 Git 字节边界上的 #8678。两项各有实际调用方,独立合树。本项可复用字节分帧思路,采集器仍保有自己的明确范围和索引摘要。

语义与 CI 对齐

Jev 的显式范围沿用已有采集契约。失败发生于范围外记录的 UTF-8 解码,导致有效工作在写基线前停止。定向跑 packages/loopx-jev/tests/test_drift_capture.py 以及真实 Git 与 CLI 的范围外记录对照。

我的整体评价 / Verdict

REQUEST_CHANGES。 在后备枚举中过滤到相关记录,再处理这些记录的编码。用原始记录或无损文件系统表示匹配,保持现有摘要和范围内非法输入的拒绝。 这仍影响采用者持续得到有效观测。原有选择范围、POSIX 对照及原生 Windows 验证需要分别可读回。

English verdict: REQUEST_CHANGES. The alias identity fixes pass on APFS. An unrelated non-UTF-8 index entry still makes scoped initialization fail. Filter relevant entries before decoding and retain the earlier alias controls. Native Windows remains unverified in this review.

The full index stream decoded every record before filtering, so one
unrelated non-UTF-8 path made a valid capture fail. A record that is not
UTF-8 cannot be a selected path; skip it. The scoped literal read still
decodes strictly, so invalid input inside the scope is still rejected.

Signed-off-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@xiaobaifly7

Copy link
Copy Markdown
Contributor Author

Addressed in commit fdea00cfb.

The full index stream (used only when a selected path has no exact entry on a case-insensitive workspace) now decodes each record individually and skips a record that is not valid UTF-8. Such a path cannot equal any selected path, so it is outside the scope and no longer fails the capture. The scoped exact read is unchanged and still decodes strictly, so invalid input within the selected scope is still rejected, and digests are computed exactly as before.

test_out_of_scope_non_utf8_index_path_does_not_fail_capture adds a 0xFF index path via update-index --index-info, then captures a tracked file through an alias plus a not-yet-created file (which forces the full stream). It fails without the change with the same UnicodeDecodeError and passes with it. tests/test_drift_capture.py: 111 passed, 2 skipped (the NTFS-inapplicable sigma and sharp-s cases) on native Windows. APFS remains unverified on my side.

@loopx-agent loopx-agent 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.

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=max

评审提交 fdea00cfb11014b29ef91c0a5566de058356284c,Git 共同基点 04958a89abbbf6b7d3f79327437e2d6deae97453。与主干 f599a60ce64fd78db80d6318c84e3af58bfc1df9 合树通过。 上轮评审 作者改动说明

[P2] 索引后备匹配把范围外硬链接当成所选路径。 在 core.ignorecase=true 的 APFS 仓库中,跟踪 record.txt,将未跟踪且有独立目录项的 selected.txt 硬链接到该文件。用 drift init --path selected.txt 建基线,只用 git update-index --cacheinfo 改 record.txt 的暂存对象。 selected.txt 的字节和按该路径查询的索引记录前后相同。共同基点的采集器返回 no_delta,当前提交返回 index_only_change_unknown。两次 drift refresh 都成功通过真正的 LoopX refresh-state 追加回执。 先证明 Git 中的名字与显式选择解析到同一个目录项,再合入该暂存记录。路径已经解析到独立目录项时,文件身份相同不足以证明别名;仍应保留文件系统对真实大小写、Unicode 和 Windows 别名的判定。 问题位置

动机 / Motivation

启用 Jev 漂移观察的操作者依赖按 --path 明确指定的文件获得任务执行前后的可读回证据。未来创建的文件也可入选。 共同基点使用字面 Git 索引查询,在 POSIX 隔离索引范围,但漏掉真实大小写别名。候选为 Windows 增加路径校验,并在不区分大小写的工作区补查索引。

selected.txt 的字节和按该路径查询的索引记录前后相同。共同基点的采集器返回 no_delta,当前提交返回 index_only_change_unknown。两次 drift refresh 都成功通过真正的 LoopX refresh-state 追加回执。 验证使用真实 Git/APFS 和真实普通 refresh-state。原生 Windows、NTFS 句柄与网络共享仍需独立实跑,评审未读取远端 CI。

改动思路 / Approach

Windows 句柄和 Git 别名处理放在可选 Jev 采集器,保留当前默认关闭和刷新所有权,仅收紧后备候选。 平台句柄、目录项匹配与 Git 索引摘要应留在可选采集器。普通 refresh-state 继续由 LoopX 控制面持久化。

移除后备查询会重新漏掉真实别名。简单按字符串折叠也重现 Unicode 与路径前缀误判。需要收紧的是把相同文件身份视为同一路径这一条判定。

具体改动 / Changes

完整差异共 5 个文件,增加 1158 行,删除 26 行。生产 Python +330/−18,双语文档 +24/−4,验证 +804/−4。增量集中于可选采集器的原生路径校验、索引后备和测试。 范围外非 UTF-8 回归修复,实际别名正向样例通过。目前存在两个独立目录项共享 inode 时的范围误判。

下列验收项来自共同基点中的公开约定。 packages/loopx-jev/DRIFT_SHADOW.md

  • Scoped files。 只观察显式文件,允许未来文件,范围外的 Git 变化不会进入摘要。 当前真实采集把未选的另一目录项的暂存变化归到所选硬链接。
  • Workspace binding。 路径需在当前工作区,采集范围和状态写入按独立 owner 管理。 APFS 读回和真实默认关闭路径已实跑。
  • Windows file identity。 新 Windows 分支需独立验证实际 NTFS 句柄、重解析点和写竞争。 本地 APFS 执行不能验证 Windows 的原生权限和网络共享。

关键代码讲解

  • 检查显式工作区相对文件名。 元数据、越界和不合格拼写由已有异常路径拒绝。 validate_paths
  • 固定各级目录与文件句柄,验证 ID 与规范路径。 拒绝重解析点、访问不足、句柄竞争与越界;读取前后比较文件状态。 _windows_capture
  • 有界 Git 子进程分帧索引记录。 范围外非 UTF-8 记录可跳过,范围内无效记录仍走明确错误。 _index_records
  • 把字面索引与已解析的真实别名合并。 同目录和同 inode 也可来自两个不同的目录项,当前误吸收。 _index
  • 比较采集前后的 Git 和文件观察值。 持续采集稳定性约束依赖同一个选定范围。 capture

对主干的风险 / Risks

上轮范围外 0xFF Git 路径导致有效配置退出 2 的反例在本地已修复。真实索引含该记录,显式选择普通跟踪文件和一个未来文件,当前仍返回 baseline_created。 定向采集器及协议测试 74 passed, 67 skipped in 105.75s (0:01:45) 真实 refresh/off 测试 1 通过。 标准预合并通过,5 项直接检查通过,未选中 catalog 子命令。

Windows 原生句柄竞争、权限和网络共享留待独立验证。 无已初始化观察者、无凭据时,默认关闭的真实 drift refresh 仍运行 LoopX refresh-state 并成功追加,不创建观察目录且不发出影子诊断。

语义与 CI 对齐

APFS 上的两个硬链接具有不同目录项。测试只改范围外路径的真实 index blob,文件内容保持原样。 同一真实大小写别名 RECORD.TXT 在基点漏报,当前能找到原目录项并返回 index_only_change_unknown。

保留同一仓库、同一 inode 的成对测试。只改 record.txt 暂存 blob 时,选择独立的硬链接 selected.txt 应为 no_delta;选择实际大小写别名 RECORD.TXT 应为 index_only_change_unknown。保留未来路径与范围外非 UTF-8 记录的对照。

我的整体评价 / Verdict

REQUEST_CHANGES。 先证明 Git 中的名字与显式选择解析到同一个目录项,再合入该暂存记录。路径已经解析到独立目录项时,文件身份相同不足以证明别名;仍应保留文件系统对真实大小写、Unicode 和 Windows 别名的判定。

操作者只选了 selected.txt,它的内容与暂存状态都没变,但看到 index_only_change_unknown。 增量归因要与一次任务的观察范围一致。当前反例产生与所选材料无关的变化,使跨轮反馈误判工作证据。

English verdict: REQUEST_CHANGES. The prior non-UTF-8 regression is fixed, and a real case alias now detects staged changes. On APFS, the fallback also credits an out-of-scope tracked hardlink to an unchanged selected path. Require the same directory entry, preserve genuine aliases, and exercise the native Windows path independently.

A selected path listed under its own spelling is a separate directory
entry; sharing the file with a tracked entry does not make it that
entry. Match by identity only when the selected leaf is not listed in
its directory, i.e. the file system resolved it to another spelling.

Signed-off-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@xiaobaifly7

Copy link
Copy Markdown
Contributor Author

Addressed in commit c1da16e01.

Your counterexample is right: matching an existing selected file to an index entry by file identity alone treats a hard link as an alias. The fallback now first establishes that the Git name and the selection are the same directory entry:

  • If the selected leaf is listed in its directory under its own spelling, it is a separate directory entry. Only an index entry with that exact leaf (in the same directory, resolved by directory identity) matches; a different tracked name that merely shares the file — your selected.txt / record.txt hard link — is outside the scope.
  • Only when the selected leaf is not listed (the file system resolved it to another stored spelling: case, Unicode, short name) is the entry matched by file identity, as before.

Directory components still resolve by directory identity, and the missing-file path, the exact literal read and the non-UTF-8 handling are unchanged.

test_hard_link_to_a_tracked_file_is_not_its_alias hard-links an untracked selected.txt to tracked record.txt, changes only record.txt's staged blob through update-index --cacheinfo, and asserts the selected capture's index evidence is unchanged. It fails on the previous commit and passes now. tests/test_drift_capture.py: 112 passed, 2 skipped on native Windows (NTFS). APFS remains unverified on my side.

@loopx-agent loopx-agent 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.

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=max

评审提交 c1da16e01506e6a3dc68c95a4d2844930382b76f,实际共同基点 04958a89abbbf6b7d3f79327437e2d6deae97453。与当前主干合树通过。 已核主干 前一轮复审

[P2] 通过大小写别名选中硬链接,仍会读入另一个目录项的暂存变化。 在默认大小写不敏感的 APFS 上,selected.txt 与跟踪的 record.txt 是两个目录项,指向同一 inode。初始化只选 SELECTED.TXT,只改 record.txt 的暂存 blob。 共同基点输出 no_delta,当前提交输出 index_only_change_unknown。所选路径字面索引依旧为空,文件字节的 SHA-256 保持一致,原有写回成功且两侧都没有调用模型。 解析选中名字所属的真实目录项后再比较索引。保留大小写、Unicode 和 8.3 真别名,并在无法解歧时使用已有的不可用结果。 实际匹配分支

动机 / Motivation

启用 Jev 本地影子评估的操作者用 drift init --path 列出要观察的工作树文件,Agent 继续用原有 refresh-state 写回。 在默认大小写不敏感的 APFS 上,selected.txt 与跟踪的 record.txt 是两个目录项,指向同一 inode。初始化只选 SELECTED.TXT,只改 record.txt 的暂存 blob。

共同基点输出 no_delta,当前提交输出 index_only_change_unknown。所选路径字面索引依旧为空,文件字节的 SHA-256 保持一致,原有写回成功且两侧都没有调用模型。 改动保留 Jev 显式开启、原写回事务和索引证据边界。Windows 专有句柄和 8.3 路径本轮没有在原生 Windows 独立复验。

改动思路 / Approach

Windows 句柄路径与 scope validator 适合保留在现有捕获层。索引匹配也由捕获层负责,但判断需匹配同一目录项,两个目录项共享文件身份不足以确认范围。 本次边界是 Windows 安全读取与正确归属已选路径的 Git 索引证据,选取策略及原写回事务仍由既有入口负责。

只有字面比较会漏真正的大小写或 8.3 别名,只有 inode 比较会纳入另一条硬链接。优先解析选中名字对应的真实目录项,再和索引路径比较;无法判定时沿既有不可用路径反馈。

显式输入 共同基点 当前提交
selected.txt,另一硬链接有暂存变动 no_delta no_delta
RECORD.TXT,真正跟踪项的大小写别名 no_delta index_only_change_unknown
SELECTED.TXT,只有另一目录项 record.txt 的索引变动 no_delta index_only_change_unknown

具体改动 / Changes

完整差异共 5 个文件,增加 1190 行,删除 26 行。一个捕获器处理两个平台、句柄范围及索引归属。两份指南和两个测试文件链接现有入口。

按共同基点的公开约定验收。 packages/loopx-jev/DRIFT_SHADOW.md

  • JEV-1。 原始选择固定为调用者列出的文件,以真实目录项归属索引证据。 仅改变未选的 record.txt 暂存 blob 后,合法大小写别名 SELECTED.TXT 在当前提交误报。
  • JEV-2。 真实文件别名要保留其自身的暂存变化信号。 以 RECORD.TXT 选择跟踪文件,当前提交得出 index_only_change_unknown,共同基点漏报。
  • JEV-3。 影子诊断保持在现有写回事务和外发授权内。 同一入口的探针都追加原有写回且没有调用模型,定向关闭用例通过。

关键代码讲解

  • 由 Windows 已打开的目录和文件句柄验证身份,先在真实祖先上应用现有排除,再接受未来文件。 _windows_capture
  • 列目录判断选中路径是否用别名。没有字面拼写时回到同目录文件身份比较,因此其他硬链接可能被计入。 _index
  • 流式拆解 Git 的 NUL 分隔索引记录,跳过无法与字符串选区匹配的非 UTF-8 名字。 _index_records

对主干的风险 / Risks

macOS 捕获、协议和 CLI 定向测试 76 通过、67 跳过。独立复现使用真实大小写不敏感 APFS 和真实 Git。 本地标准预合并通过 5 条直接检查和 0 条选定自动检查。

一个范围外的暂存项可以改变已选范围的诊断,结果在连续回合里会把无关的暂存操作混进只针对指定文件的进展证据。 Jev 未启用时走透明原写回。定向 CLI 关态测试检查既有 argv、退出码、输出以及没有创建观察器或外发。 改动保留 Jev 显式开启、原写回事务和索引证据边界。Windows 专有句柄和 8.3 路径本轮没有在原生 Windows 独立复验。

语义与 CI 对齐

用精确拼写 selected.txt 时,改 record.txt 的暂存项仍给 no_delta。真正选 RECORD.TXT 时检测到自己的暂存变化。候选也能在无关索引文件名含非 UTF-8 字节时建立基线。

补充同目录 record.txt 与 selected.txt 的真实硬链接用例,以 SELECTED.TXT 初始化,只暂存前者后断言 no_delta,同时保留直接拼写与真正 RECORD.TXT 别名的对照。

我的整体评价 / Verdict

REQUEST_CHANGES。 解析选中名字所属的真实目录项后再比较索引。保留大小写、Unicode 和 8.3 真别名,并在无法解歧时使用已有的不可用结果。

操作者照常完成写回,但可能从外部索引变动看到与自己选定材料不符的诊断。 无关暂存项会让已绑定文件的状态带上虚假的变化,降低连续进展判断的可信度。

English verdict: REQUEST_CHANGES. Resolve the selected directory entry before matching Git index records. A real case alias for an untracked hard link still observes a different tracked entry's staged-only change.

A case alias of an untracked hard link shared its file identity with the
tracked entry and picked up that entry's staged change. The alias is now
resolved to the directory entry it opens before index entries are matched.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>
@xiaobaifly7

Copy link
Copy Markdown
Contributor Author

Addressed the P2: a selected name that its directory does not list (a case, Unicode or 8.3 alias) is now resolved to the directory entry it actually opens, and an index entry is matched only if it opens that same entry. Sharing a file identity alone (a hard link) no longer counts. When several hard-linked entries cannot be told apart by caseless name, capture fails with the existing capture_identity_unavailable.

Regression: test_case_alias_of_a_hard_link_ignores_the_other_entry selects SELECTED.TXT for an untracked selected.txt hard-linked to tracked record.txt, stages a change to record.txt, and expects an unchanged index digest. It fails before the change and passes after. packages/loopx-jev/tests/test_drift_capture.py: 113 passed, 2 skipped on native Windows (NTFS, case-insensitive). APFS was not run locally.

@loopx-agent loopx-agent 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.

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning effort: max

未发现阻断问题;以下结论仅对应 head f2cb0aca7042ce44c07ad3e549f2f49cdf6c3abd。

动机 / Motivation

使用可选 Jev 观察器、通过所选文件观察 refresh-state 的维护者,会在 Windows 遇到不支持的文件原语,并可能在大小写别名下漏掉索引变化。

同一文件以 RECORD.txt 被选中而索引保存 record.txt 时,工作文件不变、只更新索引:基线返回 no_delta,当前头返回 index_only_change_unknown。

当前头在真实刷新后保留索引变化的未知状态,同时把另一独立硬链接的索引变化留在范围外;捕获失败后仍能重建基线并继续排队。

本次不安装发行包、不调用模型、不启用宿主自动观察,也不授予观察器调度或干预权。

判据来自变更前的 packages/loopx-jev/DRIFT_SHADOW.md,不可变修订 04958a89abbbf6b7d3f79327437e2d6deae97453:JEV-SCOPE(明确文件范围及拒绝逃逸)、JEV-INDEX(索引变化保留未知)、JEV-FAIL(有界、稳定和失败隔离)、JEV-OFF(关闭及无自动出站)。Windows 支持是本 PR 明确扩展的边界,不能用改后的说明自证平台资格。

改动思路 / Approach

沿用已有捕获、事件和 Core 刷新 owner。POSIX 继续使用 O_NOFOLLOW;Windows 在读取前固定父目录句柄,核对打开对象身份,再按句柄的规范路径检查范围。对未来文件,先检查最深已有祖先加完整剩余后缀,不能先把 Git 元数据别名当作普通缺失文件。

索引匹配区分“同一目录项的别名”和“同一 inode 的另一硬链接”。先隔离继承的 pathspec 模式,用 literal 查询,再对真实别名补齐索引身份;不把整个索引内容当作模型输入。下表是实际 CLI 差分,基线与当前头使用相同输入;旧捕获器对照只替换捕获模块,不代表重审旧 PR。

输入 对照 当前头
RECORD.txt / Unicode 别名,只有索引 blob 变化 基线 no_delta index_only_change_unknown
SELECTED.TXT 指向独立硬链接,另一条目索引变化 前一捕获器误报索引变化 no_delta
二进制输入后恢复文本并再次编辑 原 Core 继续成功 capture_failed → baseline_reset → queued

具体改动 / Changes

_windows_capture(drift_capture.py:178)负责句柄、身份、规范祖先和有界读取;_index(:327)负责 Git 记录与真实目录项对应;capture(:409)保留平台分支和前后稳定性校验。原有 drift_cli.refresh(:36)仍负责保持 Core 的 stdout/退出码与观察失败隔离,实际调用已验证。

六个文件均已读完:运行代码、818 行边界测试、协议测试的平台适配、英中文档及可选包 lock。锁文件只锁可选发行包依赖,没有引入默认安装或新控制面。测试覆盖 reparse/身份/共享冲突错误边界;本机模拟调用不能替代 NTFS 原生证明。

验证:完整 Jev 包 141 passed、67 skipped;真实 init/refresh/drain/status 覆盖五种名称、独立硬链接、无出站、默认 off、拒绝元数据/外部链接和恢复后再次排队。前一捕获器 c1da16e01506e6a3dc68c95a4d2844930382b76f 在相同硬链接别名输入下确实误报,当前头通过。repository premerge 的 5 个直接检查通过,未选择 catalog smoke;精确范围 change-quality receipt 为 pass,9 个提交的 DCO trailer 及 RFC 双语 diff 检查通过。

对主干的风险 / Risks

主要风险在 Windows 文件共享/规范路径 API 和别名时的全索引遍历成本。固定句柄的释放集中于 ExitStack;失败返回观察不可用,原工作流继续。POSIX 普通文件、独立硬链接、缺失/新建文件和关闭路径的实际差分保持预期,没有新状态机、配置项或调度义务。与已获取 main 的 merge-tree 比较无冲突;这不等于已运行合入后的发行包。

本轮没有原生 Windows 主机;67 个条件用例跳过,作者提供的 NTFS 结果仍按作者证据看待。受限 ACL、网络共享、大索引成本及已安装发行包未在本轮验证。未查询或等待远端 CI。首轮探针中相同未绑定刷新内容产生重复事件,随后以每例独立 classification 重做完整流程;保留原记录,没有把 duplicate_event 当作恢复成功。

我的整体评价 / Verdict

当前实现关闭了本轮复现的别名漏报和独立硬链接误报,并通过实际多次刷新证明失败后的恢复仍能继续产生有效观察。保留原 wrapper/状态 owner,新增原语限于文件系统适配层,规模与已证实边界相称;没有再建立缓存或平行判定存储。此前 repository experience 的首次使用/恢复建议已用于实际 CLI 验证,旧阶段验收和旧结论没有移植为本轮通过。

检查了 drift CLI 与可选捕获包:本次没有渲染页面变化,无需截图。 无视觉展示验证范围;原生 Windows 属运行验证缺口。

APPROVE;平台验证限制如上,审批结论与合入、安装或发布权限分别处理。

English verdict: APPROVE — head f2cb0aca7042ce44c07ad3e549f2f49cdf6c3abd. Alias/index and hard-link counterfactuals, failure recovery, full Jev tests and local premerge pass; native Windows and installed-release qualification remain unverified.

@huangruiteng
huangruiteng merged commit c757f41 into loopx-project:main Nov 17, 2026
27 of 36 checks passed
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.

3 participants