Skip to content

feat(bridge-core): add enumerateTraversalIds for bridge traversal path enumeration#117

Merged
aarne merged 2 commits intotraversal_id_doingfrom
copilot/add-enumerate-traversal-ids-function
Mar 9, 2026
Merged

feat(bridge-core): add enumerateTraversalIds for bridge traversal path enumeration#117
aarne merged 2 commits intotraversal_id_doingfrom
copilot/add-enumerate-traversal-ids-function

Conversation

Copy link
Contributor

Copilot AI commented Mar 9, 2026

Adds enumerateTraversalIds(bridge: Bridge): TraversalEntry[] — enumerates the finite set of execution paths through a bridge's wires, determined purely by structure (independent of runtime values). Intended for complexity assessment and future execution engine monitoring integration.

Wire traversal classification

  • primary — main pull source
  • fallback|| (falsy) or ?? (nullish) gate alternatives, with gateType and fallbackIndex
  • catch — error recovery via catch gate
  • empty-array — one per array iterator scope (no elements to process)
  • then / else — ternary conditional branches
  • const — constant-value wires

Plain array source wires (no fallbacks/catch) are excluded since they always execute; the empty-array entry covers the "no elements" outcome.

Example

import { parseBridge } from "@stackables/bridge-parser";
import { enumerateTraversalIds } from "@stackables/bridge-core";

const doc = parseBridge(`version 1.5
bridge Query.demo {
  with a
  with b
  with input as i
  with output as o
  a.q <- i.q
  b.q <- i.q
  o.result <- a.value || b.value catch i.fallback
}`);
const bridge = doc.instructions.find(i => i.kind === "bridge");
enumerateTraversalIds(bridge);
// [
//   { id: "q/primary",        kind: "primary",  wireIndex: 0, target: ["q"] },
//   { id: "q#1/primary",      kind: "primary",  wireIndex: 1, target: ["q"] },
//   { id: "result/primary",   kind: "primary",  wireIndex: 2, target: ["result"] },
//   { id: "result/fallback:0", kind: "fallback", wireIndex: 2, target: ["result"], fallbackIndex: 0, gateType: "falsy" },
//   { id: "result/catch",     kind: "catch",    wireIndex: 2, target: ["result"] },
// ]

Changes

  • New packages/bridge-core/src/enumerate-traversals.ts with enumerateTraversalIds and TraversalEntry type
  • Exported from bridge-core index (auto-reexported via umbrella package)
  • 14 tests covering all wire variants, both problem statement examples, ID uniqueness, and complexity ordering

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@changeset-bot
Copy link

changeset-bot bot commented Mar 9, 2026

⚠️ No Changeset found

Latest commit: 4ba106c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Enumerates all possible traversal paths through a Bridge.
Each entry represents a unique code path determined by the wire
structure (fallback chains, catch gates, array scopes, ternary
branches). Useful for complexity assessment and future integration
into the execution engine for monitoring.

Co-authored-by: aarne <82001+aarne@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 9, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bridge 4ba106c Commit Preview URL

Branch Preview URL
Mar 09 2026, 07:10 AM

@aarne aarne changed the base branch from main to traversal_id_doing March 9, 2026 07:11
Copilot AI changed the title [WIP] Add function to enumerate traversal ids for bridges feat(bridge-core): add enumerateTraversalIds for bridge traversal path enumeration Mar 9, 2026
Copilot finished work on behalf of aarne March 9, 2026 07:11
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

🐰 Bencher Report

Branchcopilot/add-enumerate-traversal-ids-function
Testbedubuntu-latest

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencynanoseconds (ns)
compiled: absolute baseline (passthrough, no tools)📈 view plot
⚠️ NO THRESHOLD
0.00 ns
compiled: array + SYNC tool-per-element 10📈 view plot
⚠️ NO THRESHOLD
0.01 ns
compiled: array + SYNC tool-per-element 100📈 view plot
⚠️ NO THRESHOLD
0.02 ns
compiled: array + tool-per-element 10📈 view plot
⚠️ NO THRESHOLD
0.01 ns
compiled: array + tool-per-element 100📈 view plot
⚠️ NO THRESHOLD
0.04 ns
compiled: chained 3-tool fan-out📈 view plot
⚠️ NO THRESHOLD
0.00 ns
compiled: flat array 10 items📈 view plot
⚠️ NO THRESHOLD
0.01 ns
compiled: flat array 100 items📈 view plot
⚠️ NO THRESHOLD
0.02 ns
compiled: flat array 1000 items📈 view plot
⚠️ NO THRESHOLD
0.12 ns
compiled: nested array 10x10📈 view plot
⚠️ NO THRESHOLD
0.02 ns
compiled: nested array 20x10📈 view plot
⚠️ NO THRESHOLD
0.05 ns
compiled: nested array 5x5📈 view plot
⚠️ NO THRESHOLD
0.01 ns
compiled: short-circuit (overdefinition bypass)📈 view plot
⚠️ NO THRESHOLD
0.00 ns
compiled: simple chain (1 tool)📈 view plot
⚠️ NO THRESHOLD
0.00 ns
exec: absolute baseline (passthrough, no tools)📈 view plot
⚠️ NO THRESHOLD
0.00 ns
exec: array + SYNC tool-per-element 10📈 view plot
⚠️ NO THRESHOLD
0.10 ns
exec: array + SYNC tool-per-element 100📈 view plot
⚠️ NO THRESHOLD
0.89 ns
exec: array + tool-per-element 10📈 view plot
⚠️ NO THRESHOLD
0.11 ns
exec: array + tool-per-element 100📈 view plot
⚠️ NO THRESHOLD
1.02 ns
exec: chained 3-tool fan-out📈 view plot
⚠️ NO THRESHOLD
0.04 ns
exec: flat array 10 items📈 view plot
⚠️ NO THRESHOLD
0.02 ns
exec: flat array 100 items📈 view plot
⚠️ NO THRESHOLD
0.08 ns
exec: flat array 1000 items📈 view plot
⚠️ NO THRESHOLD
0.74 ns
exec: nested array 10x10📈 view plot
⚠️ NO THRESHOLD
0.13 ns
exec: nested array 20x10📈 view plot
⚠️ NO THRESHOLD
0.25 ns
exec: nested array 5x5📈 view plot
⚠️ NO THRESHOLD
0.05 ns
exec: short-circuit (overdefinition bypass)📈 view plot
⚠️ NO THRESHOLD
0.00 ns
exec: simple chain (1 tool)📈 view plot
⚠️ NO THRESHOLD
0.01 ns
parse: large bridge (20 handles x 5 wires)📈 view plot
⚠️ NO THRESHOLD
1.33 ns
parse: simple bridge📈 view plot
⚠️ NO THRESHOLD
0.04 ns
🐰 View full continuous benchmarking report in Bencher

@aarne aarne marked this pull request as ready for review March 9, 2026 07:28
@aarne aarne merged commit f1aefca into traversal_id_doing Mar 9, 2026
4 checks passed
@aarne aarne deleted the copilot/add-enumerate-traversal-ids-function branch March 9, 2026 07:28
aarne added a commit that referenced this pull request Mar 9, 2026
* feat(bridge-core): add enumerateTraversalIds for bridge traversal path enumeration (#117)

* Initial plan

* feat(bridge-core): add enumerateTraversalIds function

Enumerates all possible traversal paths through a Bridge.
Each entry represents a unique code path determined by the wire
structure (fallback chains, catch gates, array scopes, ternary
branches). Useful for complexity assessment and future integration
into the execution engine for monitoring.

Co-authored-by: aarne <82001+aarne@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: aarne <82001+aarne@users.noreply.github.com>

* feat: runtime execution trace bitmask tracking with manifest view (#119)

* Initial plan

* feat: add execution trace bitmask to core engine

- Add bitIndex to TraversalEntry for bitmask encoding
- Add buildTraversalManifest (alias for enumerateTraversalIds)
- Add decodeExecutionTrace to decode bitmask back to entries
- Add buildTraceBitsMap for runtime wire→bit lookup
- Add traceBits/traceMask to TreeContext interface
- Inject trace recording in resolveWires (primary/fallback/catch/then/else)
- Add executionTrace to ExecuteBridgeResult
- Propagate trace mask through shadow trees
- All existing tests pass (133 execute-bridge + 64 resilience + 14 traversal)

Co-authored-by: aarne <82001+aarne@users.noreply.github.com>

* test: add comprehensive tests for execution trace feature

- Test buildTraversalManifest alias and bitIndex assignment
- Test decodeExecutionTrace with empty/single/multiple/round-trip
- Test end-to-end trace collection: primary, fallback, catch, then/else, const
- All 27 tests pass

Co-authored-by: aarne <82001+aarne@users.noreply.github.com>

* feat: add execution trace and manifest view to playground

- Add executionTrace to RunResult type in engine
- Pipe executionTrace through runBridgeStandalone
- Add getTraversalManifest and decodeExecutionTrace helpers to engine
- Show execution trace badge (hex) in ResultView
- Add Manifest tab to Bridge DSL panel header
- ManifestView shows all traversal entries with kind badges
- Active paths highlighted with ring + dot based on execution trace
- Works across mobile and desktop layouts

Co-authored-by: aarne <82001+aarne@users.noreply.github.com>

* refactor: address code review feedback

- Rename dslTab → activeDslTab for clarity
- Rename fi → fallbackIndex in applyFallbackGates loop
- Add comment explaining bitmask check in decodeExecutionTrace
- Add INVARIANT comment for traceMask/traceBits coupling
- Document bitIndex assignment lifecycle in enumerateTraversalIds

Co-authored-by: aarne <82001+aarne@users.noreply.github.com>

* feat: BigInt trace mask, manifest grouping/filtering, scroll fix

- Switch traceMask from number to bigint for unlimited entry support
- Update all recording helpers to use BigInt bitwise ops
- Update decodeExecutionTrace, ExecuteBridgeResult, TreeContext
- Update playground engine, ResultView, Playground types
- ManifestView: group entries by wire, show group headers for alternatives
- ManifestView: add "Show alternatives only" toggle filter
- ManifestView: fix scrolling with h-full / max-h-[60vh]
- Update tests to use bigint assertions
- All 1143 tests pass

Co-authored-by: aarne <82001+aarne@users.noreply.github.com>

* fix: add aria-label to manifest group count for accessibility

Co-authored-by: aarne <82001+aarne@users.noreply.github.com>

* feat: source descriptions, alias labels, empty-array grouping, always-on toggle

- Add `description` field to TraversalEntry with human-readable source info
  (e.g., "api.username", "|| \"Anonymous\"", "catch continue", "= \"SBB\"")
- Fix alias wires showing as `*` — use `to.field` for `__local` module targets
- Fix empty-array entries grouped under same `*` — assign unique wireIndex per scope
- Handle map resolves tool, input, context, pipe, and alias refs to handle aliases
- Filter toggle always visible regardless of whether alternatives exist
- Consistent group headers shown for all entries (not just alternatives)
- Empty-array entries show iterator variable in description (e.g., "c[] empty")
- All 1143 tests pass

Co-authored-by: aarne <82001+aarne@users.noreply.github.com>

* UI tweaks

* LSP for dead code in playground

* Docs

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: aarne <82001+aarne@users.noreply.github.com>
Co-authored-by: Aarne Laur <aarne.laur@gmail.com>

* Rename

* feat: add SocialIcons component and update social links in config

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: aarne <82001+aarne@users.noreply.github.com>
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.

2 participants