Skip to content

2-keyed-delta-fold — generic keyed zip-fold per #6121 steer: diff = keyed fold into algebraic codomain, Unchanged vanishes BY MONOID LAW; three-way = join-semilattice, Conflict = join of incomparables with NO apply arm (structural); attach to v2.std.change or consciously de-fork (no parallel Hunk/Pa - #6129

Merged
briansrls merged 12 commits into
mainfrom
session/swift-cat-141
Jul 2, 2026

Conversation

@gunbai-bot

@gunbai-bot gunbai-bot Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds std.change as the generic keyed delta fold carrier: two-way diff folds keyed rows into a KeyedPatch monoid (unchanged rows vanish by identity, never filtering); three-way fold uses KeyedLeafVerdict as the single authority (verdict is the plan) with KeyedConflict absorbing and structurally having no apply arm.
  • Re-exports the carrier surface from v2.std.change for compiler-layer consumers without minting parallel Hunk/Patch vocabulary.
  • Migrates gunbc.host_identity_knob onto the carrier (srv1 hostname slice stays green).
  • Adds gunbc.host_converge_delta with a two-key runner memory-cap fixture demonstrating collection fold (acceptance Remove LLM response caching module #9).

Scope fence: converge_knob_values_equal compares desired strings only and does not satisfy per-ConvergeTarget semantics (RunnerWidth / VerifyOnlyCap / GunbcPinnedTree axes remain scaffold — live runner-cap converge is not unblocked by this PR alone).

Merge order (operator)

Test plan

  • gunbc run --source-root dsl --entry dsl/test/claim/keyed_delta_fold_witness_test.dag --function keyed_delta_fold_keystone_holds --claim-run → true
  • gunbc run --source-root dsl --entry dsl/test/claim/host_converge_delta_witness_test.dag --function host_converge_delta_keystone_holds --claim-run → true
  • gunbc run --source-root dsl --entry dsl/test/claim/host_identity_observation_witness_test.dag --function host_identity_observation_holds --claim-run → true (host-identity migration)
  • Post-host-identity-assimilation-b: persisted v0/v1 base + closed-loop converge + srvX rows #6130 integration: re-run host-identity + srv1 witnesses after rebase onto main

@gunbai-bot
gunbai-bot Bot marked this pull request as ready for review July 2, 2026 04:18
@gunbai-bot

gunbai-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the three blocking findings from adversarial verification:

1. Decorative algebra — keyed_two_way_diff / keyed_three_way_fold now fold through keyed_patch_monoid / keyed_three_way_patch_monoid; per-row mappers return empty patch on KeyedUnchanged (identity contribution). keyed_leaf_verdict_join is called from keyed_three_way_patch_insert_entry. Post-hoc noop filter removed from fold path. New witnesses: patch monoid left/right identity, associativity, fold_matches_diff, three_way_patch_monoid_identity, leaf_verdict_join identity.

2. Plan state-space — KeyedConvergePlan gains KeyedPlanAdd / KeyedPlanRemove; keyed_plan_from_verdict maps Added/Removed distinctly (no longer fused into KeyedPlanApply{from:v,to:v}). Witness: witness_plan_add_is_not_remove.

3. Round-trip laws — Added witness_apply_diff_law_added/removed and witness_inverse_retract_law_added/removed.

All three keystones green by execution on 86cbccfe6b.

— sent from swift-cat-141

@gunbai-bot

gunbai-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Addressing claude-opus-4-7 REQUEST_CHANGES findings:

1. Parallel KeyedLeafVerdict / KeyedConvergePlan — fixed. Deleted KeyedConvergePlan and keyed_plan_from_verdict / keyed_plan_has_apply_arm entirely. KeyedLeafVerdict is now the single three-way authority (verdict is the plan). Witnesses match on verdict variants directly (witness_verdict_add_is_not_remove, etc.).

2. KeyedAdded/KeyedRemoved name collision — fixed. Two-way diff kinds renamed to KeyedDiffAdded / KeyedDiffRemoved / KeyedDiffModified. Three-way leaf add/remove renamed to KeyedVerdictAdded / KeyedVerdictRemoved.

3. Predicate dissolution — fixed in std.change. Removed keyed_plan_has_apply_arm, keyed_leaf_has_apply_arm, keyed_leaf_is_noop, keyed_leaf_is_conflict, keyed_hunk_kind_equal, and keyed_key_in_list. Patch-level folds now match structurally inline; domain wrappers in host_identity_knob retain thin structural matches (not re-exported predicates). Attempted nested KeyedVerdictMutation wrapper for full inhabitance split — v1 compiler rejects nested record variant in generic coproduct (type/variant name collision); flat 5-arm verdict with deleted predicates is the working construction.

4. Double-walk insert — fixed. keyed_three_way_patch_insert_entry now single-passes via KeyedThreeWayInsertAcc.

All three keystones green by execution post-commit.

— sent from swift-cat-141

@gunbai-bot

gunbai-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Addressing claude-opus-4-7 round-2 findings:

1. Predicate dissolution in std/ — fixed. Removed keyed_three_way_has_conflict / keyed_three_way_has_apply from std.change. Added canonical KeyedLeafVerdictFold + keyed_leaf_verdict_fold as the single catamorphism site for KeyedLeafVerdict. Domain layers (host_converge_delta, host_identity_converge, host_identity_assimilation) compose Bool questions through the fold; deleted the three 5-arm wrappers from host_identity_knob.

2. Redundant recomputation in keyed_three_way_row — fixed. Deleted unused keyed_three_way_row entirely (zero call sites; fold path uses keyed_three_way_row_patch which computes verdict once).

3. Unused key_eq + fail-open Added/Modified — fixed. KeyedDiffHunk is now a coproduct (KeyedDiffAddedHunk / KeyedDiffRemovedHunk / KeyedDiffModifiedHunk) with required to/from fields — malformed absent-target hunks are unwritable. Removed unused key_eq from keyed_apply_row.

All three keystones green by execution.

— sent from swift-cat-141

@gunbai-bot

gunbai-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

keyed_leaf_verdict_join join-semilattice idempotency — fixed.

The Added/Removed arms now mirror ApplyHunk: join(Added{v}, Added{v}) and join(Removed{v}, Removed{v}) return a when values agree via equal, and only escalate to KeyedConflict on disagreement or cross-kind mismatch. Unchanged remains the bottom (Unchanged ⊔ x = x, x ⊔ Unchanged = x).

New witnesses: witness_leaf_verdict_join_added_idempotent, witness_leaf_verdict_join_removed_idempotent, witness_leaf_verdict_join_added_disagree_is_conflict. All three keystones green.

Nit on unused Added/Removed arms at host-identity fold sites acknowledged — three_way_leaf only emits ApplyHunk/Unchanged/Conflict today; Added/Removed are keyed-row presence axes exercised by converge fixtures and generic witnesses.

— sent from swift-cat-141

@gunbai-bot

gunbai-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Addressing claude-opus-4-7 APPROVE non-blocking notes:

1. Added hunk key collision — fixed (was valid). KeyedDiffAddedHunk arm now filter-then-append, symmetric with Modified. Witness: witness_apply_added_is_upsert (double-apply preserves snapshot).

2. Thin converge scaffold marker — fixed. Added converge_knob_values_equal_dissolution_trigger naming the per-target normalization dissolve condition (string-equality on desired only remains scaffold until single semantics authority lands).

Thanks for the APPROVE — acknowledged alongside composer-2.5 approval.

— sent from swift-cat-141

@gunbai-bot

gunbai-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Non-blocking observation (downstream is_* walkers) — addressed.

Deleted host_converge_three_way_has_conflict / host_converge_three_way_has_apply from host_converge_delta (has_apply was unused). The one witness site now calls keyed_leaf_verdict_fold directly — no product-layer Bool predicate re-wrapping the 5-arm match.

Thanks for the APPROVE.

— sent from swift-cat-141

briansrls and others added 12 commits July 2, 2026 06:44
Model std.change as the single authority for keyed zip-fold diff/three-way
patch algebra (monoid identity, derived inverse, ConflictPlan with no apply
arm); migrate host_identity_knob onto it; add host_converge_delta fixture
consumer with law witnesses for all ten acceptance criteria.

Co-authored-by: Cursor <cursoragent@cursor.com>
…omain.

Route two-way and three-way folds through keyed_patch_monoid and
keyed_leaf_verdict_join so Unchanged vanishes by identity contribution,
add KeyedPlanAdd/Remove to distinguish add/remove plans, and witness
monoid laws plus Added/Removed round-trip laws.

Co-authored-by: Cursor <cursoragent@cursor.com>
Delete KeyedConvergePlan (verdict is the plan), prefix two-way diff
kind variants as KeyedDiff* and three-way add/remove as KeyedVerdict*,
remove std.change is_/has_ predicates and keyed_hunk_kind_equal/
keyed_key_in_list, single-pass keyed_three_way_patch_insert_entry,
and update witnesses/consumers to match structurally.

Co-authored-by: Cursor <cursoragent@cursor.com>
Mirror ApplyHunk agreement logic so join(x,x)=x for KeyedVerdictAdded
and KeyedVerdictRemoved, preserving join-semilattice laws for three-way
patch append; witness idempotent and disagree-to-Conflict cases.

Co-authored-by: Cursor <cursoragent@cursor.com>
…igger.

Filter existing key before append on KeyedDiffAddedHunk (symmetric with
Modified arm) to preserve row-key uniqueness; witness double-apply upsert.
Add converge_knob_values_equal_dissolution_trigger for scaffold marker.

Co-authored-by: Cursor <cursoragent@cursor.com>
Delete unused host_converge_three_way_has_apply and inline
keyed_leaf_verdict_fold at the single witness call site instead of
re-wrapping patch-level Bool walkers in product code.

Co-authored-by: Cursor <cursoragent@cursor.com>
@briansrls
briansrls force-pushed the session/swift-cat-141 branch from a004b9e to 3f5dc2a Compare July 2, 2026 06:45
@gunbai-bot

gunbai-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Rebased session/swift-cat-141 onto main (post-#6130). Conflicts resolved in:

Post-rebase witness receipts (execution):

  • keyed_delta_fold_keystone_holds → true
  • host_converge_delta_keystone_holds → true
  • host_identity_observation_holds → true (includes srv1 persisted-base + assimilation converge witnesses)

Merge conflict cleared; branch is rebased on current main.

— sent from swift-cat-141

@briansrls
briansrls merged commit 0a77bad into main Jul 2, 2026
1 of 2 checks passed
@briansrls
briansrls deleted the session/swift-cat-141 branch July 2, 2026 06:56
@gunbai-bot gunbai-bot Bot mentioned this pull request Jul 2, 2026
6 tasks
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