Skip to content

feat(issue): wire filesystem IPC and skill integration for duplicate-picker pane (part 2 of #2075) - #2080

Open
Kaap10 wants to merge 7 commits into
apache:mainfrom
Kaap10:feat/issue-duplicate-picker-pane-pr2
Open

Kaap10 wants to merge 7 commits into
apache:mainfrom
Kaap10:feat/issue-duplicate-picker-pane-pr2

Conversation

@Kaap10

@Kaap10 Kaap10 commented Nov 15, 2026

Copy link
Copy Markdown
Member

Summary

  • Implements part 2 of feat(issue): interactive duplicate-picker pane mod for issue-deduplicate #2075: wires filesystem IPC, candidate file hydration, and skill workflow integration for the magpie-issue duplicate-picker pane mod.
  • In plugins/magpie-issue/hooks/duplicate-picker.ts:
    • Added hydrateCandidatesFromFile using $.fs.read to safely parse candidate payloads, update the reactive atom state, and open the interactive terminal pane ($.ui.open({ id: 'duplicate-picker', ... })) with fail-open safety.
    • Updated renderDuplicatePickerPane to render the target issue author (@${targetAuthor}) in the header, bound visible candidates to MAX_VISIBLE = 10 with an overflow notice box (... and N more candidate(s)), and stage maintainer curation decisions directly to .magpie-issue-decision-<target>.json via $.fs.write on curate, dismiss, and selection toggle-off.
    • Added handleBashToolCall middleware on tool.call ({ tool: 'Bash' }) to intercept commands referencing candidate or decision files, executing next(e) first and immediately hydrating the pane once written to disk.
    • Normalized author handles in parseCandidatePayload by stripping leading @ characters to avoid double-@ prefixes.
    • Added request filtering in ui.render (Pane) to cleanly delegate non-duplicate-picker pane render events to next(e).
  • In plugins/magpie-issue/hooks/duplicate-picker.test.ts:
    • Added 11 new unit tests covering target author rendering, handle normalization, MAX_VISIBLE truncation, $.fs.write decision staging, toggle-off invalidation, file hydration, tool call interception, and fail-open resilience (46 tests total, 100% pass).
  • In plugins/magpie-issue/skills/deduplicate/SKILL.md:
    • Added Claude Code fast-path for .magpie-issue-candidates-<target>.json and non-blocking .magpie-issue-decision-<target>.json intake.
    • Preserved Step 3 as the sole human-in-the-loop confirmation gate (zero autonomous GitHub mutations).
    • Added Step 4 session cleanup for temporary session files.
    • Preserved skill line count under the 500-line limit (489 lines, §15 compliant), updating surface_hash and measured_tokens.
  • In tools/spec-loop/specs/issue-management-family.md:
    • Updated line 192 describing part 2 connecting file hydration.
  • In docs/setup/secure-agent-setup.md:
    • Documented filesystem IPC boundaries, threat model, and human-in-the-loop contract with strict semantic line breaks.
  • In .gitignore:
    • Excluded temporary session artifacts /.magpie-issue-candidates-*.json and /.magpie-issue-decision-*.json.

Type of change

  • Skill change (.claude/skills/<name>/) — eval fixtures updated below
  • Tool / bridge contract (tools/<system>/*.md)
  • Python package (tools/*/ with pyproject.toml)
  • Groovy reference impl
  • Cross-cutting (RFC, AGENTS.md, sandbox, privacy-LLM)
  • Documentation (docs/, README.md, CONTRIBUTING.md)
  • Project template (projects/_template/)
  • CI / dev loop (prek, workflows, validators)
  • Other:

Test plan

  • claude plugin validate --strict plugins/magpie-issue passes (0 errors)
  • claude plugin test plugins/magpie-issue passes (46 passed, 0 failed across 1 file)
  • prek run static checks pass on all modified files (doctoc, add-license-headers, check-merge-conflict, detect-private-key, end-of-file-fixer, mixed-line-ending, trailing-whitespace, markdownlint-cli2, typos)
  • skill_and_tool_validator passes on deduplicate/SKILL.md (0 violations; line limit: 489 <= 500)
  • skill-surface-hash recomputed and stamped (sha256:859f50fc947cf377)
  • skill-token-count measured with offline_encoding() and stamped (measured_tokens: 5222)
  • spec-validate passes on tools/spec-loop/specs/issue-management-family.md (0 violations)

RFC-AI-0004 compliance

  • HITL — any new mutation is gated on explicit user confirmation (pane interactions only stage local .magpie-issue-decision-<target>.json; zero direct GitHub API calls or autonomous issue closures)
  • Sandbox — no new unrestricted host access; filesystem access is strictly bounded to .magpie-issue-candidates-*.json and .magpie-issue-decision-*.json in the workspace root
  • Vendor neutrality — placeholders (<PROJECT>, <tracker>, <upstream>, <security-list>) used in all skill / tool prose; terminal CLI prompt fallback preserved for non-Claude harnesses
  • Conversational + correctable — agentic-override path documented if behaviour is adopter-tunable
  • Write-access discipline — no autonomous outbound messages; drafts only, sent on confirmation
  • Privacy LLM — private content does not reach a non-approved LLM; redactor invoked where needed

Linked issues

Closes #2075 (completes part 2 of 2: filesystem IPC, candidate hydration, decision staging, and skill integration)

Notes for reviewers (optional)

@github-actions github-actions Bot added family:setup setup-* skills family:docs Docs, MISSION.md, READMEs family:ci .github workflows, prek, validators family:issue issue-* skills capability:resolve Close-out: invalidate, dedupe, CVE allocate, announcement family:dev Repo dev: .asf.yaml, spec-loop specs, Node manifests, .claude/settings.json labels Nov 15, 2026

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for wiring part 2 — the overall shape (file IPC, the pane stages and the skill confirms) is right, but the decision file isn't yet trustworthy: it can be written through a symlink, reset or reused stale, can drop candidates the maintainer never saw, and the pane may not open at all when the payload is written with the Write tool. Details inline.

writes refuse to follow paths that exist as symbolic links or non-regular files (plugins/magpie-issue/hooks/duplicate-picker.ts:88)

Because Claude Code mod hooks execute outside the container sandbox with user privileges, $.fs.write targets the host filesystem directly. [...] To prevent symlink traversal outside the intended directory, writes refuse to follow paths that exist as symbolic links or non-regular files.

await $.fs.write(decisionPath, JSON.stringify(decision, null, 2));

This write runs unsandboxed to a predictable path in the working tree. A symlink planted at .magpie-issue-decision-<N>.json (e.g. by a checked-out branch) redirects a pane click to overwrite any file the user can write. Mirror the review-findings mod (plugins/magpie-pr-management/hooks/review-findings.ts, the $.fs.stat / isSymbolicLink / isFile precheck) before writing.

Flagged by codex (adversarial review); cross-checked.

Candidates are only marked for closure upon deliberate maintainer action (plugins/magpie-issue/hooks/duplicate-picker.ts:657)

Candidates are only marked for closure upon deliberate maintainer action via interactive buttons ("Keep Target" or "Set as Kept").

const match = /\.magpie-issue-(?:candidates|decision)-(\d+)\.json/.exec(command);

Matching decision here means the skill's own decision intake (Step 1.4: cat / test -f .magpie-issue-decision-<N>.json) re-hydrates from the candidates file, and createStateFromPayload resets selectedKeptIssue and dismissedIssues. The pane then shows a blank selection while the file still holds the old one, and the next click rewrites the decision from scratch. Re-hydrate only on the candidates file (or skip when the atom already holds that target); the test at duplicate-picker.test.ts:511 asserts the current behaviour and should flip.

Flagged by both the primary and adversarial reviewers.

Candidates are only marked for closure upon deliberate maintainer action (plugins/magpie-issue/hooks/duplicate-picker.ts:396)

Candidates are only marked for closure upon deliberate maintainer action via interactive buttons ("Keep Target" or "Set as Kept").

const MAX_VISIBLE = 10;
const visibleCandidates = state.candidates.slice(0, MAX_VISIBLE);

The pane shows 10 candidates, but serializeDecision (line 270) builds dropped_issues from all of state.candidates. With 15 candidates, "Keep Target" stages candidates 11 to 15 for closure although the maintainer never saw them, and that pre-fills Step 2. Either cap the payload at parse time or restrict dropped to the rendered candidates.

Flagged by both the primary and adversarial reviewers.

Self-invalidation lifecycle (plugins/magpie-issue/skills/deduplicate/SKILL.md:293)

The curated JSON payload embeds the active PR number and the source findings file's SHA-256 digest in a metadata envelope. [...] Downstream CLI tools (render) validate the PR number and source hash directly before loading <file>.curated.json, ensuring stale, orphaned, or invalidated curation files are refused or bypassed.

4. If `.magpie-issue-decision-<target>.json` is present with `status: "curated"`
   or `status: "dismissed"`, load the staged decision to pre-fill Step 2.

Intake checks only presence and status. A decision left behind by an interrupted run (cleanup is only in Step 4) is reused for a later comparison of the same target, even when the candidate set differs. The docs at secure-agent-setup.md:2056 say "stale decision files are purged or bypassed", but nothing does either. Bind the decision to the comparison the way the findings mod does (e.g. a hash of the candidates file in the decision) and have Step 1.4 refuse a mismatch.

Flagged by both the primary and adversarial reviewers.

hooks('tool.call', { tool: 'Bash' }, handleBashToolCall) (plugins/magpie-issue/skills/deduplicate/SKILL.md:285)

hooks('tool.call', { tool: 'Bash' }, handleBashToolCall);

1. Write candidate payload to `.magpie-issue-candidates-<target>.json`

The only trigger is a Bash command whose text names the file; there is no Write-tool hook. An agent following "Write candidate payload" will normally use the Write tool, and the pane never opens. Step 2's "The mod intercepts the file via $.fs.read" also describes a watcher that does not exist. Either say the file must be created with a Bash command, or register a tool.call hook for Write as well.

Flagged by both the primary and adversarial reviewers.

Smaller observations

  • See inline comments on plugins/magpie-issue/hooks/duplicate-picker.ts:89, docs/setup/secure-agent-setup.md:2055, plugins/magpie-issue/hooks/duplicate-picker.ts:685, plugins/magpie-issue/skills/deduplicate/SKILL.md:277, plugins/magpie-issue/skills/deduplicate/SKILL.md:295.

This review was drafted by an AI-assisted tool and
confirmed by an Apache Magpie maintainer. After you've
addressed the points above and pushed an update, an Apache Magpie
maintainer — a real person — will take the next look
at the PR. The findings cite the project's review criteria;
if you think one of them is mis-applied, please reply on the
PR and a maintainer will weigh in.

More on how Apache Magpie handles maintainer review:
Contributing guide.

const decision = serializeDecision(state);
const decisionPath = `.magpie-issue-decision-${state.targetIssue}.json`;
try {
await $.fs.write(decisionPath, JSON.stringify(decision, null, 2));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

writes refuse to follow paths that exist as symbolic links or non-regular files

Because Claude Code mod hooks execute outside the container sandbox with user privileges, $.fs.write targets the host filesystem directly. [...] To prevent symlink traversal outside the intended directory, writes refuse to follow paths that exist as symbolic links or non-regular files.

This write runs unsandboxed to a predictable path in the working tree. A symlink planted at .magpie-issue-decision-<N>.json (e.g. by a checked-out branch) redirects a pane click to overwrite any file the user can write. Mirror the review-findings mod (plugins/magpie-pr-management/hooks/review-findings.ts, the $.fs.stat / isSymbolicLink / isFile precheck) before writing.

Flagged by codex (adversarial review); cross-checked.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added $.fs.stat prechecks to ensure the destination path is not a symbolic link and is a regular file before writing, mirroring the review-findings mod.

if (e && typeof e.command === 'string') {
try {
const command = e.command;
const match = /\.magpie-issue-(?:candidates|decision)-(\d+)\.json/.exec(command);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Candidates are only marked for closure upon deliberate maintainer action

Candidates are only marked for closure upon deliberate maintainer action via interactive buttons ("Keep Target" or "Set as Kept").

Matching decision here means the skill's own decision intake (Step 1.4: cat / test -f .magpie-issue-decision-<N>.json) re-hydrates from the candidates file, and createStateFromPayload resets selectedKeptIssue and dismissedIssues. The pane then shows a blank selection while the file still holds the old one, and the next click rewrites the decision from scratch. Re-hydrate only on the candidates file (or skip when the atom already holds that target); the test at duplicate-picker.test.ts:511 asserts the current behaviour and should flip.

Flagged by both the primary and adversarial reviewers.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removed decision from the regex so it only intercepts candidates files, and added a guard to skip re-hydration if the atom already holds that target.

// Candidate list
for (const c of state.candidates) {
// Candidate list (capped at MAX_VISIBLE)
const MAX_VISIBLE = 10;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Candidates are only marked for closure upon deliberate maintainer action

Candidates are only marked for closure upon deliberate maintainer action via interactive buttons ("Keep Target" or "Set as Kept").

The pane shows 10 candidates, but serializeDecision (line 270) builds dropped_issues from all of state.candidates. With 15 candidates, "Keep Target" stages candidates 11 to 15 for closure although the maintainer never saw them, and that pre-fills Step 2. Either cap the payload at parse time or restrict dropped to the rendered candidates.

Flagged by both the primary and adversarial reviewers.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Restricted dropped_issues in serializeDecision to only the visible rendered candidates (MAX_VISIBLE_CANDIDATES = 10), preventing unrendered candidates from being staged for closure.

interactive curation pane.
3. Maintainer clicks (*Set as Kept*, *Keep Target*, *Dismiss*, *Restore*)
stage their choice into `.magpie-issue-decision-<target>.json` via `$.fs.write`.
4. If `.magpie-issue-decision-<target>.json` is present with `status: "curated"`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Self-invalidation lifecycle

The curated JSON payload embeds the active PR number and the source findings file's SHA-256 digest in a metadata envelope. [...] Downstream CLI tools (render) validate the PR number and source hash directly before loading <file>.curated.json, ensuring stale, orphaned, or invalidated curation files are refused or bypassed.

Intake checks only presence and status. A decision left behind by an interrupted run (cleanup is only in Step 4) is reused for a later comparison of the same target, even when the candidate set differs. The docs at secure-agent-setup.md:2056 say "stale decision files are purged or bypassed", but nothing does either. Bind the decision to the comparison the way the findings mod does (e.g. a hash of the candidates file in the decision) and have Step 1.4 refuse a mismatch.

Flagged by both the primary and adversarial reviewers.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Bound the decision to the candidate set using a pure-TS SHA-256 hash (source_candidates_sha256), and updated Step 1.4 to bypass stale or mismatched decision files.

Under Claude Code with the `magpie-issue` mod active, the agent can
stage the comparison into an interactive side pane:

1. Write candidate payload to `.magpie-issue-candidates-<target>.json`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hooks('tool.call', { tool: 'Bash' }, handleBashToolCall)

hooks('tool.call', { tool: 'Bash' }, handleBashToolCall);

The only trigger is a Bash command whose text names the file; there is no Write-tool hook. An agent following "Write candidate payload" will normally use the Write tool, and the pane never opens. Step 2's "The mod intercepts the file via $.fs.read" also describes a watcher that does not exist. Either say the file must be created with a Bash command, or register a tool.call hook for Write as well.

Flagged by both the primary and adversarial reviewers.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Registered a tool.call hook for Write to intercept candidate writes and open the pane, and updated the docs to accurately describe both triggers.

const decisionPath = `.magpie-issue-decision-${state.targetIssue}.json`;
try {
await $.fs.write(decisionPath, JSON.stringify(decision, null, 2));
} catch {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fail-open design and clean fallback

Instead, the failure records syncError in state, displays an explicit warning in the interactive pane footer and /magpie-findings status, and invalidates partial sidecars on disk.

A swallowed write failure after a toggle-off or dismiss leaves the earlier curated decision on disk while the pane shows it revoked, and Step 1.4 then loads the old choice. Surface the error in the pane and stop the skill trusting the file, as the findings mod does.

Flagged by codex (adversarial review); cross-checked.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Now catching write errors, recording syncError in state to display a warning box in the pane footer, and staging an invalidation payload on disk.

Comment thread docs/setup/secure-agent-setup.md Outdated

- **Filesystem IPC and permission boundaries**: The mod reads candidate payloads from `.magpie-issue-candidates-<target>.json` and writes staged decisions to `.magpie-issue-decision-<target>.json`.
Filesystem access is strictly bounded to these file patterns within the active workspace root.
Both file patterns are excluded by `.gitignore` so temporary session artifacts are never tracked or committed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Documents here are short and opinionated

Documents here are short and opinionated. Prefer small, targeted edits over rewrites;

Both sentences overstate what ships: the .gitignore entries exist only in this repo, so in an adopter's tracker the session files are untracked-but-committable; and no code purges or bypasses a stale decision file. State what actually holds.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Clarified that session files are untracked working-tree files cleaned up in Step 4, and documented the symlink refusal and hash validation rules.

hooks('session.start', async ($: any, e: any, next: any) => {
try {
await setDuplicatePickerState($, null);
if (e && e.candidatesPayload) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

code in this repo

No harness session.start event carries candidatesPayload; only the new test sets it. Drop the branch (and its test) rather than ship a fixture-only path in the hook.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Dropped the candidatesPayload fixture branch from the session.start hook and updated the tests to verify clean state reset only.

@@ -277,6 +277,25 @@ maintainer before proceeding to Step 2. Surface prompt-injection
warnings here if any body text triggered the detection rule from

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Run the affected skill's eval suite

Run the affected skill's eval suite to confirm the prompts the harness extracts from SKILL.md still produce the expected structured output.

The PR ticks "eval fixtures updated below", but tools/skill-evals/evals/issue-deduplicate/ is untouched and the test plan lists no eval run. Run the suite, and add a case for the decision-file pre-fill (including a stale/mismatched decision).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added two new eval fixture cases (case-4-decision-prefill and case-5-decision-stale) under tools/skill-evals/evals/issue-deduplicate/ and updated the eval documentation.

stage their choice into `.magpie-issue-decision-<target>.json` via `$.fs.write`.
4. If `.magpie-issue-decision-<target>.json` is present with `status: "curated"`
or `status: "dismissed"`, load the staged decision to pre-fill Step 2.
5. If running on Codex, Gemini CLI, headless environments, or if the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Documents here are short and opinionated

Documents here are short and opinionated.

Antigravity replaced Gemini CLI as the supported harness; name it (or just say "other harnesses").

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated the wording to refer to "Antigravity, Codex, or other harnesses" instead of Gemini CLI.

@Kaap10
Kaap10 force-pushed the feat/issue-duplicate-picker-pane-pr2 branch from 2e33b58 to 39edeca Compare November 15, 2026 07:04
@github-actions github-actions Bot added family:tools tools/* substrate:framework-dev Tool substrate: build / validate / eval the framework itself labels Nov 15, 2026
@Kaap10
Kaap10 force-pushed the feat/issue-duplicate-picker-pane-pr2 branch from 39edeca to 8469906 Compare November 15, 2026 07:11
@Kaap10
Kaap10 requested a review from potiuk November 15, 2026 07:19

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for working through the first round. I pushed one fixup commit to your branch (f135cfb), so please pull before you push again.

What the fixup changes: the link check now reads the harness's stat shape

The check in safeWriteDecisionFile and invalidateDecisionFile looked for stat.isSymbolicLink() and stat.isFile(), which are Node's fs.Stats methods. The mod harness's $.fs.stat resolves a different shape, { kind, size, mtimeMs, isLink }, so neither probe ever matched. A link planted at .magpie-issue-decision-<N>.json, for example committed on a branch the maintainer has checked out, was written through. The tests passed because they mocked Node's shape, and $ is typed any, so nothing flagged the mismatch.

The new classifyWriteTarget helper:

  • refuses when isLink is true or kind is not file, which covers a link to a regular file, a link that leads nowhere, and directories or devices;
  • treats only ENOENT as "no file yet, safe to create", and refuses on any other stat failure, so the write fails closed;
  • does not use $.fs.exists, which answers for what the path leads to.

Both writes use it. The tests now mock the harness shape and add cases for a missing path, a dangling link and a failing stat. claude plugin test passes (63 tests).

The merged review-findings mod has the same mistake. I'll fix that in a separate PR.

Still open from the first round

  • Stale decision binding: the hash itself is correct, but SKILL.md never tells the agent which command checks it (e.g. shasum -a 256 .magpie-issue-candidates-<N>.json). The docs also refer to a "Step 1.4" that does not exist.
  • The decision is never used in Step 2: the skill deduplicates one pair given as arguments, while the decision carries kept_issue and a list of dropped_issues. Say how one maps onto the other, including a kept_issue that is neither argument, or more than one dropped issue.
  • The eval cases cannot fail: step-2-build-proposal/fixtures/step-config.json extracts only ## Step 2, but the decision-file logic is in Step 1, so the model never sees it. Also, case-4 and case-5 state the verdict in report.md ("Stale decision bypassed. The skill falls back to…"). Give the raw decision and candidates file, and let the model work it out. Please also record a run in runs.jsonl.
  • A pane left open goes stale: when the candidates file is rewritten for the same target, the re-hydration skip keeps the old candidates and the old hash. Every click then writes a decision the skill ignores, while the pane still shows "curated". Re-hydrate when the file's hash changes, not only when the target changes.
  • Docs overstate: secure-agent-setup.md says the files are "strictly bounded … within the active workspace root", but the Write hook accepts any absolute path whose name matches. In the same case the decision write uses a relative name, so every click then fails with "Candidate file missing". Normalise to the working directory, or say what actually holds.
  • Nits: with more than 10 candidates, deriveStatus can never reach "dismissed" (it checks every candidate, not the visible ones). The spec paragraph in issue-management-family.md names the target and candidates twice and does not mention the decision file.

This review was drafted by an AI-assisted tool and
confirmed by an Apache Magpie maintainer. After you've
addressed the points above and pushed an update, an Apache Magpie
maintainer — a real person — will take the next look
at the PR. The findings cite the project's review criteria;
if you think one of them is mis-applied, please reply on the
PR and a maintainer will weigh in.

More on how Apache Magpie handles maintainer review:
Contributing guide.

Kaap10 added a commit to Kaap10/magpie that referenced this pull request Nov 16, 2026
…l integration (apache#2080)

- Add workspace root boundary check in Write tool hook to prevent path traversal

- Re-hydrate duplicate picker pane state when candidates file hash changes for same target

- Bound deriveStatus to visible candidates (up to MAX_VISIBLE_CANDIDATES = 10)

- Document portable candidates SHA-256 validation command in SKILL.md

- Map multi-dropped issues and non-argument canonical kept issue resolution in Step 2 and Step 3

- Update eval fixtures to provide raw payloads without hardcoded verdicts, record run, and re-render journal

- Fix broken Step 1.4 reference in secure-agent-setup.md and deduplicate spec description
@Kaap10

Kaap10 commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

Thanks @potiuk for the review and for pushing the stat shape fixup (f135cfb). I pulled your commit and addressed all remaining points in 38a8a71:

  • Stale decision binding & docs link:

    • In SKILL.md, documented the portable SHA-256 verification command: shasum -a 256 .magpie-issue-candidates-<target>.json 2>/dev/null || sha256sum .magpie-issue-candidates-<target>.json.
    • In docs/setup/secure-agent-setup.md, updated the broken reference from "Step 1.4" to Step 2 (Decision file resolution).
  • Decision mapping in Step 2 & Step 3:

    • Anchored the decision file logic directly inside ## Step 2 — Build the deduplication proposal.
    • Added explicit handling for decision mapping:
      • If status: "curated", each issue in dropped_issues is deduplicated against kept_issue.
      • If kept_issue was not one of the invocation arguments, the skill fetches its metadata via gh issue view <kept_issue>.
      • In Step 3, the skill closes each dropped issue sequentially with an explanatory comment, halting if any close operation fails.
      • If status: "dismissed", the skill records the dismissal, skips closing, and exits cleanly.
  • Eval fixtures & runs journal:

    • Because step-config.json extracts ## Step 2, moving the decision resolution into Step 2 allows the prompt extractor to include it.
    • Removed the pre-determined verdict sentences from case-4-decision-prefill/report.md and case-5-decision-stale/report.md. Both fixtures now supply raw candidate and decision payloads (matching SHA-256 in case 4, mismatched SHA-256 in case 5) so the model evaluates the files directly.
    • Recorded the run in tools/skill-evals/evals/issue-deduplicate/runs.jsonl and regenerated the summary table in tools/skill-evals/evals/issue-deduplicate/README.md.
  • Pane re-hydration on hash change:

    • Updated duplicate-picker.ts to compare candidatesSha256 during handleBashToolCall. If the candidates file is rewritten with different content for the same target issue, it re-hydrates the state and resets prior selections. Added a unit test covering this scenario.
  • Workspace boundary enforcement:

    • Added workspace boundary validation in handleWriteToolCall (duplicate-picker.ts) to ensure candidate paths resolve strictly within the active workspace root, rejecting directory traversal (..) and external paths.
    • Updated docs/setup/secure-agent-setup.md to accurately reflect workspace bounding.
  • Nits:

    • Updated deriveStatus to check visible candidates (candidates.slice(0, MAX_VISIBLE_CANDIDATES)). Dismissing all 10 visible candidates now correctly transitions the status to "dismissed", even if more candidates exist in the file. Added a test for this case.
    • In tools/spec-loop/specs/issue-management-family.md, removed the repeated sentence and documented the decision file IPC flow.

All 66 plugin unit tests pass cleanly (claude plugin test plugins/magpie-issue), and all CI checks on the PR are green.

@Kaap10
Kaap10 force-pushed the feat/issue-duplicate-picker-pane-pr2 branch from 38a8a71 to 3b7b65e Compare November 19, 2026 07:40
Kaap10 added a commit to Kaap10/magpie that referenced this pull request Nov 19, 2026
…l integration (apache#2080)

- Add workspace root boundary check in Write tool hook to prevent path traversal

- Re-hydrate duplicate picker pane state when candidates file hash changes for same target

- Bound deriveStatus to visible candidates (up to MAX_VISIBLE_CANDIDATES = 10)

- Document portable candidates SHA-256 validation command in SKILL.md

- Map multi-dropped issues and non-argument canonical kept issue resolution in Step 2 and Step 3

- Update eval fixtures to provide raw payloads without hardcoded verdicts, record run, and re-render journal

- Fix broken Step 1.4 reference in secure-agent-setup.md and deduplicate spec description
Kaap10 and others added 6 commits November 19, 2026 15:43
…picker pane (part 2 of apache#2075)

- Adds `hydrateCandidatesFromFile` to `plugins/magpie-issue/hooks/duplicate-picker.ts` using `$.fs.read` to load candidate payloads, populate reactive state, and open the interactive pane with fail-open safety.
- Updates `renderDuplicatePickerPane` to render target author handle in header, bound candidates to MAX_VISIBLE (10) with overflow box, and stage decisions safely.
- Implements `safeWriteDecisionFile` with `$.fs.stat` pre-checks to refuse symlinks and non-regular files, preventing host overwrites.
- Implements `invalidateDecisionFile` staging `{ invalidated: true, status: 'reviewing' }` with symlink refusal.
- Implements pure-TS bitwise `computePayloadHash` (supporting multi-byte UTF-8 without Node stdlib imports) and embeds `source_candidates_sha256` in decision payloads.
- Binds `dropped_issues` strictly to visible rendered candidates (`MAX_VISIBLE_CANDIDATES = 10`), preventing unrendered candidates from being staged for closure.
- Adds `syncError` to state and renders warning box in pane footer when write fails, staging invalidation on disk.
- Adds `handleBashToolCall` and `handleWriteToolCall` hooks to intercept candidate file creation, executing `next(e)` first and hydrating candidate state.
- Normalizes author handles in `parseCandidatePayload` by stripping leading `@` characters.
- Adds 59 tests in `duplicate-picker.test.ts` covering author header rendering, handle normalization, candidate truncation, decision file staging, toggle-off invalidation, file hydration, tool call interception, symlink refusal, and pure-TS hash computation (100% pass).
- Adds fast-path, hash binding, and session artifact cleanup to `plugins/magpie-issue/skills/deduplicate/SKILL.md` (493 lines, below 500-line ceiling), updating `surface_hash` and `measured_tokens`.
- Updates spec in `tools/spec-loop/specs/issue-management-family.md` (line 192).
- Documents filesystem IPC boundaries, threat model, symlink protection, and human-in-the-loop contract in `docs/setup/secure-agent-setup.md`.
- Ignores `.magpie-issue-candidates-*.json` and `.magpie-issue-decision-*.json` in `.gitignore`.
- Adds eval test fixtures `case-4-decision-prefill` and `case-5-decision-stale` under `tools/skill-evals/evals/issue-deduplicate/step-2-build-proposal/fixtures/`.
…hape

The mod harness's `$.fs.stat` resolves `{ kind, size, mtimeMs, isLink }`, not
Node's `Stats`, so the `isSymbolicLink()` / `isFile()` probes never matched and
the pane wrote through a link planted at `.magpie-issue-decision-<N>.json`.

`classifyWriteTarget` judges the path on `isLink` and `kind`, treats only
`ENOENT` as a missing file, and refuses on any other stat failure. Both the
decision write and the invalidation use it. The tests now mock the harness
shape and cover a link to a regular file, a dangling link, a missing path and
a failing stat.

Generated-by: Claude Opus 5
Claude-Session: https://claude.ai/code/session_01NyQq9UgHu7T8a8DfcfyP2M
…l integration (apache#2080)

- Add workspace root boundary check in Write tool hook to prevent path traversal

- Re-hydrate duplicate picker pane state when candidates file hash changes for same target

- Bound deriveStatus to visible candidates (up to MAX_VISIBLE_CANDIDATES = 10)

- Document portable candidates SHA-256 validation command in SKILL.md

- Map multi-dropped issues and non-argument canonical kept issue resolution in Step 2 and Step 3

- Update eval fixtures to provide raw payloads without hardcoded verdicts, record run, and re-render journal

- Fix broken Step 1.4 reference in secure-agent-setup.md and deduplicate spec description
@Kaap10
Kaap10 force-pushed the feat/issue-duplicate-picker-pane-pr2 branch from 3b7b65e to 0d534ca Compare November 19, 2026 10:16
…e-picker-pane-pr2

# Conflicts:
#	plugins/magpie-issue/skills/deduplicate/SKILL.md
@Kaap10
Kaap10 requested a review from potiuk November 22, 2026 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

capability:resolve Close-out: invalidate, dedupe, CVE allocate, announcement family:ci .github workflows, prek, validators family:dev Repo dev: .asf.yaml, spec-loop specs, Node manifests, .claude/settings.json family:docs Docs, MISSION.md, READMEs family:issue issue-* skills family:setup setup-* skills family:tools tools/* substrate:framework-dev Tool substrate: build / validate / eval the framework itself

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(issue): interactive duplicate-picker pane mod for issue-deduplicate

2 participants