Skip to content

fix: open members through the held descriptor at the by-name sites - #40258

Merged
KiroCrewCaptain merged 3 commits into
mainfrom
r17-l4-byname-sites
Nov 21, 2026
Merged

KiroCrewCaptain merged 3 commits into
mainfrom
r17-l4-byname-sites

Conversation

@chenmingwei23

Copy link
Copy Markdown
Contributor

R17 landing round 2, L4 of 2, from feature/member-folder-hardening (#40203)

Problem / Motivation

Goal: A crewmate's notes are written into the member folder that was opened and checked, not into whatever the name members points at a moment later.

The member folder is opened once and held (open_member_folder), so a link at members is read once and nothing looks the name up again. Four places outside it still named members as a string (members_root().resolve() or members_root() / slug). The notes writer was the one that also wrote behind that name: it resolved the link, then made and pinned folders by name.

Why it matters

A members link that is re-pointed between the lookup and the write sends a member's notes into a folder that was never checked. The other three places write nothing behind the name, so they are marked as such where they sit, with tests that show it.

Not a goal

  • No change to what open_member_folder accepts or refuses.
  • No change to callers of the member_dir path helper (see Sibling sweep).
  • A members link that leads into a folder inside the data home (a separate follow-up).

What changed (motivation -> approach -> change)

Symptom: write_member_notes called members_root().resolve(), then makedirs, mkdir and a pinned open of the resolved path. Cause: the name was resolved to a path and every later step used that path. Change: it opens the member folder through open_member_folder(slug) and writes the briefing by descriptor in that held folder. The refusal of a non-plain file at the briefing name and the owner-only atomic write with fsync are kept.

This is the same content as squash commit 6b4fbd5 (#40203) for its 5 files, as two commits: the test first (red on main), then the source.

Decision per site:

Site Reads or writes Route
member_notes.write_member_notes writes through open_member_folder (code change)
eventlog/service.py _remove_legacy_activity unlinks declared: already holds members first and refuses a link there; marked, tested
members_parts/member_space.py member_dir none (builds a path) declared read-only, tested
members_parts/prompt_layers.py _briefing_pinned_target none (feeds a read) declared read-only, tested

1 routed site, 3 declared sites.

Backwards compatibility

Compatible: a normal members folder, and a members link to a folder outside the data home, still take notes as before. A link to the data home or a folder above it is now refused with notes_unwritable, as open_member_folder already refuses it for the other member files.

Reader: src/kiro_crew/dashboard/handlers/member_goals.py:805 write_member_notes -- dashboard notes save -- unchanged signature and error codes; covered by test/test_member_notes.py and test/test_member_message_notes.py.

Tests

New test/test_members_root_by_name_sites.py: the notes writer never resolves the members link by name and writes into the folder it opened; the legacy activity cleanup removes nothing behind a linked members; member_dir and the briefing read leave the tree unchanged under a linked members.

Red on main (test commit 50cb8f7 on origin/main c356f78, only this file): 1 failed, 3 passed.

FAILED test/test_members_root_by_name_sites.py::test_the_notes_writer_does_not_resolve_the_members_link_by_name - AssertionError: the link at members was resolved by name
1 failed, 3 passed

Green at the head (d829dbb): test_members_root_by_name_sites.py, test_member_notes.py, test_member_message_notes.py: 43 passed. black --check on the 5 files: unchanged.

Proof: PROVEN test_the_notes_writer_does_not_resolve_the_members_link_by_name (head d829dbb)

Manual verification

N/A -- unit coverage sufficient: every changed path is a file operation the tests drive.

Real-machine verification

N/A -- no installer, service or platform behaviour changes; the change is file operations under a temporary data home.

Sibling sweep

Swept: git grep -n "members_root()" -- src/
Sibling: src/kiro_crew/member_notes.py -- changed here
Sibling: src/kiro_crew/eventlog/service.py -- not affected -- it pins members first and refuses a link
Sibling: src/kiro_crew/members_parts/member_space.py -- not affected -- member_dir only builds a path
Sibling: src/kiro_crew/members_parts/prompt_layers.py -- not affected -- the briefing path feeds a read

Follow-up, not changed here: mate_upgrade_notice.py (_claim) and dashboard/mate_welcome.py:250 still write under the path member_dir returns, so they still reach members by name.

Pattern harvest

Not generalizable: the defect is a name used after it was checked at one write site; a lint cannot tell a writer from a reader of the same helper.

Checklist

  • A Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...); PR Hygiene does not count commits
  • 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

Red on main: the notes writer resolves the members link by name
(1 failed, 3 passed in test/test_members_root_by_name_sites.py).
write_member_notes now writes through the held members descriptor; the
legacy activity cleanup, briefing read and member_dir helper are declared
by-name sites.
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 21, 2026
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 71a71d1abebe79218a232b182df4c32890bf7e9f — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing to check. This is a backend-only change to member-notes file handling; it changes no website/ code and no user-facing strings, and the dashboard notes save keeps its existing notes_unwritable error code.

[UX-REVIEWED] 71a71d1

Description read

[DESCRIPTION-READ] 19abbbcbf5202b124dd24a1bd6ed2ccd5a6ba32e330c3bd75cfa1eb958370105

That sha256 names everything this verdict read: the PR description, plus the 3 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 Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 71a71d1abebe79218a232b182df4c32890bf7e9f — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the one site that writes now goes through the folder that was opened and held, and the other three are read-only, which the tests check.

Notes

  • The description's follow-up already names the remaining writers that reach members by name: mate_upgrade_notice._claim and dashboard/mate_welcome.py:250. Route them the same way rather than adding more comments that say a site is read-only.

[DESIGN-REVIEWED] 71a71d1

Description read

[DESCRIPTION-READ] db5bbc7afdef2023ee81ea2a9009c97645ad4476497b476f1dc828b0f08c9541

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 Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 71a71d1abebe79218a232b182df4c32890bf7e9f — 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 does not.

First-Principles-Verdict: PASS

The notes writer now writes through the folder it opened and checked. Nothing blocks. The fix leaves writers that still go through member_dir by name, and one of them is not in the description's follow-up list.

Notes

  • Item 1 — symptom-level sibling: the PR names only mate_upgrade_notice.py and mate_welcome.py:250 as later work. Grepping member_dir\( in src also finds eventlog/service.py:541, where _retire_legacy_activity renames under member_dir(slug). That makes 4 write call sites in 3 files, and the description never names this one.
  • Item 6 — undeclared: the patch also contains feat(dashboard): remove a not-done milestone from the conductor mode list #40213's milestone Hide feature (the component, its test, 15 locale files, crew-mode.md, work-ledger.md). That feature is already on main as cbffcd8. Nothing in the intent mentions it, so it is not this PR's change and was not judged.

What this change ships

Inventory (6 items) — 4 justified

Intent: notes for a crewmate land in the folder that was checked, even if the members link is re-pointed. FIX.

  1. Saving notes uses the held members folder and no longer re-resolves the link by name — justified
  2. A members link to the data home or a folder above it now refuses notes with notes_unwritable — justified
  3. The legacy activity cleanup is marked as holding members first — justified
  4. member_dir and the briefing read are marked read-only — justified
  5. New test file pins the four sites — rides along
  6. The milestone Hide feature (feat(dashboard): remove a not-done milestone from the conductor mode list #40213) appears in the patch — undeclared, already on main

[FIRST-PRINCIPLES-REVIEWED] 71a71d1

Description read

[DESCRIPTION-READ] 52a3c3b158bc39b4b6aa952f766cc628bd7c0bf57819ba8b4ec509321bcae5e1

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 Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 71a71d1

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 71a71d1abebe79218a232b182df4c32890bf7e9f false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 71a71d1

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 71a71d1abebe79218a232b182df4c32890bf7e9f false-positive: <reason, 20 to 500 characters>

Comment-only: the module docstring names the four sites in the present tense.
@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 Nov 21, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider estimates a 10% chance that this change introduces a defect, within the 12% limit for approving on its own, but it is held at tier pending: being reviewed.

write_member_notes now writes through the folder that open_member_folder opened and holds, instead of resolving members by name. Every failure before the folder is handed back becomes MemberSlugError, which is mapped to notes_unwritable, so the error codes are unchanged. The refusal of a link or non-plain file at the briefing name and the owner-only write with fsync are kept, and folder handles are closed on every path. Existing notes tests still hold. The new test fails on main and passes with the change. The other three sites only gain accurate comments. No regression or data-loss path found; approve.

Tier: pending: being reviewed.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit 71a71d1abe · 190 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 21, 2026 03:45

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

Reviewed on head 71a71d1. The only runtime change is in write_member_notes. It now writes the briefing by descriptor inside open_member_folder(slug) and no longer resolves members by name. Every failure before the folder opens maps to the same notes_unwritable error as before. The 0o700 folders, the owner-only fsync'd atomic write and the refusal of a non-plain briefing file are unchanged. The one caller still runs the save off the event loop and catches only NotesError. The new spy test fails on main and passes at the head. All existing test_member_notes.py cases pass at the head. The other three files change only comments.

Security: this narrows a write path and does not widen one. Some members link setups that main followed are now refused. No sandbox, governance or auth code changes.

Done well: the fix deletes the hand-rolled resolve, makedirs and pin sequence and its manual os.close bookkeeping, and reuses the existing open_member_folder instead of adding a third pinning routine.

Optional:

  • The new member_dir docstring and the test module docstring say every writer under members uses open_member_folder. That is not true yet: mate_upgrade_notice.py, dashboard/mate_welcome.py:250 and eventlog/service.py:541 (_retire_legacy_activity) still write by name. Saying that they are follow-ups would be accurate. The eventlog site is also missing from the follow-up list in the body.
  • No test checks the result of the declared behaviour change. A test that makes members a symlink to the data home and expects NotesError("notes_unwritable") with nothing created behind the link would catch a revert that does the path lookup with os.path.realpath. The current spy only catches Path.resolve.
  • A dangling members link is now refused too. One line under Backwards compatibility would record it.

@KiroCrewCaptain
KiroCrewCaptain merged commit 5001aea into main Nov 21, 2026
101 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the r17-l4-byname-sites branch November 21, 2026 03:45
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 21, 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