Skip to content

refactor(toplevel): bind _WIN_FILE_SHARE_READ once in platform_compat - #19860

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
refactor/simplify-toplevel
Oct 13, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
refactor/simplify-toplevel

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Make platform_compat.py bind the read-only Windows share-mode constant once, at its documented first assignment, and take it out from under a heading that says only win_open_no_reparse uses it, with no change to any Windows open.

src/kiro_crew/platform_compat.py assigns _WIN_FILE_SHARE_READ = 0x00000001 at module scope twice. The first assignment sits among pin_directory's CreateFileW arguments, under its own comment on what the read-only share mode buys a deny_write open. The second sits in a block headed "CreateFileW arguments only win_open_no_reparse uses", which is not true of it: _win_open_without_following reads it too.

Why it matters

Nothing is broken today: both assignments carry the same value. But the later one is the binding that wins at import, so an edit to the first, documented assignment would be silently overridden, and the heading over the second tells a reader the constant has one caller when it has two.

Not a goal

  • Changing any CreateFileW access mask, share mode, disposition or flag.
  • The first assignment's own comment, which states the deny_write rationale and stays as it is.
  • The heading over pin_directory's CreateFileW arguments, which already covers constants pin_directory itself never passes (_WIN_GENERIC_WRITE, _WIN_FILE_SHARE_READ).
  • The file's other Windows constant blocks, such as _WIN_FILE_SHARE_READ_WRITE_DELETE.
  • Any other module.

What changed (motivation → approach → change)

No Windows open gets a different argument.

Before After
_WIN_FILE_SHARE_READ = 0x00000001 assigned twice in platform_compat.py assigned once, at the first assignment, which carries the constant's own comment
the win_open_no_reparse block's comment says "read-only sharing" under an "only win_open_no_reparse uses" heading that also covered _WIN_FILE_SHARE_READ the block keeps _WIN_FILE_LIST_DIRECTORY and _WIN_OPEN_ALWAYS, which only win_open_no_reparse reads, and its comment points at the definition above for the share mode

Both readers, _win_open_without_following and win_open_no_reparse, are function bodies that look the name up at call time, so each still gets 0x00000001.

Backwards compatibility

Compatible: the module still binds _WIN_FILE_SHARE_READ to the same value before any function that reads it can run.

Removes nothing: the name stays bound, only its duplicate assignment goes; no test, doc or script names the constant.

Tests

No new tests: no value, branch or call changes.

  • Static gates (Python 3.12), on the rebased commit. All exit 0: flake8, isort, mypy, check_black_formatting.py, check_subprocess_encoding.py, check_sync_io_in_async.py, check_agent_sdk_boundary.py (these four scope origin/main...HEAD and each saw the one changed file), check_comment_history.py, check_brand_name.py and check_harness_parity.py (base ref set to the merge-base), docs_lint.py --test, docs-lint.sh, check_per_file_coverage.py --test and verify_vendor_manifest.py.
  • Tests. 41 files, every one across both testpaths (test/ and src/kiro_crew/apps/builtins) that names a reader of the constant or a function that reaches one (_win_open_without_following, win_open_no_reparse, open_file_no_reparse, open_create_no_reparse, pin_directory), plus every test_platform_compat*.py: 4846 passed, 0 failed. This host's parity venv lacks markdown-it-py, so that run added it on PYTHONPATH. Both readers are Windows-only, so these runs show the module imports and the code around the change is untouched, not the Windows opens themselves; the review below covers those.
  • Not run locally. scripts/scrub-lint.sh is not in the checkout; that scan is CI's internal-content-scan job. semgrep is not installed here, so CI's SAST job is the only run of semgrep/. The diff touches nothing under website/, .github/ or scripts/, so CI reports only_backend=true.
  • Pre-PR review. Seven read-only reviewers looked at this before it opened. Their lenses were AUTOSDE rules plus the code-review.yml greps, behaviour preservation, binding semantics, the security keystone and boot path, comment and claim accuracy, and local mirrors of the GPT and Opus CI lane contracts. The GPT mirror ran on a Claude model, because no GPT model is available locally. None found a defect in the changed code. The behaviour reviewer deleted the one assignment from the base AST and got the head AST exactly, and found every nested code object byte-identical. The security reviewer captured the CreateFileW arguments of both readers on all four branches (deny_write on and off, file and directory) under a stubbed kernel32: identical before and after, with FILE_SHARE_DELETE absent from every share mode. Independent refuters then checked every remaining point. Taken: four wording fixes to this description (the Goal, the test-file count and set, which gates ran on the commit, and what an import can show). Dropped: a proposal to fence platform_compat.py as a keystone security file (its no-follow helpers carry no policy; the callers make the decision, and no detector site there would be excluded), and a claim that the edited block's heading also covers _WIN_FILE_ATTRIBUTE_TAG_INFO (that constant carries its own #: comment).

Manual verification

N/A — unit coverage sufficient: the change deletes an assignment that re-bound a module constant to the value it already had. An AST parse of the changed module finds one module-scope assignment to _WIN_FILE_SHARE_READ where the base has two, and importing it still binds the name to 0x1.

Screenshots / video

Why no screenshot: backend-only removal of a duplicate constant assignment; nothing renders differently.

Related Issues

Part of #16523

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners October 13, 2026 18:05
@bolichen97
bolichen97 requested a review from mbriones98 October 13, 2026 18:06
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 13, 2026
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of b18b564be42ad08cefc2a7e1461b7e35872bcec0 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Nothing to check.

[DESIGN-REVIEWED] b18b564

Description read

[DESCRIPTION-READ] aa6878606eb2fbcbf32c0830a0b297e8731f554ba37cd5bc902b068359eefe42

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision b18b564be42ad08cefc2a7e1461b7e35872bcec0 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of b18b564be42ad08cefc2a7e1461b7e35872bcec0 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Nothing to check.

What this change ships

Inventory (2 items) — 2 justified

Intent: keep one binding of a Windows share-mode constant so that editing the documented assignment actually takes effect. This is a FIX (refactor, no behaviour change).

  1. The second assignment of _WIN_FILE_SHARE_READ is gone, so the first one at platform_compat.py:7793 is the only binding. Both readers (lines 8211 and 8372) are function bodies and still resolve to 0x1. — justified
  2. The win_open_no_reparse block comment now points to the earlier definition instead of implying it owns the constant. — justified

[FIRST-PRINCIPLES-REVIEWED] b18b564

Description read

[DESCRIPTION-READ] 81600a71d456287dbf3a1da6d2621d18eed4e6c9e8a42f64354529ae5dbba72d

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of b18b564be42ad08cefc2a7e1461b7e35872bcec0 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] b18b564

False positive or not applicable? A repository writer can comment:
/ai-review override gpt b18b564be42ad08cefc2a7e1461b7e35872bcec0: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed b18b564be42ad08cefc2a7e1461b7e35872bcec0 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] b18b564

Verdict parsed from the review's SHA-scoped output markers for commit b18b564be42ad08cefc2a7e1461b7e35872bcec0.

False positive or not applicable? A repository writer can comment:
/ai-review override fable b18b564be42ad08cefc2a7e1461b7e35872bcec0: <one-sentence reason>

platform_compat.py assigned _WIN_FILE_SHARE_READ = 0x00000001 at module
scope twice. The first assignment sits among pin_directory's CreateFileW
arguments, under its own comment on what the read-only share mode buys
a deny_write open. The second sat in the block headed "CreateFileW
arguments only win_open_no_reparse uses", re-binding the same value
under a heading that was not true of it: _win_open_without_following
reads it too.

Drop the second assignment and point that block's comment at the
definition above. Both readers are function bodies that resolve the
name at call time, so each still sees 0x00000001.
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 13, 2026
@bolichen97
bolichen97 force-pushed the refactor/simplify-toplevel branch from f6ede9c to b18b564 Compare October 13, 2026 18:45
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/dashboard_templates/instance.py since this head went green (ac8a96a -> cf3c385); CI re-running.

The overlap is import-only: instance.py imports open_create_or_existing, release_lock and try_acquire_lock from platform_compat, none of which reads _WIN_FILE_SHARE_READ. Before this push, the rebased head b18b564be4 passed every static gate again, plus 72 test files: the 41 from the description and the 31 that import kiro_crew.dashboard_templates (6520 passed, 0 failed).

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 13, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Green age on b18b564be4: main gained 2 commits (cf3c385ce8 -> 3751ed36ad: #19748, #19878) that green_age.py classes as same-dir overlap only, because they edit src/kiro_crew/dashboard_frame.py and src/kiro_crew/subagent.py beside this PR's src/kiro_crew/platform_compat.py. Neither commit touches platform_compat.py or names _WIN_FILE_SHARE_READ.

Not re-pushing for it: the top-level package gains commits faster than a CI round finishes, so a re-sync on every same-dir hit there would not converge. Instead, this commit was cherry-picked onto 3751ed36ad in a scratch worktree, and 52 test files passed there (5326 passed, 0 failed): the 41 from the description, the test files those two commits changed, and every test naming dashboard_frame. The scratch worktree is removed; the branch head is unchanged.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 13, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) October 13, 2026 20:06

@KiroCrewCaptain KiroCrewCaptain 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.

Tier 1 auto-approve: refactor (1 file). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: removes a duplicate _WIN_FILE_SHARE_READ definition in platform_compat.py; the earlier definition in the same module has the same value (0x00000001), so behaviour does not change.

@KiroCrewCaptain
KiroCrewCaptain merged commit 852618b into main Oct 13, 2026
102 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the refactor/simplify-toplevel branch October 13, 2026 20:07
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 13, 2026
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.

2 participants