refactor(sandbox): cut echo mode's rebase conflict surface - #11
Merged
Conversation
echo mode stays -- it is the mechanism four CI-gated integration tests
and policies/wire-proof-local.yaml use to prove cred_inject
strip-and-replace on the wire, and there is no equivalent replacement
(the --debug-egress logging is a hardcoded allowlist of one request
header plus five response headers, and never logs stripped headers at
all; generalising it would write injected credential values into an
OCSF log that may be shipped off-box).
What it cost, though, was rebase pain out of all proportion to the
feature. Two changes fix that without touching behaviour:
1. relay.rs: the echo branch wrapped the pre-existing forward body in
`} else {`, indenting ~38 otherwise-unchanged lines by one level.
git counts that as 38 deletions plus 38 re-insertions, which made
this file one of the worst conflict hotspots against upstream.
Replaced with an early `continue` (the branch already sits inside
the `loop {` at line 650, and the forward path already treats
fall-through as "continue loop"), so the forward body returns to
upstream's exact indentation and drops out of the diff entirely.
`git diff -w` against the previous state is 3 insertions / 2
deletions -- the change really is just the de-indent.
2. proxy.rs: query_l7_route_snapshot was called twice per connection,
once early for the echo check and again later for L7 inspection.
It is a pure function of (engine, decision, host, port), all fixed
before either call, with no await between them; its only side
effect is an ocsf_emit! on the error path. Merged into one call,
which also stops a double emission of that error event.
Fork delta against the merge base, across the three affected files:
before 830 insertions / 62 deletions
after 793 insertions / 24 deletions
Deletion churn -- the part that actually collides on rebase, since it
marks rewritten upstream lines rather than appends -- drops 61%.
l7/rest.rs is byte-identical to before, so the echo JSON response
contract (echo, method, path, query, headers, body_length, policy,
cred_inject_applied) is untouched and needs no re-verification.
Verified: cargo check and clippy --workspace --all-targets with
--features openshell-prover/bundled-z3 both exit 0; 722 tests pass in
openshell-supervisor-network, 83 in openshell-policy; the 6 echo tests
pass unchanged; cargo fmt --check clean.
Signed-off-by: Jakub Kovaľ <kuba.koval@gmail.com>
Pre-existing markdown lint violation in the fork's own --volume delta that fails 'mise run pre-commit' on a clean tree, blocking any commit in this repo. Fixed separately from the echo removal so it can be cherry-picked or dropped independently. Signed-off-by: Jakub Kovaľ <kuba.koval@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Review artifact for an openlock-side fork change. Not intended to merge via this PR — fork
mainlands by rebase + force-push.echomode stays. It is the mechanism four CI-gated integration tests andpolicies/wire-proof-local.yamluse to prove cred_inject strip-and-replace on the wire, and there is no equivalent replacement: the--debug-egresslogging is a hardcoded allowlist of one request header plus five response headers, and it never logs stripped headers at all — so a log-based assertion would pass unconditionally and couldn't catch a real strip regression. Generalising that logging isn't an option either; it would write injected credential values into an OCSF log that may be shipped off-box, whichAGENTS.mdforbids.What echo did cost was rebase pain out of all proportion to the feature. Two changes fix that without touching behaviour.
Changes
1.
l7/relay.rs— remove theelse-wrapper entanglement. The echo branch wrapped the pre-existing forward body in} else {, indenting ~38 otherwise-unchanged lines by one level. git counts that as 38 deletions plus 38 re-insertions, which made this file one of the worst conflict hotspots against upstream. Replaced with an earlycontinue— the branch already sits inside theloop {at line 650, and the forward path already treats fall-through as "continue loop" — so the forward body returns to upstream's exact indentation and drops out of the diff entirely.git diff -wagainst the previous state is 3 insertions / 2 deletions: the change really is just the de-indent.2.
proxy.rs— merge the duplicate route query.query_l7_route_snapshotwas called twice per connection, once early for the echo check and again later for L7 inspection. It is a pure function of(engine, decision, host, port), all fixed before either call, with no.awaitbetween them; its only side effect is anocsf_emit!on the error path. Merged into one call, which also stops a double emission of that error event.Impact
Fork delta against the merge base, across the affected files:
Deletion churn — the part that actually collides on rebase, since it marks rewritten upstream lines rather than appends — drops 61%.
l7/rest.rsis byte-identical to before, so the echo JSON response contract (echo,method,path,query,headers,body_length,policy,cred_inject_applied) is untouched and needs no re-verification.An intermediate approach that extracted a shared rewrite function plus a separate
run_echo_relayorchestration loop was rejected: it reached 976/27, moving ~246 insertions intorest.rs(itself a top-5 hotspot, and where upstream's40194f93lands) and introducing a second lower-fidelity orchestration loop that could drift. The early-continue beats it on both axes for roughly one line.Also includes a one-line MD022 fix for a pre-existing markdown lint failure in
docs/sandboxes/manage-sandboxes.mdxthat was blockingmise run pre-commiton a clean tree.Testing
cargo checkandcargo clippy --workspace --all-targets --features openshell-prover/bundled-z3— both exit 0openshell-supervisor-network, 83 inopenshell-policycargo fmt --checkandmise run markdown:lint:mdcleanmise run pre-commit'srust:checkfails locally for an unrelated reason (the task omits--features bundled-z3and this machine has no system libz3; it dies inside z3-sys's build script).