Skip to content

refactor(precedence): absorb firstNonEmpty helper variants into one precedence.First enforcer (links-va-001-precedence-jg6.1)#207

Merged
brandon-fryslie merged 1 commit into
masterfrom
absorb-precedence-helper
Jun 10, 2026
Merged

refactor(precedence): absorb firstNonEmpty helper variants into one precedence.First enforcer (links-va-001-precedence-jg6.1)#207
brandon-fryslie merged 1 commit into
masterfrom
absorb-precedence-helper

Conversation

@brandon-fryslie

Copy link
Copy Markdown
Collaborator

Summary

Closes out epic links-va-001-precedence-jg6 (F-14, Pattern C — mode flags hidden in helper-function variants).

Of the six filed sites, three were already absorbed as side effects of #202#204 (config.first, workspace.firstNonEmptyTrimmed, error_output.firstNonEmptyString). The three survivors — templates.firstNonEmpty, cli.firstNonEmptySyncBranch, cli.firstNonEmptySyncRemote (the sync pair byte-identical under two names) — collapse into one enforcer: internal/precedence.First.

Design deviation from the epic sketch (with reason, family precedent 4-for-4)

The filed sketch proposed Precedence{candidates []string; trim bool}. Not implemented as filed, because a trim bool is itself the Pattern-C mode flag this epic exists to kill ([LAW:no-mode-explosion]), and inspection shows the trim distinction is illusory:

  • sync.go — every candidate (validatedUpstreamRemote, singleRemote, debugOverride, defaultBranch) is already TrimSpace'd where it is produced; the trim inside the helpers was duplicate enforcement.
  • templates.go — template content must never be trimmed.

So trim is a property of the value at its production boundary (the PathSpec trim-at-construction precedent, [LAW:single-enforcer]), and resolution is mode-free: variability lives in the values ([LAW:dataflow-not-control-flow]). Behavior at every callsite is byte-identical to before.

Tests

  • New precedence package test matrix pins the contract, including the deliberate "whitespace is a value, not emptiness" semantics.
  • Helper-specific TestFirstNonEmptySyncBranchFollowsDeterministicPriority deleted — it asserted the removed structure ([LAW:behavior-not-structure]); its cases live in the matrix.
  • go vet ./... and full go test ./... clean.

…recedence.First enforcer (links-va-001-precedence-jg6.1)

Three surviving helper variants (templates.firstNonEmpty,
cli.firstNonEmptySyncBranch, cli.firstNonEmptySyncRemote — the latter two
byte-identical) collapse into internal/precedence.First.

The epic's proposed trim bool is deliberately not implemented: every sync
candidate is already trimmed where it is produced, and template content
must never be trimmed — so trim is a property of the value at its
production boundary (the PathSpec precedent), not a mode of resolution.
[LAW:no-mode-explosion] [LAW:single-enforcer]

Helper-specific sync test becomes the precedence package test matrix.

The other three filed sites (config.first, workspace.firstNonEmptyTrimmed,
error_output.firstNonEmptyString) were already absorbed by #202-#204.

@github-actions github-actions 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.

Z.ai Coding Agent Review

Clean refactoring consolidating three duplicate firstNonEmpty helpers into a single precedence.First. No LAW violations introduced. The "trim at source, not at resolution" design is correct — all callsites trim their candidates before passing them. The new test suite covers the removed tests' contract plus edge cases. No changes requested.

✅ Approved

@brandon-fryslie brandon-fryslie merged commit 0edad0e into master Jun 10, 2026
6 checks passed
@brandon-fryslie brandon-fryslie deleted the absorb-precedence-helper branch June 10, 2026 08:53
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