* fix(schema,uow): cover the proxied data-behind path and make its consent step runnable (post-merge #6659)
Post-merge review of the landed range d0063ac..e1e1158 (PR #6659, the
release/1.3.0 backport of #6658) raised two majors. Neither is a regression
from that PR; both are gaps its surface left open.
F-A — the uow/proxied path never reached the #6575 stop, and its blunt body
prescribed the wedge. `doltSQLProvider.initSchema` passed a nil adopter to
`CheckSharedStoreMigrateGate`, so `localDataBehind` short-circuited and routing
could never emit `smartDataBehind`. A proxied store that was level on schema
and behind in data reported `shared-store` instead, whose body is the
designated-migrator recipe — `bd migrate --force` then `bd dolt push` — which
in that state is exactly the #6368 wedge the stop exists to prevent. The
refusal was always safe (the shared arm suppresses the auto-migrate either
way); the guidance was not.
Only `AheadBehind` is wired. It is the complete data-behind predicate, while
leaving `IsStrictAncestor`/`WorkingSetClean` nil keeps `routeAdoptFastForward`
false, so the remote-AHEAD arm on this path keeps the plain adopt directive it
has today. `FastForward` stays nil: it is a write that would promote the schema
for every co-resident client.
The remedy also had to be topology-correct before it could be printed.
`bd dolt pull` is refused at the proxied front door
(`proxy.dolt_pull.unsupported`), as are `bd dolt push`, `bd migrate` and
`bd conflicts` — so the body, agent directive and `options` now name the
machine the pull runs on, and the option id becomes
`pull-first-on-server-host`. The don't-force warning gains
`BD_ALLOW_REMOTE_MIGRATE=1`, the one consent surface the proxy does not refuse.
Read-only proxied opens print the pull-first block instead of the shared
consent template.
The proxied fact is the caller's, not the provider's: `newSQLServerUOWProvider`
is also `bd serve`'s provider for SERVER-mode workspaces, where that pull
works. A new `uow.WithProxiedServerMode()` is set only by
`openProxiedServerUOWProvider`.
F-B — the shared data-behind consent step named a verb that cannot unlock a
remote-backed shared store. `sharedMigrateConsent` has one reader,
`sharedNoRemoteGate`, reachable only on the `!hasRemote` branch; a data-behind
stop has a remote by construction. The four surfaces now name
`SharedConsentCommandForced` (`bd migrate schema --force`) with its `--global`
twin, and the human/JSON `--global` retargets follow. Widening the verb consent
to the remote-backed arm was rejected: it would drop the designated-migrator
confirmation #4259 deliberately requires whenever a remote exists. This mirrors
PR #6692, the main-line remediation for the same defect on #6658, so the two
lines converge rather than diverge.
Tests: the consent step is proven by EXECUTING its path (a text assertion on
`Options()` is how the dead command shipped), with the bare verb as the
counterfactual; the proxied route is driven through `initSchema` against a
mocked behind-clone and asserts the body does not prescribe
`bd migrate --force`; a server-mode open pins that it keeps the runnable-here
remedy; a level clone pins that reading ancestry does not turn a genuine
first-mover into a stop.
Scope: the scorecard's two Required Changes only. Its non-gating items — F-C
(`noticeSharedMigrateRefusal` lacks an `IsDataBehind()` branch), F-D
(`warnRemoteSyncOpenRefusal` verbosity), F-E (`docs` not retargeted), F-F/F-G
(stale comments) — are left for separate follow-ups.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(schema,cli): the proxied consent step is not refused — say so (post-merge #6659 iter 2)
Post-merge review iteration 2 of PR #6695 found one major: the proxied
data-behind guidance this PR added asserts that its own prescribed consent
step, `bd migrate schema --force`, is refused at the proxied front door. It
is not.
The refusal table keys on the full command path. `proxyMaintenanceRefusals`
registers the bare `migrate` verb and its hooks/issues/sync children, but has
no `migrate schema` row, so the two-word path misses the lookup and
`validateProxyMaintenanceBeforeProvider` falls through to nil. `bd migrate
schema` then runs its proxied arm, which reports the migration the provider
open already applied under that verb's consent.
That makes the claim wrong in the unsafe direction: `forceOrEnvConsent` is
read BEFORE the data-behind stop is routed, so an operator told "it is refused
here anyway" who types it to confirm applies the migration to a data-behind
shared store — the #6368 wedge, reachable from the exact topology this
remediation was written for. The don't-force warning made it worse by
presenting BD_ALLOW_REMOTE_MIGRATE=1 as the only consent surface this
workspace can reach.
Reworded to the truth on all five surfaces, and pinned so it cannot drift
again:
- dataBehindBody's proxied consent clause now says the step CAN be run here
and that the precondition is temporal, not locational: run it only after
the pull lands on the server host.
- the proxied don't-force warning names `bd migrate schema --force` alongside
BD_ALLOW_REMOTE_MIGRATE=1 as the two reachable consent surfaces, both
honored before this stop is reached.
- the consent option's When/Risk drop "bd migrate is refused in
proxied-server mode" and say the pull-first half is load-bearing here
because this one does NOT fail closed the way the pull does.
- CHANGELOG drops "the one consent surface the proxy does not refuse".
- the same false premise is corrected in the uow test comment.
- TestProxyMaintenanceAllowsTheSharedConsentVerb resolves the command from
SharedConsentCommandForced through the same cobra lookup the root pre-run
uses, asserts validateProxyMaintenanceBeforeProvider returns nil for it,
and keeps the bare `bd migrate` refusal (proxy.migrate.unsupported) as the
counterfactual. No test called that function with this command before,
which is why the false wording shipped green.
Also the two non-gating consistency findings from the same iteration:
- `--json` gate["expected"] carries the location qualifier when Proxied, so
an expected-only reader is not handed a locally-refused command while
options/hint carry it. Extracted to dataBehindExpectedField so the
qualifier does not add a branch to handleRemoteMigrateGateJSON (cognitive
stays 33, cyclomatic 18).
- fallbackReasonNote's data-behind arm gates its remedy on Proxied; the note
prints after the body, so unqualified it made the last paragraph prescribe
what the paragraph above called refused.
- smart_remote_migrate_gate.go's injection-site comment no longer says the
shared UOW provider wires neither callback; it wires AheadBehind only.
Tests: ./internal/storage/schema (full, ok), ./cmd/bd -run
'Migrate|Consent|Proxy|RemoteGate|DataBehind|SharedStore|RemoteSyncOpen'
(ok), ./internal/storage/uow -run 'DataBehind|Proxied|MigrateGate' (ok).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>