refactor(bridge-core): extract gate helpers from resolveWiresAsync#85
Merged
refactor(bridge-core): extract gate helpers from resolveWiresAsync#85
Conversation
|
Co-authored-by: aarne <82001+aarne@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor resolveWiresAsync to reduce complexity
refactor(bridge-core): extract gate helpers from resolveWiresAsync
Mar 4, 2026
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bridge | 93c5f03 | Commit Preview URL Branch Preview URL |
Mar 04 2026, 09:28 PM |
Contributor
Contributor
|
| Branch | copilot/refactor-resolve-wires-async |
| Testbed | ubuntu-latest |
🚨 10 Alerts
| Benchmark | Measure Units | View | Benchmark Result (Result Δ%) | Upper Boundary (Limit %) |
|---|---|---|---|---|
| compiled: absolute baseline (passthrough, no tools) | Latency nanoseconds (ns) | 📈 plot 🚷 threshold 🚨 alert (🔔) | 0.00 ns(+7.69%)Baseline: 0.00 ns | 0.00 ns (103.57%) |
| compiled: array + tool-per-element 10 | Latency nanoseconds (ns) | 📈 plot 🚷 threshold 🚨 alert (🔔) | 0.01 ns(+5.03%)Baseline: 0.01 ns | 0.01 ns (101.42%) |
| compiled: chained 3-tool fan-out | Latency nanoseconds (ns) | 📈 plot 🚷 threshold 🚨 alert (🔔) | 0.00 ns(+6.52%)Baseline: 0.00 ns | 0.00 ns (101.02%) |
| compiled: flat array 10 items | Latency nanoseconds (ns) | 📈 plot 🚷 threshold 🚨 alert (🔔) | 0.01 ns(+7.48%)Baseline: 0.01 ns | 0.01 ns (102.90%) |
| compiled: nested array 10x10 | Latency nanoseconds (ns) | 📈 plot 🚷 threshold 🚨 alert (🔔) | 0.02 ns(+8.82%)Baseline: 0.02 ns | 0.02 ns (105.09%) |
| compiled: nested array 20x10 | Latency nanoseconds (ns) | 📈 plot 🚷 threshold 🚨 alert (🔔) | 0.04 ns(+8.80%)Baseline: 0.03 ns | 0.03 ns (105.50%) |
| compiled: nested array 5x5 | Latency nanoseconds (ns) | 📈 plot 🚷 threshold 🚨 alert (🔔) | 0.01 ns(+6.76%)Baseline: 0.01 ns | 0.01 ns (103.85%) |
| compiled: short-circuit (overdefinition bypass) | Latency nanoseconds (ns) | 📈 plot 🚷 threshold 🚨 alert (🔔) | 0.00 ns(+6.55%)Baseline: 0.00 ns | 0.00 ns (102.07%) |
| compiled: simple chain (1 tool) | Latency nanoseconds (ns) | 📈 plot 🚷 threshold 🚨 alert (🔔) | 0.00 ns(+5.69%)Baseline: 0.00 ns | 0.00 ns (100.18%) |
| exec: short-circuit (overdefinition bypass) | Latency nanoseconds (ns) | 📈 plot 🚷 threshold 🚨 alert (🔔) | 0.00 ns(+14.45%)Baseline: 0.00 ns | 0.00 ns (105.82%) |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result nanoseconds (ns) (Result Δ%) | Upper Boundary nanoseconds (ns) (Limit %) |
|---|---|---|---|
| compiled: absolute baseline (passthrough, no tools) | 📈 view plot 🚷 view threshold 🚨 view alert (🔔) | 0.00 ns(+7.69%)Baseline: 0.00 ns | 0.00 ns (103.57%) |
| compiled: array + tool-per-element 10 | 📈 view plot 🚷 view threshold 🚨 view alert (🔔) | 0.01 ns(+5.03%)Baseline: 0.01 ns | 0.01 ns (101.42%) |
| compiled: array + tool-per-element 100 | 📈 view plot 🚷 view threshold | 0.03 ns(+3.51%)Baseline: 0.03 ns | 0.04 ns (96.68%) |
| compiled: chained 3-tool fan-out | 📈 view plot 🚷 view threshold 🚨 view alert (🔔) | 0.00 ns(+6.52%)Baseline: 0.00 ns | 0.00 ns (101.02%) |
| compiled: flat array 10 items | 📈 view plot 🚷 view threshold 🚨 view alert (🔔) | 0.01 ns(+7.48%)Baseline: 0.01 ns | 0.01 ns (102.90%) |
| compiled: flat array 100 items | 📈 view plot 🚷 view threshold | 0.01 ns(+4.45%)Baseline: 0.01 ns | 0.01 ns (98.86%) |
| compiled: flat array 1000 items | 📈 view plot 🚷 view threshold | 0.07 ns(+0.63%)Baseline: 0.07 ns | 0.07 ns (94.68%) |
| compiled: nested array 10x10 | 📈 view plot 🚷 view threshold 🚨 view alert (🔔) | 0.02 ns(+8.82%)Baseline: 0.02 ns | 0.02 ns (105.09%) |
| compiled: nested array 20x10 | 📈 view plot 🚷 view threshold 🚨 view alert (🔔) | 0.04 ns(+8.80%)Baseline: 0.03 ns | 0.03 ns (105.50%) |
| compiled: nested array 5x5 | 📈 view plot 🚷 view threshold 🚨 view alert (🔔) | 0.01 ns(+6.76%)Baseline: 0.01 ns | 0.01 ns (103.85%) |
| compiled: short-circuit (overdefinition bypass) | 📈 view plot 🚷 view threshold 🚨 view alert (🔔) | 0.00 ns(+6.55%)Baseline: 0.00 ns | 0.00 ns (102.07%) |
| compiled: simple chain (1 tool) | 📈 view plot 🚷 view threshold 🚨 view alert (🔔) | 0.00 ns(+5.69%)Baseline: 0.00 ns | 0.00 ns (100.18%) |
| exec: absolute baseline (passthrough, no tools) | 📈 view plot 🚷 view threshold | 0.00 ns(+11.89%)Baseline: 0.00 ns | 0.00 ns (90.62%) |
| exec: array + tool-per-element 10 | 📈 view plot 🚷 view threshold | 0.08 ns(+1.64%)Baseline: 0.07 ns | 0.10 ns (73.99%) |
| exec: array + tool-per-element 100 | 📈 view plot 🚷 view threshold | 0.68 ns(+1.38%)Baseline: 0.67 ns | 0.95 ns (71.54%) |
| exec: chained 3-tool fan-out | 📈 view plot 🚷 view threshold | 0.02 ns(+16.05%)Baseline: 0.01 ns | 0.02 ns (84.58%) |
| exec: flat array 10 items | 📈 view plot 🚷 view threshold | 0.01 ns(-8.03%)Baseline: 0.02 ns | 0.04 ns (38.51%) |
| exec: flat array 100 items | 📈 view plot 🚷 view threshold | 0.07 ns(-27.79%)Baseline: 0.10 ns | 0.35 ns (21.29%) |
| exec: flat array 1000 items | 📈 view plot 🚷 view threshold | 0.73 ns(-30.89%)Baseline: 1.06 ns | 4.26 ns (17.13%) |
| exec: nested array 10x10 | 📈 view plot 🚷 view threshold | 0.13 ns(-17.36%)Baseline: 0.15 ns | 0.42 ns (29.81%) |
| exec: nested array 20x10 | 📈 view plot 🚷 view threshold | 0.25 ns(-17.26%)Baseline: 0.30 ns | 0.86 ns (28.80%) |
| exec: nested array 5x5 | 📈 view plot 🚷 view threshold | 0.05 ns(-6.86%)Baseline: 0.05 ns | 0.12 ns (42.90%) |
| exec: short-circuit (overdefinition bypass) | 📈 view plot 🚷 view threshold 🚨 view alert (🔔) | 0.00 ns(+14.45%)Baseline: 0.00 ns | 0.00 ns (105.82%) |
| exec: simple chain (1 tool) | 📈 view plot 🚷 view threshold | 0.01 ns(+14.06%)Baseline: 0.01 ns | 0.01 ns (87.46%) |
| parse: large bridge (20 handles x 5 wires) | 📈 view plot 🚷 view threshold | 1.03 ns(+6.95%)Baseline: 0.97 ns | 1.32 ns (78.44%) |
| parse: simple bridge | 📈 view plot 🚷 view threshold | 0.03 ns(-10.59%)Baseline: 0.03 ns | 0.04 ns (63.48%) |
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.
resolveWiresAsynchandled all four resolution layers (Execution, Falsy Gate, Nullish Gate, Catch Gate) inline in a single try/catch, making each layer hard to reason about and impossible to unit test in isolation.Changes
WireWithGatestype —Exclude<Wire, { value: string }>scopes the gate helpers to non-constant wires onlyapplyFalsyGate— extracts Layer 2a (||): walksfalsyFallbackRefs, thenfalsyControl/falsyFallbackapplyNullishGate— extracts Layer 2b (??): appliesnullishControl/nullishFallbackRef/nullishFallbackapplyCatchGate— extracts Layer 3: recovers viacatchControl/catchFallbackRef/catchFallback, returnsundefinedwhen no handlerresolveWiresAsyncreduced to a clean pipeline:packages/bridge-core/test/resolve-wires-gates.test.tscovering each gate helper in isolation via a lightweight mockTreeContext, includingpullChainforwarding verificationOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.