Skip to content

chore(rust): re-land DocumentCompactor walker (squash-merge lost it from main)#288

Merged
chopratejas merged 1 commit intomainfrom
rust-stage-3c-2-pr3a-redux-walker
Apr 28, 2026
Merged

chore(rust): re-land DocumentCompactor walker (squash-merge lost it from main)#288
chopratejas merged 1 commit intomainfrom
rust-stage-3c-2-pr3a-redux-walker

Conversation

@chopratejas
Copy link
Copy Markdown
Owner

Summary

Re-lands the walker module that was lost when PR #285 (PR2) was squash-merged. The original PR3a (#286) was merged on GitHub on 2026-04-27, but because it was stacked on top of PR2's branch and PR2 was squash-merged, the walker commit (`4db4f46`) disappeared along with the intermediate history. This PR brings back the same content unmodified.

Type: `chore` — no new functionality, just a regression fix for the squash-merge accident. Using `chore` instead of `feat` so it doesn't bump the package version.

What the walker does

Recursive descent over any JSON value, applying lossless compaction at every compactable spot:

```rust
match value {
Object(m) => recurse into each field's value,
Array(xs) => recurse into items, then try TabularCompactor on the array,
String(s) => parse-as-JSON-and-recurse / CCR-substitute / leave,
scalar => unchanged,
}
```

Output: same JSON shape with compactable spots replaced by inline strings holding the rendered bytes. Wrapping object/array structure is preserved — only bulky leaves get replaced.

What stacks next

With the walker back, PR3b (document-level token budget + selective lossy escalation) can now build on top of it cleanly. Without the walker, PR3b had no place to plug in.

Tests

  • 13 walker unit tests pass.
  • 462/462 headroom-core lib tests overall.
  • 17/17 SmartCrusher parity fixtures byte-equal (untouched).
  • 185/185 Python tests pass.
  • `make ci-precheck` green.

Provenance

…rom main)

Stage 3c.2 PR3a-redux. The original PR3a (#286) was merged on GitHub
on 2026-04-27 but its content never reached main — its parent merge
(#285 PR2) was squash-merged, which drops commits stacked on top of
the source branch. The walker module disappeared along with the
intermediate commits.

This PR re-lands `walker.rs` and updates the `compaction/mod.rs`
re-exports — same content as commit 4db4f46 from the lost branch.
No new functionality, no behavior change for existing crusher paths.

# What the walker does (recap)

Recursive descent over any JSON value:

  match value {
    Object(m) => recurse into each field
    Array(xs) => recurse into items, then try TabularCompactor on the array
    String(s) => parse-as-JSON-and-recurse / CCR-substitute / leave
    scalar    => unchanged
  }

Compactable spots become inline strings holding the rendered bytes.
The wrapping JSON structure is preserved.

# Why chore, not feat

This is a re-land of previously-merged-but-lost code. No new feature
shipped — fixing a regression caused by the stacked-PR squash-merge
accident. Using `chore` keeps the version from bumping for what is
effectively a parity restoration.

# Tests

- 13 walker unit tests pass.
- 462/462 headroom-core lib tests overall.
- 17/17 SmartCrusher parity fixtures byte-equal (untouched).
- 185/185 Python tests pass.
- make ci-precheck green.

Module: crates/headroom-core/src/transforms/smart_crusher/compaction/walker.rs
@chopratejas chopratejas merged commit 7b1ce22 into main Apr 28, 2026
25 checks passed
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