Commit Graph
5 Commits
Author SHA1 Message Date
zhengqiuyangandJD Davis 303f521812 fix(smart-crusher): keep container-shaped strings as strings in lossless tables (#4875)
## Description

A string cell in a `json` column whose text is a JSON **container**
(`"[]"`, `"{}"`, `"[1,2]"`) is
classified as `StringifiedJson` and un-escaped into
`CellValue::Scalar(parsed)`, so the cell renders
byte-identically to the real value it spells. The csv-schema decoder
cannot tell the two apart
afterwards: `expand_compacted` returns `[]` where the original had
`"[]"`, and with
`verify_lossless=True` (also forced by `mode="agent"`) the round-trip
check fails and the whole
message is reverted, silently dropping its compression.

This is the container-shaped remainder of #4053, which fixed the
scalar-looking case (`"null"`,
`"true"`, `"1"`). The formatter already knows how to render these
strings unambiguously
(`csv_formatter_json_column_quotes_strings_that_parse_as_json` covers
`"[1]"` and `'{"a":1}'`), but
`compact()` never lets them reach it as strings.

Closes #4874

## Type of Change

- [x] Bug fix (non-breaking change that fixes an issue)

## Changes Made

- `compactor::cell_from_value`: for `StringifiedJson` that is not an
array of objects, keep the
original string (`CellValue::Scalar(v.clone())`) instead of the parsed
value. The formatter's
existing ambiguous-text rule JSON-quotes it, so the decoder returns the
string.
- Nested behaviour is unchanged: a stringified **array of objects**
still becomes a nested table, so
`test_nested_table_markers_resolve_to_source_bytes` and its CCR markers
keep working.
- Rust regression test pinning the exact wire cells (`"[]"` for the
array, `"""[1]"""`-style for the
  string).
- Python regression test at the caller boundary (`_crush` +
`expand_compacted`).

## Testing

- [x] Unit tests pass (`cargo test -p headroom-core --lib` -> 1044
passed, 1 ignored)
- [x] `cargo fmt --all -- --check` clean
- [x] New tests added for new functionality
- [x] Manual testing performed

### Test Output

```text
$ cargo test -p headroom-core --lib compaction::
test result: ok. 74 passed; 0 failed; 0 ignored

$ cargo test -p headroom-core --lib
test result: ok. 1044 passed; 0 failed; 1 ignored

# with the fix reverted, the new Rust test fails:
left: "\"[]\""
right: "\"\"\"[]\"\"\""
```

## Real Behavior Proof

- Environment: Windows 11, Python 3.12, Rust 1.100
`x86_64-pc-windows-gnu`, repo `main` at
  `fda75de5`
- Exact command / steps: `cargo test -p headroom-core --lib

compaction::compactor::tests::stringified_container_strings_keep_their_identity`;
the test builds

`[{id:0,v:[]},{id:1,v:"[]"},{id:2,v:[1,2]},{id:3,v:"[1,2]"},{id:4,v:{}},{id:5,v:"{}"}]`,
compacts
  it, and asserts the rendered `v` cells.
- Observed result: without the change the array and the string render
the same cell (`"[]"`); with
  it the string renders as the JSON string literal (`"""[]"""`), which
  `expand_compacted` maps back to `"[]"`.
- Not tested: the Python regression test could not be executed locally
because this machine cannot
build the native extension (Rust build stopped in `icu_segmenter` under
the GNU toolchain); it is
  included for CI, where the wheel is built normally.

## Runtime Rollout Safety

- Rollout-managed feature(s): none; the change is in the lossless table
codec only.
- Minimum rollout channel: n/a
- Stable/default behavior changed: a stringified JSON container in a
table cell now stays a string
in the densified text (it was displayed as the parsed value). This is
required for the documented
reversibility of `csv-schema`; the model sees a JSON string literal
instead of nested JSON.
- Kill switch / disable path: n/a (lossless path)
- Unsafe override required: no
- Qualification impact: none
- Rollback path: revert the single `cell_from_value` branch.

## Review Readiness

- [x] I have performed a self-review
- [x] This PR is ready for human review

## Checklist

- [x] My code follows the project's style guidelines

<!-- devin-review-badge-begin -->

---

<a href="https://app.devin.ai/review/headroomlabs-ai/headroom/pull/4875"
target="_blank"><picture><source media="(prefers-color-scheme: dark)"
srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img
src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4"
alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->

Co-authored-by: JD Davis <mxjerrett@gmail.com>
2026-11-16 23:50:47 -06:00
Andrew Barnes 75df01d627 fix(codec): reject densified blocks with mismatched row counts (#4271)
## Description

`expand_compacted()` now rejects blocks whose `[N]` header disagrees
with the number of CSV records. Previously, `[3]{id:int}\n1\n2\n`
returned two records as though the original array had been
reconstructed, leaving callers unable to distinguish truncation from
successful expansion.

The decoder returns its existing `None` failure result on mismatch.
Valid multiline cells, single-column missing values, empty arrays and
the tolerated trailing blank line retain their behavior.

Compatibility limit: existing trailing-empty-row normalization can
discard an extra empty CSV record. This patch does not distinguish that
record from a trailing blank-line artifact; it validates the count after
that normalization.

## Type of Change

- [x] Bug fix

## Changes Made

- Validate the parsed CSV record count after dictionary legends and
existing trailing-newline normalization.

## Testing

- [x] Focused unit tests pass (full suite limitation below)
- [x] Linting passes
- [x] Type checking passes on macOS (Windows limitation below)
- [x] New regression tests added
- [x] Manual testing performed

- Eight new regression cases failed before the fix and pass after it
(missing/extra rows, empty bodies, dictionary-encoded values, and
JSON-string wrappers).
- Codec and live-agent densification suites: **41 passed on Windows and
41 passed on macOS arm64**.
- Repository-wide `ruff check .`: passed (Ruff 0.17.0).
- Changed-file `ruff format --check`: passed.
- `mypy --follow-imports=silent --ignore-missing-imports
headroom/transforms/compaction_codec.py`: passed.
- Full `pytest -x` attempt stopped at collection: optional `fastapi` is
not installed in this environment. The full suite is not claimed green.
- Repository pre-commit hooks passed except full-project mypy on
Windows: seven existing POSIX-only `os` attribute errors in unchanged
`fileperms.py` and `proxy/interceptors/astgrep.py`. Scoped codec type
checking passed.
- Full-project mypy 1.20.2 on macOS: **no issues found in 572 source
files** (`uvx --from mypy==1.20.2 mypy --ignore-missing-imports
headroom`).

### Test Output

```text
python -m pytest tests/test_transforms/test_compaction_codec.py tests/test_densify_agent_mode.py -q
Windows / Python 3.13.12: 41 passed in 2.74s
macOS arm64 / Python 3.13.15: 41 passed in 2.99s
```

## Real Behavior Proof

- Environment: Windows, Python 3.13.12, current Python source with the
published Headroom 0.41.0 native wheel. No provider API calls, ML model
downloads or mocks. `HEADROOM_TELEMETRY=off`, `HEADROOM_BEACON=0`,
`HEADROOM_OFFLINE=1`; `gpt-4o` used only for token counting.

- Exact command / steps: Run the Python snippet below from the checkout
after installing the native extension.

```python
import json
from headroom import densify, expand_compacted

records = [{"id": i, "name": f"item_{i}", "status": "active"} for i in range(100)]
result = densify(
    [{"role": "tool", "tool_call_id": "demo", "content": json.dumps(records)}],
    model="gpt-4o", protect_recent=0,
)
block = result.messages[0]["content"]
if block.startswith('"'):
    block = json.loads(block)
assert expand_compacted(block) == records
truncated = block.rstrip("\n").rsplit("\n", 1)[0] + "\n"
print(f"Full block: {len(records)} records recovered exactly")
print(f"After removing the last data row: {expand_compacted(truncated)!r}")
assert expand_compacted(truncated) is None
```

- Observed result: All 100 records recovered exactly; deleting the final
row returns `None`.

```text
Full block: 100 records recovered exactly
After removing the last data row: None
```

- Not tested: full optional-dependency suite, native-source rebuild,
live provider/proxy traffic. This change does not validate every
possible malformed CSV cell; its scope is the declared row count.

## Runtime Rollout Safety

- Rollout-managed feature(s): none.
- Minimum rollout channel: not applicable.
- Stable/default behavior changed: malformed row-count blocks return
`None`.
- Kill switch / disable path: no new flag; revert this commit.
- Unsafe override required: no.
- Qualification impact: no dependency or wire-format change.
- Rollback path: revert this commit to restore prior decoder behavior.

## Review Readiness

- [x] I have performed a self-review
- [x] This PR is ready for human review

## Checklist

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation (decoder
docstring)
- [x] My changes generate no new warnings in the checks run
- [x] I have added tests that prove my fix is effective
- [x] New and existing focused unit tests pass locally with my changes
- [x] I did **not** edit `CHANGELOG.md`

## Screenshots (if applicable)

Not applicable; decoder behavior is shown above.

## Additional Notes

The pre-push hook's documented bypass was used because Windows has no
`make`, and the Mac validation environment has no Rust toolchain. The
full native `ci-precheck` is unverified. Windows pre-commit mypy was
skipped after the same pinned full-project check passed on macOS; all
other pre-commit checks passed.

<!-- devin-review-badge-begin -->

---

<a href="https://app.devin.ai/review/headroomlabs-ai/headroom/pull/4271"
target="_blank"><picture><source media="(prefers-color-scheme: dark)"
srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img
src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4"
alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->
2026-11-03 19:28:06 -06:00
3c1fcbdfde fix(compaction): reject negative dictionary indices and non-array legends in expand_compacted (#4470)
## Description

`expand_compacted()` promises `None` when a densified block cannot be
losslessly reversed, but value-factored (`__dict:K`) cells were decoded
with raw Python indexing:

- a wire index of `-1` silently decoded to the **last** legend value
(data corruption, no error);
- a non-array legend (`@tag=42`, `@tag="ab"`, `@tag={"a":1}`,
`@tag=null`) raised `TypeError`/`KeyError` or was indexed character by
character.

Fixes #4280

## Type of Change

- [x] Bug fix (non-breaking change that fixes an issue)

## Changes Made

- `headroom/transforms/compaction_codec.py`: reject a legend whose JSON
payload is not a list; reject negative dictionary indices before
indexing. Both paths return `None`, as the docstring already promises.
- `tests/test_transforms/test_compaction_codec.py`: regression tests for
the negative index, four non-array legend shapes, and a guard that valid
first/last indices, a quoted literal `"-1"`, `null`, and missing cells
in a dictionary column still decode.

## Testing

- [x] Unit tests pass locally
- [x] New tests added for the fix

```
$ python -m pytest tests/test_transforms/test_compaction_codec.py tests/test_densify_agent_mode.py -q
37 passed in 1.58s

# with the codec fix reverted, new tests:
5 failed, 1 passed, 17 deselected

$ ruff check / ruff format --check (touched files)
All checks passed! / 2 files already formatted
```

## Real Behavior Proof

- Environment: Windows 11, Python 3.12, local build of headroom with
native `headroom._core`, branch rebased on upstream/main
- Exact command / steps: `expand_compacted('[1]{tag:string}
__dict:1\n@tag=["first","last"]\n-1\n')` and
`expand_compacted('[1]{tag:string} __dict:1\n@tag=42\n0\n')`, plus the
codec and densify-agent-mode test files above
- Observed result: before: `[{"tag": "last"}]` and `TypeError`; after:
`None` for both; full codec + agent densification suites pass (37 tests)
- Not tested: declared row-count mismatch validation (separate issue
#4271)

## Runtime Rollout Safety

- Rollout-managed feature(s): none
- Minimum rollout channel: n/a, decoder correctness fix
- Stable/default behavior changed: only for malformed blocks, which now
return None instead of wrong data or an exception
- Kill switch / disable path: n/a
- Unsafe override required: no
- Qualification impact: none
- Rollback path: revert this commit

## Review Readiness

- [x] I have performed a self-review
- [x] This PR is ready for human review

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- devin-review-badge-begin -->

---

<a href="https://app.devin.ai/review/headroomlabs-ai/headroom/pull/4470"
target="_blank"><picture><source media="(prefers-color-scheme: dark)"
srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img
src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4"
alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: JD Davis <mxjerrett@gmail.com>
2026-10-28 23:34:33 -05:00
Suliman AbdulrazzaqandJerrettDavis 3db1a94443 fix(smart-crusher): keep string cells in json columns from decoding as other types (#4053)
## Description

The SmartCrusher lossless table (`csv-schema`) types a column `json`
when its cells mix types, for example `[26]{id:int,v:json?}`.
`_decode_cell` in `headroom/transforms/compaction_codec.py` reads every
cell of a `json` column with `json.loads` and only keeps the raw text
when that fails. The Rust encoder did not know the column type when it
rendered a string cell, so strings that spell a JSON value came back as
that value:

- the string `null` was written `"null"` and decoded as `None`
- the string `true` was written `true` (byte-identical to the bool) and
decoded as `True`
- the string `1` was written `1` and decoded as the int `1`
- `NaN` decoded as a float nan, and the string `"q"` (a string that
carries its own quotes) decoded as `q`

A string that parses as a JSON array or object (`[1]`, `{"a":1}`) never
reaches the formatter as a string: the classifier already un-escapes it
(`CellClass::StringifiedJson`), which is existing behavior and is not
changed here.

This changes the encoder only. In a column whose type tag is `json`, a
string cell is now written as a JSON string literal (then CSV-quoted)
when `json.loads` could parse it into something else. The decoder
already returns the string for that form, so it is not touched.
Everything else renders as before.

"Could parse into something else" is a conservative superset: after
trimming JSON white space (space, tab, newline, carriage return), the
text starts with `[`, `{`, `"`, `-` or an ASCII digit, or is exactly
`true`, `false`, `null`, `NaN` or `Infinity`.

## Type of Change

- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [ ] Performance improvement
- [ ] Code refactoring (no functional changes)

## Changes Made

-
`crates/headroom-core/src/transforms/smart_crusher/compaction/formatter.rs`:
`write_table` works out once which columns have type tag `json` and
passes that flag to `format_cell`. For a `Value::String` cell in such a
column, `is_ambiguous_json_text` decides whether it is rendered as
`csv_quote(serde_json::to_string(s))`. Non-string cells, the
`string`/`int`/`float`/`bool` columns, the JSON formatter and the
Markdown-KV formatter are unchanged. Bucketed tables go through
`write_table` too, so they get the same treatment.
- Rust tests in the same file:
`csv_formatter_json_column_quotes_strings_that_parse_as_json` (13
strings, exact wire output, with a `string` column as control),
`csv_formatter_json_column_leaves_other_strings_alone`, and
`csv_formatter_json_column_tells_strings_from_values`, which goes
through `compact` + `CsvSchemaFormatter` so the column type really comes
out as `json`, and checks that the string `"true"` and the bool `true`
no longer share a wire form.
- `tests/test_transforms/test_compaction_codec.py`: one test that
decodes a hand-written block using the new wire form next to the bare
forms for real values. It documents the contract the Rust change relies
on and passes with or without this change, since the decoder is not
changed.

## Testing

- [ ] Unit tests pass (`pytest`)
- [x] Linting passes (`ruff check` on the touched test file; `cargo fmt`
and `cargo clippy -D warnings` in CI)
- [ ] Type checking passes (`mypy headroom`)
- [x] New tests added for new functionality
- [x] Manual testing performed

### Test Output

```text
# Rust, GitHub Actions run on our fork (toolchain 1.95.0)
https://github.com/SulimanAbdulrazzaq/headroom/actions/runs/37829441316
  cargo fmt --all -- --check                                 ok
  cargo clippy -p headroom-core --all-targets -- -D warnings ok
  cargo test -p headroom-core smart_crusher                  345 passed; 0 failed
    (342 on main in run 37827119554; the 3 new tests are the difference)
  csv_formatter_json_column_leaves_other_strings_alone ... ok
  csv_formatter_json_column_quotes_strings_that_parse_as_json ... ok
  csv_formatter_json_column_tells_strings_from_values ... ok

# Python, 3.12
$ pytest tests/test_transforms/test_compaction_codec.py -q
17 passed   (16 existing + 1 new)
$ ruff check tests/test_transforms/test_compaction_codec.py          All checks passed!
$ ruff format --check tests/test_transforms/test_compaction_codec.py 1 file already formatted
```

## Real Behavior Proof

- Environment: Rust core built and tested on `ubuntu-latest` in GitHub
Actions with Rust 1.95.0 (the repository pin). Python 3.12.13 on Windows
11 for the decoder test and the reproducer.
- Exact command / steps: a script crushes 26 records `{"id": i, "v":
...}` whose `v` cycles through the strings `null`, `true`, `1`, `NaN`
and other values, decodes the result with `expand_compacted`, and
compares each row with its input. The encoded header is
`[26]{id:int,v:json?}`. In CI: `cargo test -p headroom-core
smart_crusher`.
- Observed result: before the change (the Rust core of the installed
`headroom-ai` 0.40.0 wheel), 8 of 26 rows differ, for example `'null'
(str) -> None`, `'true' (str) -> True`, `'1' (str) -> 1`, `'NaN' (str)
-> nan`. After the change the new Rust test shows the string `null` in a
`json` column is written `"""null"""` and the string `hello` is still
written `hello`; in the real-path test (through `compact` and
`CsvSchemaFormatter`) the rows are `1,"""null"""`, `2,null`,
`3,"""true"""`, `4,true`, `5,"""1"""`, `6,1`, `7,hello`, so each string
and each value has its own wire form. The Python test shows the decoder
returns `'null'`, `None`, `'true'`, `True`, `'1'`, `1`, `'NaN'` for such
a block.
- Not tested: the 26-row Python reproducer against a freshly built core
(the installed wheel on my machine is older and cannot see the Rust
change), and the Python wheel end to end. The Python decoder was not
changed.

### Maintainer native qualification (2026-10-08)

- Environment: Windows 11, Rust/MSVC, Python 3.12.13. This head contains
current `main`; contributor formatter logic was not modified.
- Exact commands: `cargo test -p headroom-core --lib
transforms::smart_crusher::compaction --locked`; `cargo build -p
headroom-py --features extension-module --locked`; then the PR's
`tests/test_transforms/test_compaction_codec.py` suite using that newly
built extension. A standalone native SmartCrusher/Python decoder probe
also encoded and decoded 100 records containing mixed
string/null/bool/numeric cells.
- Observed: **73 Rust compaction tests and 17 Python codec tests
passed**. The 100-record probe preserved every value and Python type,
including literal strings `null`, `true`, `false`, `1`, `NaN`,
`Infinity`, `-Infinity`, whitespace, quotes, empty strings, and embedded
newlines. No native encoder/decoder boundary was mocked.
- Scope: JSON-container-looking strings (`[1]`, `{"a":1}`) retain the
classifier's pre-existing `StringifiedJson` behavior. They are
explicitly outside this formatter repair; the author clarified that
limitation in the test. This PR fixes mixed-column primitive-literal
strings that actually reach the formatter, and does not claim a new
container-string round-trip contract.
- Hosted CI is tracked by the maintainer at this exact head; approval
remains pending until all applicable current checks pass.

## Runtime Rollout Safety

- Rollout-managed feature(s): none
- Minimum rollout channel: n/a
- Stable/default behavior changed: the lossless table text changes only
for string cells that look like JSON literals inside `json`-typed
columns. All other cells and all other column types render as before.
- Kill switch / disable path: n/a
- Unsafe override required: no
- Qualification impact: none
- Rollback path: revert this commit. Older decoders read the new form
correctly, because it is a plain quoted JSON string, so nothing else
needs to change.

## Review Readiness

- [x] I have performed a self-review
- [x] This PR is ready for human review

## Checklist

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [x] I did **not** edit `CHANGELOG.md` — it is generated by
release-please from my Conventional Commit PR title (a CI guard enforces
this)

## Additional Notes

Rust tests ran in CI on a fork, not locally, because the machine used
for development has no linker for the Rust toolchain. `mypy` and the
full Python suite were not run, only the touched test file. No other
test or fixture in the repository asserts the wire form of a string in a
`json` column (searched `crates`, `tests`, `docs` and `headroom` for
`json?` and `:json`).

---------

Co-authored-by: JerrettDavis <mxjerrett@gmail.com>
2026-10-08 22:40:54 -05:00
84f0e84dcc feat(compress): live-agent densify mode, lossless and cache-safe (#1402)
## Description

Revised 2026-10-05 after review: the codec now decodes main's native
null encoding (bare `null` = null, empty cell = missing key) with no
formatter change, and agent-mode `tokens_after` is recounted with
`count_messages` after factoring and reverts.

Adds an opt-in agent densification mode that only shrinks content,
verifies reversibility message by message, and reverts any output that
cannot be proven lossless. It also adds a pure-Python inverse decoder
and reversible low-cardinality value factoring for the existing
`csv-schema` format.

## Type of Change

- [x] Bug fix (non-breaking change that fixes an issue)
- [x] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [x] Performance improvement
- [ ] Code refactoring (no functional changes)

## Changes Made

- Add `compress(mode="agent")` and `densify()` with verified-lossless
fallback.
- Add public `expand_compacted()` and `is_compacted()` helpers.
- Decode `csv-schema` cells exactly as main's native formatter (#3665)
encodes them: empty cell = missing key, bare `null` = null, quoted `""`
/ `"null"` = strings. This PR no longer changes the Rust formatter.
- Recount `tokens_after` with the pipeline tokenizer's `count_messages`
after agent-mode value factoring and lossless reverts.
- New `CompressConfig` / `CompressResult` fields sit after
`diagnostics`, so existing positional construction is unchanged.
- Add reversible value factoring only when it reduces output size.
- Preserve current `main` dependency placement, security pins, CCR
gating, and Windows ONNX initialization.

## Testing

- [x] Unit tests pass (`pytest`)
- [x] Linting passes (`ruff check .`)
- [x] Type checking passes (`mypy headroom`)
- [x] New tests added for new functionality
- [ ] Manual testing performed

### Test Output

```text
tests/test_transforms/test_compaction_codec.py + tests/test_densify_agent_mode.py: 30 passed (native extension built from this branch)
tests/test_compress_*.py + tests/test_transforms/ + agent-mode suite: 577 passed, 67 skipped
cargo test -p headroom-core --lib compaction: 73 passed
ruff check / ruff format --check on touched files: passed
```

## Real Behavior Proof

- Environment: macOS, locked `uv` environment, native extension built
from this branch, `HEADROOM_*` env scrubbed
- Exact command / steps: public `headroom.densify()` on a tool result of
40 records with three repeated long paths, some `null` paths and some
literal `"null"` strings
- Observed result: `factored: True | reverted: 0 | lossless: True`;
`tokens_before: 1269 | tokens_after: 407 |
count_messages(result.messages): 407`; `expand_compacted(content) ==
records: True`
- Not tested: live multi-turn prompt-cache hit rate and proxy wiring;
agent mode remains an opt-in library API

## Runtime Rollout Safety

- Rollout-managed feature(s): none; `mode="agent"` / `densify()` is an
opt-in library API
- Minimum rollout channel: not applicable (library opt-in, not wired
into the proxy)
- Stable/default behavior changed: no; default `compress()` and native
formatter output are unchanged
- Kill switch / disable path: do not pass `mode="agent"` / do not call
`densify()`
- Unsafe override required: no
- Qualification impact: none for the proxy path
- Rollback path: revert this PR

## Review Readiness

- [x] I have performed a self-review
- [x] This PR is ready for human review

## Checklist

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [x] I did **not** edit `CHANGELOG.md` — it is generated by
release-please from my Conventional Commit PR title (a CI guard enforces
this)

## Screenshots (if applicable)

Not applicable: this PR does not change a user interface.

## Additional Notes

The branch was rebuilt on current `main`. The older
dependency-relocation portion was intentionally omitted: current `main`
keeps those dependencies available and includes a security exclusion for
the compromised `ast-grep-cli` release. The current CCR gate already
supersedes the PR's older gate implementation and was retained.

<!-- devin-review-badge-begin -->

---

<a href="https://app.devin.ai/review/headroomlabs-ai/headroom/pull/1402"
target="_blank"><picture><source media="(prefers-color-scheme: dark)"
srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img
src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4"
alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->

---------

Co-authored-by: JerrettDavis <mxjerrett@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 08:28:46 -05:00