Repository navigation
fix(validate): remote-reference awareness for linked-artifact validation (URL doc-refs no longer flagged/pruned as missing files) - #372
Conversation
… linked-artifact validation
pm validate --check-files and pm files/docs --validate-paths fs.stat'd every
project-scoped linked-artifact path, so an https:// PR/issue/design-doc URL
recorded via `pm docs --add` resolved to a bogus local path, was reported as a
"deleted" missing file, and — critically — was planned for deletion by
`pm validate --prune-missing`, silently destroying intentionally-recorded
context (project management = context management).
Add a pure core helper isRemoteLinkedArtifactReference (scheme:// detection,
2+ char scheme so Windows drive/UNC paths stay local) and wire it into both
stat-based surfaces:
- buildFilesCheck (validate.ts): remote refs collected into a benign
remote_linked_paths{,_count,_total,_truncated} details category; never
stat'd, classified moved/deleted, counted missing, or pruned.
- validateLinkedPaths (linked-artifacts.ts): remote refs reported in a new
remote_references[] field instead of missing_paths.
Follow-up to pm-0v2m (GH-184), which introduced --prune-missing without
remote-reference awareness.
Refs pm-k2n4 (parent pm-mpbb; related pm-0v2m/pm-j8z6/pm-o2kc).
Verification: pnpm typecheck clean; full coverage gate 5131 tests
100/100/100/100; contracts:check current; quality:static (docstrings) pass;
changelog:pm:check unchanged; manual temp-dir smoke confirms a URL doc ref
stays in the remote category and is never targeted by --prune-missing --dry-run.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0162E7r4dACCeEAoJCigEAJG
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
@coderabbitai full review @gemini-code-assist please review @codex review Focus areas:
|
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Review limit reached
More reviews will be available in 46 minutes. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (11)
📝 WalkthroughWalkthroughRemote URL-style linked artifact references are now detected separately from local paths in core validation, ChangesRemote linked artifact handling
Sequence Diagram(s)sequenceDiagram
participant Validate as validate.ts
participant Helper as isRemoteLinkedArtifactReference()
participant fsStat as fs.stat
Validate->>Helper: inspect linked artifact reference
alt remote reference
Helper-->>Validate: true
Validate-->>Validate: add path to remoteLinkedPaths
Validate-->>Validate: skip stat, missing, moved, deleted, and orphan classification
else local path
Helper-->>Validate: false
Validate->>fsStat: probe filesystem path
fsStat-->>Validate: existing file or missing path result
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
To use Codex here, create a Codex account and connect to github. |
🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== PR files =="
gh pr view 372 --repo unbraind/pm-cli --json files --jq '.files[].path'
echo
echo "== Diff summary =="
gh pr diff 372 --repo unbraind/pm-cli --name-only
echo
echo "== Outline: src/core/validate/linked-artifact-reference.ts =="
ast-grep outline src/core/validate/linked-artifact-reference.ts --view expanded || true
echo
echo "== File: src/core/validate/linked-artifact-reference.ts =="
cat -n src/core/validate/linked-artifact-reference.ts
echo
echo "== Outline: src/cli/commands/validate.ts =="
ast-grep outline src/cli/commands/validate.ts --view expanded || true
echo
echo "== Relevant symbols in src/cli/commands/validate.ts =="
rg -n -C 4 'buildFilesCheck|missing_linked_paths|remote_linked_paths|staleLinkRows|classifyStaleLinkedPaths|planStaleLinkPruneFixes' src/cli/commands/validate.ts || true
echo
echo "== Slice: src/cli/commands/validate.ts (buildFilesCheck area) =="
sed -n '1,280p' src/cli/commands/validate.ts
echo
echo "== Outline: src/core/linked-artifact/validate-paths.ts =="
ast-grep outline src/core/linked-artifact/validate-paths.ts --view expanded || true
echo
echo "== Relevant symbols in src/core/linked-artifact/validate-paths.ts =="
rg -n -C 4 'validateLinkedPaths|missing_paths|remote_references|isRemoteLinkedArtifactReference' src/core/linked-artifact/validate-paths.ts || true
echo
echo "== File: src/core/linked-artifact/validate-paths.ts =="
cat -n src/core/linked-artifact/validate-paths.ts
echo
echo "== Searches for consumers/callers =="
rg -n -C 3 'missing_linked_paths|remote_linked_paths|staleLinkRows|remote_references|validateLinkedPaths\s*\(' src || trueLength of output: 32529 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== Locate validateLinkedPaths =="
rg -n -C 4 '\bvalidateLinkedPaths\b' src tests || true
echo
echo "== buildFilesCheck implementation slice =="
sed -n '1639,1835p' src/cli/commands/validate.ts
echo
echo "== linked-artifacts.ts outline =="
ast-grep outline src/cli/commands/linked-artifacts.ts --view expanded || true
echo
echo "== linked-artifacts.ts relevant symbols =="
rg -n -C 4 'validateLinkedPaths|missing_paths|remote_references|isRemoteLinkedArtifactReference|stat\(' src/cli/commands/linked-artifacts.ts || true
echo
echo "== linked-artifacts.ts full file =="
cat -n src/cli/commands/linked-artifacts.ts
echo
echo "== stale-file-classification references =="
rg -n -C 3 'classifyStaleLinkedPaths|summarizeStaleLinkedPathClassifications' src || true
echo
echo "== fix-planning references for stale link prune =="
rg -n -C 4 'planStaleLinkPruneFixes|type StaleLinkPruneRow' src/core src/cli || true
echo
echo "== remote reference tests =="
cat -n tests/unit/validate/linked-artifact-reference.spec.ts
echo
echo "== validate-command tests relevant to remote refs =="
rg -n -C 4 'remote_linked_paths|prune-missing|missing_linked_paths|remote reference|https://' tests/unit/commands/validate-command.spec.ts || true
echo
echo "== files/docs command tests relevant to remote refs =="
rg -n -C 4 'remote_references|missing_paths|validate-paths|https://' tests/unit/commands/files-docs-command.spec.ts || trueLength of output: 65893
What I verified:
One tiny non-blocking note: ✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/cli/commands/linked-artifacts.ts`:
- Around line 409-416: The remote-reference handling in linked-artifacts is
storing the raw relativePath while buildFilesCheck stores a trimmed path,
causing inconsistent output when the input has surrounding whitespace. Update
the remoteReferences collection in the linked-artifacts flow to use the same
trimmed value used by buildFilesCheck, and keep the
isRemoteLinkedArtifactReference check operating on the normalized path so both
code paths report the same shape.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: ASSERTIVE
Plan: Pro
Run ID: c5cc79bc-972e-4f97-8721-f065d73c010e
📒 Files selected for processing (10)
.agents/pm/history/pm-k2n4.jsonl.agents/pm/history/pm-z5nb.jsonl.agents/pm/issues/pm-k2n4.toon.agents/pm/plans/pm-z5nb.toonsrc/cli/commands/linked-artifacts.tssrc/cli/commands/validate.tssrc/core/validate/linked-artifact-reference.tstests/unit/commands/files-docs-command.spec.tstests/unit/commands/validate-command.spec.tstests/unit/validate/linked-artifact-reference.spec.ts
…ut-shape parity Address CodeRabbit review on #372: validateLinkedPaths stored the untrimmed path in remote_references while buildFilesCheck stores the trimmed value, so a " https://… " input would surface with surrounding whitespace in one flow only. Store the trimmed value in both; extend the unit test with a whitespace-wrapped URL asserting the trimmed result. Refs pm-k2n4. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0162E7r4dACCeEAoJCigEAJG
|
Addressed the CodeRabbit nitpick in 9c7909e: @coderabbitai full review |
|
If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! ✅ Action performedFull review finished. |
|
✅ Action performedFull review finished. |
|
✅ Action performedFull review finished. |
…rence fix Close the remote-reference validation Issue (pm-k2n4) with resolution + expected/actual evidence now that PR #372 ships the fix, and regenerate CHANGELOG.md so the change lands under Unreleased → Fixed for the next auto-release. changelog:pm:check reports unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0162E7r4dACCeEAoJCigEAJG
|
Pushed 7903e63: closed pm-k2n4 with resolution evidence and regenerated CHANGELOG.md (the fix lands under Unreleased → Fixed). This commit is pm-tracker data + changelog only — no code change. @coderabbitai full review |
|
✅ Action performedFull review finished. |
Problem (pm-k2n4)
A linked-artifact
path(pm files/pm docs) is normally a workspace-relative or absolute local file, butpm docs --addlegitimately records remote references too — most commonly anhttps://URL to a PR, issue, or external design doc. (In this very repo,pm-bhmk/pm-v37g/pm-qawdeach linkhttps://github.com/unbraind/pm-cli/pull/362|364.)Three validation surfaces blindly
fs.statevery project-scoped path:buildFilesCheck(src/cli/commands/validate.ts) — a URL resolves to a bogus local path →statfails → pushed intomissing_linked_paths+staleLinkRows.classifyStaleLinkedPathsthen labels itdeleted(no basename candidate match).planStaleLinkPruneFixesprunes everydeletedlink →pm validate --prune-missingsilently deletes the intentionally-recorded PR/URL doc reference. That is data loss of recorded context (project management = context management).validateLinkedPaths(pm files/docs --validate-paths) reports the URL as amissing_pathfor the same reason.This is the gap left by pm-0v2m (GH-184), which introduced moved/deleted classification +
--prune-missingwithout remote-reference awareness.Fix
New pure core helper
src/core/validate/linked-artifact-reference.ts:isRemoteLinkedArtifactReference(path)— matches^[a-z][a-z0-9+.-]+:\/\//i(ascheme://authority, scheme ≥ 2 chars so a Windows drive prefixC:/…/C:\…/ UNC//server/shareand all relative/absolute POSIX paths stay local).Wired into both stat-based surfaces:
buildFilesCheck— remote refs are collected into a new benignremote_linked_paths{,_count,_total,_truncated}details category and skipped before the existence probe, so they never entermissing_linked_paths,staleLinkRows, classification, or the--prune-missingplan.validateLinkedPaths— remote refs go to a newremote_references[]field instead ofmissing_paths.No new CLI flags or contract changes (output-shape additions only); existing behavior for genuine local files is unchanged.
Verification
pnpm typecheckclean.contracts:checkcurrent ·quality:static(incl. docstring coverage) pass ·changelog:pm:checkunchanged.remote_linked_paths(notmissing_linked_paths);--prune-missing --dry-runplans only the genuine missing local file and never the URL;pm docs --validate-pathsreports it underremote_references.pm tracking
pm-mpbb) — related topm-0v2m(the pm validate --files should detect and report stale linked file paths referencing deleted/moved files #184 prune feature),pm-j8z6(the linked-file reconciliation chore this de-noises), andpm-o2kc(data durability).🤖 Generated with Claude Code
https://claude.ai/code/session_0162E7r4dACCeEAoJCigEAJG