Skip to content

fix: task search passes -n; compact pgrep stops leaking process args - #171

Merged
bborbe merged 1 commit into
masterfrom
fix/pgrep-leak-and-task-search
Sep 15, 2026
Merged

bborbe merged 1 commit into
masterfrom
fix/pgrep-leak-and-task-search

Conversation

@bborbe

@bborbe bborbe commented Sep 15, 2026

Copy link
Copy Markdown
Owner

Two defects in one PR.

Defect 1 — vault-cli task search exits 2 on every query

pkg/ops/search.go:68 passed --limit <n> to semantic-search-mcp, which accepts -n TOP_K:

semantic-search-mcp: error: unrecognized arguments: --limit 5
: exit status 2

The documented operator command failed for any vault, and --top-k was unusable. The flag is now -n. --limit was the only emitter in Go/markdown outside vendor/ — checked before changing it, because the original diagnosis read the caller and the callee's own usage but no sibling caller.

Defect 2 — the compact commands leaked process command lines

commands/prepare-compact.md:52 and commands/post-compact.md:32,49 prescribed pgrep -af 'dark-factory|docker'. -a prints full command lines, and the pattern matched ~46 processes on a loaded machine, so following the checklist copied MCP Authorization headers into the transcript. Both now use PIDs-only pgrep -f, matching the rule ~/.claude/commands/and.md:85 already documents, with a comment at each site recording why so -a doesn't get re-added.

Verification

  • make test green (8 packages); make precommit green (golangci-lint 0 issues, osv-scanner and trivy clean, CHANGELOG structure OK)
  • SC1 probe: grep -c "pgrep -f 'dark-factory|docker'" commands/prepare-compact.md commands/post-compact.md reports 1 / 2; grep -nE 'pgrep +-[a-z]*[al]' … returns 0 lines
  • Still open after merge, tracked on the task: the plugin ladder (make updateclaude plugin update vault-cli@vault-cli → reload), then task search "<term>" against the real vault, including the --top-k 1 / --top-k 3 count check — that needs the rebuilt binary, so it cannot be claimed from this branch.

Refs task: Stop vault-cli Leaking Process Command Lines and Breaking Task Search

@bborbe
bborbe marked this pull request as ready for review September 15, 2026 07:27

@ben-s-pull-request-reviewer ben-s-pull-request-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The ast-grep toolchain check failed (not in PATH, runner script not accessible). Per Step 4.0, I'll skip the mechanical funnel and note the toolchain gap. Now let me write the final report.

{
  "verdict": "approve",
  "summary": "Both fixes are correct and well-documented: (1) `pgrep -f` replaces `pgrep -af` in two command docs to prevent MCP Authorization headers from leaking into transcripts; (2) the `-n` flag replaces `--limit` in search.go so semantic-search-mcp accepts the top-K parameter as documented. The CHANGELOG.md entry clearly explains both root causes.",
  "comments": [],
  "concerns_addressed": [
    {
      "concern": "security: pgrep -a leaked command lines including MCP Authorization headers in commands/prepare-compact.md and commands/post-compact.md",
      "disposition": "addressed",
      "detail": "Changed to `pgrep -f` (PIDs only) in both files; explanatory comment added citing the Authorization-header risk"
    },
    {
      "concern": "correctness: --limit flag caused semantic-search-mcp to exit 2 with 'unrecognized arguments' in pkg/ops/search.go",
      "disposition": "addressed",
      "detail": "Changed to `-n` (the flag semantic-search-mcp actually accepts); comment documents the exit-2 symptom so future maintainers understand why"
    }
  ]
}

@bborbe
bborbe merged commit 56e416d into master Sep 15, 2026
3 checks passed
@bborbe
bborbe deleted the fix/pgrep-leak-and-task-search branch September 15, 2026 07:31
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.

1 participant