Skip to content

refactor(session-flow): share the plugin data-root rule with save_point - #17391

Merged
kyle-sexton merged 2 commits into
mainfrom
refactor/17383-shared-plugin-paths
Nov 19, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
refactor/17383-shared-plugin-paths

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Refs: #17383

Summary

Problem: the session-flow plugin data-root rule existed in two places, save_point.py and the shared plugin_paths.py, and an agreement test existed only to keep them in step. Now save_point.py calls plugin_paths.data_root, the same function away.py uses, so only one implementation of the rule remains.

census.py is left unchanged. It has no data-root rule: its data dir comes from the required --data-dir argument. Its only overlap with plugin_paths.py is write_atomic. census.py is also listed in COLLECTOR_INPUTS in collect.py, so any edit to it re-ingests every stored session. Since this refactor must not change behavior, that is out of scope here.

Fix

  • save_point.py: removed _plugin_data_root. _default_memory_dir now calls plugin_paths.data_root(os.environ, _SCRIPTS_DIR.parent).
  • test_save_point.py: the fake cache install now copies plugin_paths.py along with the other scripts.
  • test_plugin_paths.py: dropped test_matches_save_point_rule. Once both scripts call the same function, it can no longer fail.
  • reference/structure.md: the verification record now names plugin_paths.py data_root.
  • Changelog fragment: bump: none.

Verification

  • uvx --with pytest pytest plugins/session-flow/scripts/tests -q: 540 passed. The baseline before the change was 544; the difference is the 4 deleted parametrized cases.
  • scripts/run-ruff.sh check on the three changed Python files: all checks passed.
  • Pre-push check-affected: passed.
  • Left out: the audit-sessions and audit-friction suites, since census.py and its tests are unchanged.

Related

N/A

Remaining

  • census.py importing from plugin_paths.py: there is no data-root rule in it to switch. The only possible change is to delegate its write_atomic. Because census.py is a collector fingerprint input, that would re-ingest every stored session once, and it would add the shared version's fsync. The owner decides between that change and treating the issue as delivered by this PR.
  • The census tests' fixed script lists (test_collect.py) only need plugin_paths.py if census.py imports it.

🤖 Generated with Claude Code

kyle-sexton and others added 2 commits November 19, 2026 01:31
save_point.py now resolves its fallback memory dir through
plugin_paths.data_root, the rule away.py already uses, so one
implementation of the data-root rule remains. The cache-install test
copies plugin_paths.py into the fake plugin tree, and the agreement test
that kept the copies in step is gone.

census.py is unchanged: it holds no data-root rule (its data dir is the
required --data-dir argument), and it is a collector fingerprint input,
so editing it would re-ingest every stored session.

Co-authored-by: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 19, 2026 06:35
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T06:41:32.579390Z 6a8c72a Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 6a8c72a58bdfc7c7c945d9695bc7687b8644e130: read 5 of 5 changed file(s); 0 finding(s), 0 as inline comments.

No findings. This is a code-review pass over all 5 changed files at 6a8c72a5.

The PR removes save_point._plugin_data_root and has _default_memory_dir call the shared plugin_paths.data_root(os.environ, _SCRIPTS_DIR.parent) instead.

Behavior is unchanged (checked by reading the code, not by running it).

  • The removed body is the same as plugin_paths.data_root line for line:
    • the same session-flow / session-flow- segment test on CLAUDE_PLUGIN_DATA;
    • the same cache-layout walk;
    • the same id sanitising.
  • The old code used _SCRIPTS_DIR.parent as version_dir, and that is the argument now passed.
  • The plugin_root is None branch in the shared function is never reached from save_point.py.

No caller is left behind.

  • No remaining references to _plugin_data_root exist in session-flow.
  • tidy_work.py reaches the new import through save_point.py's existing sys.path insert of its own scripts dir.
  • _install_in_cache is the only test that copies save_point.py into a fake cache layout, and it now also copies plugin_paths.py.

Coverage stays in place.

Loosened-check criterion.

  • I considered kind 1 (a test deleted) for test_matches_save_point_rule and decided it is not a loosening:
    • the only thing the test compared was two implementations, and one of them is now gone;
    • away.data_root is an alias of plugin_paths.data_root (away.py#L208);
    • every input it used is still asserted against the shared function, so the suite accepts nothing it rejected before.
  • The prompt had no loosened_check_verdict: or loosened_check_patterns: line, so I used fail with no consumer entries.
  • It had no loosened_check_decision_record: line, so I did not check the citation requirement.
  • Loosened-check verdict: fail (default, no wrapper lines); patterns: 0

Closing issue. The PR context file has no closing-issue section: the PR says Refs: #17383 and does not close it. So I had no acceptance criteria to check. The PR body's "Remaining" section leaves the census.py question to the owner.

Other checks.

  • No plugin manifest changed. The changelog fragment's bump: none fits a refactor that changes no behavior.
  • No changed file matches a trusted-path glob.
  • No embedded instructions were found in the PR context.
  • I did not run the tests. The 540-passed count and the ruff result are the author's claims.

Verifier dropped 0 of 0 candidates.

@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 6a8c72a58bdfc7c7c945d9695bc7687b8644e130: read 5 of 5 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #17391, head 6a8c72a

I found no security issues.

What changed. save_point.py no longer has its own _plugin_data_root. It now calls the shared plugin_paths.data_root(os.environ, _SCRIPTS_DIR.parent). The rest of the PR is a test cleanup, a one-line doc pointer update in reference/structure.md and a bump: none changelog fragment.

What I checked.

  • The rule is unchanged. I compared the shared function with the deleted code (plugin_paths.py#L35-L49) and found the same logic, line by line:
    • CLAUDE_PLUGIN_DATA is used only when its last path segment is session-flow or starts with session-flow- (PLUGIN_NAME = "session-flow", L30).
    • Otherwise the directory is derived only from the plugins/cache/<marketplace>/<plugin>/<version> layout, with the same [^A-Za-z0-9_-] replacement in the plugin id.
    • Any other layout still returns None. The plugin root passed in is _SCRIPTS_DIR.parent, the same version dir the old code used.
    • So the check that ignores a data dir exported by another plugin's hook is neither narrowed nor widened, and the path where artifacts are written does not move.
  • The new import is safe. plugin_paths.py sits beside save_point.py, which already puts its own scripts dir first on sys.path. The module uses only the standard library and does nothing when imported except define constants, so no new code reaches the load path.
  • The deleted test can no longer fail. test_matches_save_point_rule only compared the two implementations. With one implementation left, there is nothing for it to compare, so its removal takes no coverage away from the data-root rule itself.
  • No standing instruction or trust control is touched. The PR changes no manifest, no workflow and no trusted path, and it deletes or softens no instruction.

critical-findings: 0

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit f26b703 Nov 19, 2026
117 of 120 checks passed
@kyle-sexton
kyle-sexton deleted the refactor/17383-shared-plugin-paths branch November 19, 2026 07:29
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant