Skip to content

fix(#5915 P2): cross-repo link passes handle segment-set repos end-to-end#5919

Merged
cajasmota merged 4 commits into
mainfrom
worktree-agent-a12313d9d03ad1b53
Jul 22, 2026
Merged

fix(#5915 P2): cross-repo link passes handle segment-set repos end-to-end#5919
cajasmota merged 4 commits into
mainfrom
worktree-agent-a12313d9d03ad1b53

Conversation

@cajasmota

Copy link
Copy Markdown
Owner

What

Cross-repo link passes silently dropped segmented repos (a current pointer + graph.<gen>/ dir of seg-NNNN.fb + manifest.json, no flat graph.fb). A #5915 P2 gap. This closes it end-to-end: discovery → staging → load → pass contribution.

Changes (all in the cross-repo link path)

  • internal/links/links.go loadAllGraphs discovery — added a branch keyed on base == graph.CurrentPointerName that registers the dir only when graph.CurrentGraphDescriptor(dir).Kind == GraphSegmentSet (not != GraphAbsent — scoped to exactly the missing case, single-file discovery untouched). The gen dir's seg-*.fb/manifest.json match neither IsGraphFileName nor graph.json, so it can't self-register as a phantom repo; dirSet dedupes.
  • internal/cli/links.go stageGraphsDir — descriptor-branch: GraphSingleFile symlinks as graph.fb (byte-parity); GraphSegmentSet stages the gen dir (symlink segments+manifest) + WriteCurrentPointerRaw; GraphAbsent skipped.
  • internal/cli/links.go phantom-edge gateos.Stat pair → CurrentGraphDescriptor(...).Kind != GraphAbsent.
  • internal/graph/genpath.go — exported CurrentPointerName.

Verification (independent adversarial review — APPROVE)

  • bug(win): resident mmap reader blocks reindex rewrite of graph.fb on Windows (file-locking) #5891 single-file-with-current-pointer NOT misclassified: classifies GraphSingleFile, guard excludes it → discovery count 1 (the load-bearing safety for existing users).
  • No phantom repos from the gen dir; discovery genuinely required (both e2e tests RED when reverted); stray/legacy currentGraphAbsent; loud-fail on broken segment/manifest; copy-fallback resolves.
  • RunAllPasses e2e: a segment-set repo now contributes a cross-repo import link (was got []).

Follow-up (noted by review, out of scope → J2 sweep)

~13 more os.Stat(CurrentGraphPath) existence gates (audit, groupalgo, dashboard store/refs, daemon state_path, doctor, status_stats) still assume flat graph.fb. Latent (no production writer emits segment-sets yet), swept before the flip.

Refs #5915

🤖 Generated with Claude Code

jcajasmc added 4 commits July 23, 2026 00:03
…ented repos (#5904(e) PR-c)

stageGraphsDir and the phantom-edge existence gate both resolved a repo's
graph via the flat-file-only graph.CurrentGraphPath, so a SEGMENTED repo
(graph.<gen>/ dir + manifest.json, no flat .fb) was silently dropped from
cross-repo link staging and skipped before its (already segment-aware) load
(#5915 P2 gap). Both now resolve via graph.CurrentGraphDescriptor:

- stageGraphsDir stages a GraphSegmentSet repo by symlinking the whole
  generation (every seg-*.fb + manifest.json) into dstDir/graph.<gen>/ and
  writing a `current` pointer in dstDir naming that gen dir, so
  LoadGraphFromDir(dstDir) resolves it identically to the real state dir.
  GraphSingleFile staging is unchanged (still symlinked as graph.fb).
- runPhantomEdgePass's existence gate now checks
  CurrentGraphDescriptor(...).Kind != GraphAbsent instead of stat'ing the
  flat graph.fb path, so a segment-set repo reaches loadGraphDocument
  (LoadGraphFromDir is already segment-aware).

Scope: internal/cli/links.go only (staging + phantom-edge load gate). Does
not touch phantom-edge writeback (PR-b), description overlay (PR-a), or the
broad P2 sweep (J2).
…or segmented repos (#5904(e) PR-c)

Adds three tests exercising the #5915 P2 fix:
- TestStageGraphsDir_SegmentSetAndSingleFile: a fleet with a single-file
  repo AND a SEGMENTED repo (graph.<gen>/ dir + manifest.json, no flat
  .fb) — both are staged, and graph.LoadGraphFromDir resolves the staged
  segment-set repo with its entities intact.
- TestStageGraphsDir_SingleFileParity: single-file staging remains
  byte-for-byte identical to the pre-fix behavior (symlink target / bytes).
- TestRunPhantomEdgePass_SegmentSetNotSkipped: a CALLS/http link sourced
  from a segment-set repo actually promotes a phantom edge, proving the
  existence gate no longer skips it before loadGraphDocument.

writeSingleFileRepo/writeSegmentSetRepo hand-build fixtures directly (the
graph package's writeSegmentSet test helper lives in an external _test.go
file and isn't exported). All tests use t.TempDir() + the stageGraphsDir
cleanup closure, no long-lived handles, so teardown is Windows-safe.
…pos (#5904(e) PR-c)

loadAllGraphs' WalkDir added a repo dir to the discovery set only on
graph.json or graph.IsGraphFileName (graph.fb / graph.<gen>.fb). A SEGMENTED
repo's active generation is a graph.<gen>/ dir (seg-NNNN.fb + manifest.json)
named by a `current` pointer with NO flat graph.fb — none of those filenames
matched, so the repo was silently dropped from every cross-repo pass even
after PR-c's staging fix. This completes the P2 fix end-to-end: staging a
segment-set repo was useless while the real consumer (RunAllPasses ->
loadAllGraphs) still couldn't discover it.

Discovery now also recognizes the `current` pointer file (graph.CurrentPointerName,
newly exported) as a state-dir marker and confirms it via
graph.CurrentGraphDescriptor, registering the dir only when
Kind == GraphSegmentSet. Guards:
- Single-file parity: a single-file repo is still discovered by its
  graph.fb / graph.<gen>.fb match (unchanged branch, early return); the new
  branch never fires for it (its descriptor is GraphSingleFile, and its
  graph.<gen>.fb already registered the dir).
- Stray/legacy `current` with no valid gen dir resolves to GraphAbsent and is
  ignored (no false-positive repo).
- Dedupe: only the pointer's dir (the state dir) is added, never the
  graph.<gen>/ gen dir — its seg-NNNN.fb / manifest.json never match the
  graph-file check, so the gen dir cannot register a phantom repo entry.
#5904(e) PR-c)

Two tests through the REAL consumer:
- TestLoadAllGraphs_DiscoversSegmentSet: a graphs dir with a single-file repo
  AND a segment-set repo yields BOTH repoGraphs; the graph.<gen>/ gen dir does
  NOT register a phantom repo entry (dedupe guard), and exactly 2 repos are
  discovered (single-file parity).
- TestRunAllPasses_SegmentSetContributesCrossRepoLink: the end-to-end P2
  assertion — a segment-set repo owning an entity with an IMPORTS edge into a
  single-file repo yields a cross-repo import link SOURCED FROM the segment-set
  repo in RunAllPasses output, proving it is no longer dropped at discovery.

writeSingleFileFBRepo/writeSegmentSetFBRepo build the staged-equivalent layout
directly (the graph package's segment fixture helper lives in an external
_test.go and isn't importable from package links).
@cajasmota
cajasmota merged commit 44d42ab into main Jul 22, 2026
1 of 2 checks passed
@cajasmota
cajasmota deleted the worktree-agent-a12313d9d03ad1b53 branch July 22, 2026 16:04
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