8000 Fix feature identity after ordinary merges by rore · Pull Request #46 · rore/minimap · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .agent-workflow/tasks/merge-history-identity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!-- agent-workflow:start -->
**Outcome:** Correctly connect proven versions of a roadmap feature across supported Git histories without merging unrelated features.
**Target:** Minimap worktree aggregation and participant candidate selection.
**Scope:** Investigate the reported duplicate named-drafts identities; fix the shared identity matching defect, add generic regressions, and reconcile affected documentation and roadmap evidence.
**Constraints:** Preserve independent same-ID features, deletion/recreation boundaries, bounded Git work, and unknown participant semantics. Do not edit Dictation files, install tools, or restart the live service.
**Completion criteria:** Proven related versions aggregate once; ambiguous or untracked copies remain safely distinct; counts and participant eligibility agree; focused regressions and required checks pass.
**Requirement baseline:** {"source":"user-2026-10-12-investigate-and-fix","outcome":"Correctly connect proven versions of a roadmap feature across supported Git histories without merging unrelated features.","scope":"Investigate the reported duplicate named-drafts identities; fix the shared identity matching defect, add generic regressions, and reconcile affected documentation and roadmap evidence.","constraints":"Preserve independent same-ID features, deletion/recreation boundaries, bounded Git work, and unknown participant semantics. Do not edit Dictation files, install tools, or restart the live service.","completion_criteria":"Proven related versions aggregate once; ambiguous or untracked copies remain safely distinct; counts and participant eligibility agree; focused regressions and required checks pass."}
**Behavior changes:** [{"target":"repository-contract","path":"playwright/worktree-ui.spec.js","classification":"coverage-only","before":"The rendered Across worktrees fixture did not exercise an exact squash identity after a later ordinary merge.","after":"An additional isolated fixture asserts one rendered feature card with two source versions in List and Columns at desktop and 390px widths; existing assertions remain unchanged.","reason":"Verify the approved first-parent merge parser correction on the actual rendered board without weakening prior acceptance coverage."}]
**Risk:** High
**Complexity:** Moderate
**Reason:** The fix changes documented identity support in the red-zone CONTRACT.md and lifecycle reference. Keep first-parent transition semantics and single-parent integration matching; no write authorization, persistence, or configuration change.
**Discovery:** Diagnosis /root/identity_diagnosis confirms transitionHistory uses --first-parent --diff-merges=first-parent but parses exactly one parent in commit headers. A later normal merge therefore invalidates otherwise valid squash evidence. The parser fix joins six active committed versions in the reported repository. The older planned committed branch shares ancestry with the original implementation branch but remains separate under pairwise group matching; the untracked main-only copy remains unproven. Participant eligibility is still ambiguous while distinct same-ID groups remain.
**Material assumptions:** The bounded parser correction connects directly proven active committed versions without guessing identity from matching text or IDs. The older planned branch has only a transitive proof through the implementation branch and remains separate under the existing pairwise requirement. This scoped fix does not resolve all same-ID groups or participant ambiguity; widening identity policy needs separate review.
**Plan:** Accept one or more parent hashes in transitionHistory and retain the first parent for the already first-parent-relative changes. Keep integration matching restricted to single-parent commits so this fixes traversal without broadening identity proof. Preserve parent-chain validation and all caps. Add generic fixtures for a later ordinary merge on either side of an existing exact squash proof; assert identity/count/participant behavior, independent same-ID isolation and untracked ambiguity. Update only the corresponding history wording in CONTRACT.md and roadmap server reference, sync runtimes, and add follow-up evidence to the existing roadmap item. Obtain independent technical and required human plan review before product edits; then focused tests, isolated rendered board inspection, independent result review, and normal delivery gates.
**Verification plan:** Related history joins correctly -> `test/worktree-aggregate.test.js` Git fixtures exercising aggregation and participant selection. Independent or recreated identity remains separate -> existing negative tests plus missing cases. Bounded work remains -> existing cap/performance regressions. Presentation remains understandable -> rendered isolated `playwright/worktree-ui.spec.js` board inspection. Delivery -> workflow, redline and CI checks.
**Plan review:** Agent technical review: /root/merge_history_plan_review approved the plan at base 75541444eb7aed5a6eba5707d402ae8ecd492e92 on 2026-10-12. Parse all parent hashes but retain first-parent transitions; explicitly exclude merge signatures as integration candidates. Cover ordinary merges on either side, merge-only negative proof, untracked duplicate ambiguity, and existing identity/cap tests. Human plan review required by High classification before product edits.
**Approvals:** Approved by user 2026-10-12: "approved". Approval covers the recorded implementation plan; no live environment changes authorized.
**Exceptions:** —
**State:** Ready for review
<!-- agent-workflow:end -->

Source item: roadmap/features/add-worktree-aware-roadmap-view.md (existing delivered feature; this follow-up does not reopen unrelated completed work).

## Implementation
Isolated checkout: C:/Dev/rore/minimap/artifacts/merge-history-identity, branch feat/merge-history-identity, base 7554144. Technical and human plan review complete. Implemented first-parent merge parsing, single-parent integration matching, merge deletion collection, generic aggregate regressions, focused browser regression, documentation updates, and runtime mirror sync. The original parser failed both later-merge regressions with `squash-evidence-unavailable`; the fixed parser passed all 28 focused aggregate tests and the isolated rendered board test. The separate planned branch is a broader identity-policy question outside the approved parser fix. Scoped result review is on [PR #46](https://github.com/rore/minimap/pull/46); no live rollout performed.

## Evidence
Read-only reproduction found eight loaded checkouts, no excluded checkouts, three logical identities for the same named-drafts ID, and ambiguous participant reference selection. No user files were changed.

After the parser fix, a read-only load of the reported repository found eight loaded checkouts, zero excluded, no identity uncertainty, and three named-drafts groups: six active committed versions, one planned committed version, and one untracked completed copy. The planned branch's file at HEAD 427454c matches ancestor commit 2d8e24a, while the integrated line starts from parent 63c3095; pairwise matching cannot join all three committed sublines transitively. A manager inspected four isolated screenshots: one merged feature in List and Columns at desktop and 390px widths, with two source versions accessible in the desktop editor. The isolated session provider was disabled, so this visual check does not prove live participant badge delivery.

Verification: original-parser behavioral baseline 0/2 later-merge tests, fixed-parser targeted 5/5, full `node --test test/worktree-aggregate.test.js` 28/28, focused Playwright 1/1, `node --test test/sync-mirrors.test.js` 1/1, `git diff --check` clean, and obsolete skill-doc phrase sweep empty. An existing agent-workflow virtual environment provides the Python checker without installation. A fresh Redline verdict classifies the committed diff RED with no boundary violations; `architecture-review` remains unsatisfied pending the PR label or CODEOWNER approval. CI and human result review remain delivery gates.

## Result review
Agent technical review: /root/merge_history_plan_review approved the scoped application diff; no actionable defects.
Reviewed revision: b024c58.
Verification adequacy: 28 aggregate tests, one mirror test, one focused Playwright test, and four manager-inspected screenshots adequately cover the parser-only change, including false-match and deletion boundaries. The isolated session provider was disabled, so live participant badge delivery is unproven. The older tracked planned and untracked completed copies remain separate under existing identity policy.

Human result review and architecture checkpoint are pending. The manager inspected the four isolated board screenshots; that visual check is not the full human result review.
2 changes: 1 addition & 1 deletion package/minimap/CONTRACT.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Example config:

The board can show **This checkout** or a read-only **Across worktrees** projection. Discovery considers at most 16 registered linked Git worktrees in the opened repository's common Git directory. A separate clone is not a sibling. A source with an incompatible roadmap location, unreadable workspace, or uncertain identity is excluded or marked as partial coverage; it is never silently represented as empty. A checkout whose branch or HEAD changes during the read invalidates the combined snapshot and requires Refresh. Same item ID, path, or content alone do not prove one logical feature. Identity requires either that the shared ancestor contains the same ID/path, or that a branch's complete repository change from that ancestor to a historical commit exactly matches a single-parent integration commit in the other checkout's history, including every changed path, file mode, and old/new Git blob. The latter recognizes newly introduced items after squash integration, including later edits; the matched added item must have the same parsed ID/path. A delete/re-add breaks both forms of continuity. Git cannot distinguish independently reproduced identical complete changes from squash integration, so these are treated as equivalent; independent item-content matches with different complete changes remain separate. Conflicting values stay source-specific. Different board-group memberships are disclosed on the cards; missing-file board references remain visible in coverage details even under metadata lenses. Line-ending-only differences do not produce a visual conflict, although raw file revisions remain exact for stale-write checks. Search, filters, In play, and metadata grouping evaluate each checkout version, not a fabricated merged item.

Squash evidence uses cached first-parent histories with at most 64 single-parent commits per history and 4 MiB per Git response. One aggregate permits at most 32 history loads and 8192 raw change records. Missing history, an unsupported merge chain, malformed evidence, or a cap retains separate new identities and reports partial coverage; already established shared-ancestor identities remain usable. Equivalence compares committed blobs, not checkout newline formatting or whitespace-insensitive patch IDs.
Squash evidence uses cached first-parent histories with at most 64 commits per history and 4 MiB per Git response. Merge commits can be traversed by their first-parent changes, but only single-parent commits can establish a matching integration. One aggregate permits at most 32 history loads and 8192 raw change records. Missing history, malformed evidence, or a cap retains separate new identities and reports partial coverage; already established shared-ancestor identities remain usable. Equivalence compares committed blobs, not checkout newline formatting or whitespace-insensitive patch IDs.

Across may first show a provisional opened-checkout-only snapshot while the full scan runs. Feature totals and In play are explicitly incomplete; participant counts and details remain unknown until full identity is resolved. Same-scope Refresh retains the existing board and editor during loading. Reconciliation preserves newer view/selection changes and unsaved editor context; a failed full read retains usable provisional or last-known content with an error and Refresh retry.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The browser's **Across worktrees** board reads `GET /api/worktree-workspace` for

The source menu separately reads `GET /api/worktree-sources`: this lists discovered Git checkouts without roadmap parsing, ancestry aggregation, or participant lookup. Cached choices are discovery evidence only. Opening a choice uses `GET /api/worktree-source-workspace` with that identity in `X-Minimap-Source-Context` and its repository header; the response contains `{source, workspace}` with a fresh validated roadmap binding. Subsequent item operations use the bound route family. Discovery refresh never replaces an editor's captured context or draft, and failed refresh retains last-known choices with an unavailable cue. A failed checkout open can be retried with Refresh or the current-source choice, which rediscovers before binding. Counts distinguish discovered checkouts from loaded roadmaps and participant coverage.

Aggregate identity accepts shared-ancestor ID/path continuity or an exact complete repository transition matching a historical squash integration. Matching a new item's ID/path or content alone is insufficient. The whole-change comparison includes every changed path, mode and old/new committed blob, and retains later source edits as versions; delete/re-add breaks continuity. Independently reproducing the same complete change is indistinguishable in Git and is treated as equivalent. Squash inspection is cached and bounded to 64 first-parent single-parent commits per history, 4 MiB per Git response, and 32 history loads / 8192 raw change records per aggregate. Missing, unsupported, malformed or capped evidence keeps new identities separate and reports partial coverage while retaining proven inherited identities.
Aggregate identity accepts shared-ancestor ID/path continuity or an exact complete repository transition matching a historical squash integration. Matching a new item's ID/path or content alone is insufficient. The whole-change comparison includes every changed path, mode and old/new committed blob, and retains later source edits as versions; delete/re-add breaks continuity. Independently reproducing the same complete change is indistinguishable in Git and is treated as equivalent. Squash inspection traverses first-parent histories, including merges, but only a single-parent commit can establish a matching integration. It is cached and bounded to 64 commits per history, 4 MiB per Git response, and 32 history loads / 8192 raw change records per aggregate. Missing, malformed or capped evidence keeps new identities separate and reports partial coverage while retaining proven inherited identities.

## Roadmap snapshots and observations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ async function transitionHistory(source, base, cache, signal) {
for (let i = 0; i < tokens.length; i += 1) {
const token = tokens[i].replace(/^\n/, "");
if (!token) continue;
const header = token.match(/^commit ([0-9a-f]{40,64}) ([0-9a-f]{40,64})$/i);
const header = token.match(/^commit ([0-9a-f]{40,64}) ((?:[0-9a-f]{40,64})(?: [0-9a-f]{40,64})*)$/i);
if (header) {
if (commits.length >= 64) throw new Error("squash-evidence-limit");
commits.push({ commit: header[1], parent: header[2], changes: new Map() });
const parents = header[2].split(" ");
commits.push({ commit: header[1], parent: parents[0], merge: parents.length > 1, changes: new Map() });
continue;
}
const change = token.match(/^:([0-7]{6}) ([0-7]{6}) ([0-9a-f]{40,64}) ([0-9a-f]{40,64}) [AMDT]$/i);
Expand Down Expand Up @@ -118,7 +119,7 @@ async function squashPaths(left, right, base, candidates, cache, signal) {
const histories = [await transitionHistory(left, base, cache, signal), await transitionHistory(right, base, cache, signal)];
const objects = new Map();
for (const [index, history] of histories.entries()) {
const integrations = new Set(histories[1 - index].commits.map((entry) => entry.signature));
const integrations = new Set(histories[1 - index].commits.filter((entry) => !entry.merge).map((entry) => entry.signature));
for (const prefix of history.prefixes) {
if (!integrations.has(prefix.signature)) continue;
for (const file of candidates.keys()) {
Expand Down Expand Up @@ -178,7 +179,8 @@ async function sharedPaths(left, right, roadmapPath, cache, signal) {
const key = `${base}:${source.git.headCommit}`;
let paths = cache.deletions.get(key);
if (!paths) {
const output = await git(source.repoRoot, "log", "-z", "--format=", "--name-only", "--diff-filter=D", "--no-renames", `${base}..${source.git.headCommit}`, "--", ...dirs, { signal });
const output 8000 = await git(source.repoRoot, "log", "-z", "--format=", "--name-only", "--diff-filter=D", "--no-renames",
"--diff-merges=first-parent", `${base}..${source.git.headCommit}`, "--", ...dirs, { signal });
paths = new Set(output.split("\0").filter(Boolean));
cache.deletions.set(key, paths);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ async function transitionHistory(source, base, cache, signal) {
for (let i = 0; i < tokens.length; i += 1) {
const token = tokens[i].replace(/^\n/, "");
if (!token) continue;
const header = token.match(/^commit ([0-9a-f]{40,64}) ([0-9a-f]{40,64})$/i);
const header = token.match(/^commit ([0-9a-f]{40,64}) ((?:[0-9a-f]{40,64})(?: [0-9a-f]{40,64})*)$/i);
if (header) {
if (commits.length >= 64) throw new Error("squash-evidence-limit");
commits.push({ commit: header[1], parent: header[2], changes: new Map() });
const parents = header[2].split(" ");
commits.push({ commit: header[1], parent: parents[0], merge: parents.length > 1, changes: new Map() });
continue;
}
const change = token.match(/^:([0-7]{6}) ([0-7]{6}) ([0-9a-f]{40,64}) ([0-9a-f]{40,64}) [AMDT]$/i);
Expand Down Expand Up @@ -118,7 +119,7 @@ async function squashPaths(left, right, base, candidates, cache, signal) {
const histories = [await transitionHistory(left, base, cache, signal), await transitionHistory(right, base, cache, signal)];
const objects = new Map();
for (const [index, history] of histories.entries()) {
const integrations = new Set(histories[1 - index].commits.map((entry) => entry.signature));
const integrations = new Set(histories[1 - index].commits.filter((entry) => !entry.merge).map((entry) => entry.signature));
for (const prefix of history.prefixes) {
if (!integrations.has(prefix.signature)) continue;
for (const file of candidates.keys()) {
Expand Down Expand Up @@ -178,7 +179,8 @@ async function sharedPaths(left, right, roadmapPath, cache, signal) {
const key = `${base}:${source.git.headCommit}`;
let paths = cache.deletions.get(key);
if (!paths) {
const output = await git(source.repoRoot, "log", "-z", "--format=", "--name-only", "--diff-filter=D", "--no-renames", `${base}..${source.git.headCommit}`, "--", ...dirs, { signal });
const output = await git(source.repoRoot, "log", "-z", "--format=", "--name-only", "--diff-filter=D", "--no-renames",
"--diff-merges=first-parent", `${base}..${source.git.headCommit}`, "--", ...dirs, { signal });
paths = new Set(output.split("\0").filter(Boolean));
cache.deletions.set(key, paths);
}
Expand Down
Loading
Loading
0