Skip to content

refactor(context_compressor): extract skill-prune/ghost-skill cluster (LB2) - #80628

Open
andrexibiza wants to merge 2 commits into
NousResearch:mainfrom
andrexibiza:gfg/cc-lb2-skill-prune-2
Open

refactor(context_compressor): extract skill-prune/ghost-skill cluster (LB2)#80628
andrexibiza wants to merge 2 commits into
NousResearch:mainfrom
andrexibiza:gfg/cc-lb2-skill-prune-2

Conversation

@andrexibiza

@andrexibiza andrexibiza commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

God-file Feature Package (tracker #78647): agent/context_compressor.py slice LB2 — extract the skill-prune / ghost-skill defense cluster into agent/context_compressor_skill_prune.py with an is-identical re-export seam.

Slice

  • God-file: agent/context_compressor.py (6,883 lines @ pin 6e9cae6ac4b)
  • Window: 404–618 banner-inclusive (pin numbering; re-anchored at leaf commit 2b7a1b97807)
  • Golden sha256: ec5defbef6a402ad302b28369c81f5f9182162f1c8353b231d2d863fe59305c0 — byte-exact, verified by 5/5 blind reviewers
  • Module: agent/context_compressor_skill_prune.py (12 members: 6 constants + 6 functions)
  • Deps: one-way into context_compressor_text_utils (leaf extract refactor(context_compressor): extract text-util leaves into context_compressor_text_utils #80626) — no cycle (W2 C1 resolved)
  • Seam: godfile re-exports all 12 members; cc.<m> is sp.<m> verified at runtime

Verification

  • 35/35 targeted tests (seam + ghost-skill + redaction + zero-user-guard + text-utils seam)
  • 5/5 blind re-review APPROVED (0 CRITICAL / 0 IMPORTANT)
  • ruff clean · git diff --check clean · LF-only · DCO signed
  • Collision census clean

Part of #78645
Part of #78647

Prior Work / Attribution

Related work searched (multiple methods, all states, before finalizing this PR):

Unlinked related work (stars not bound to this PR by keywords):

Builds on: #80626 (context_compressor_text_utils leaf dependency, one-way, no cycle).
Merge-order / dependency: merge #80626 before #80628.
Duplicates: none — no existing PR covers the LB2 skill-prune/ghost-skill cluster.

Prior Work / Attribution

Prior credit — the humans whose work this builds on, before anyone else:

If a related artifact has no attributable human author, say so plainly rather than crediting a ticket number as if it were a person.

Related work searched (multiple methods, all states, before finalizing this PR):

Unlinked related work (stars not bound to this PR by keywords):

Builds on: @andrexibiza, #80626 (context_compressor_text_utils leaf dependency, one-way, no cycle).
Merge-order / dependency: merge #80626 before #80628.
Duplicates: none — no existing PR covers the LB2 skill-prune/ghost-skill cluster.

…ll-prune

Wave-2 dual REQUEST_CHANGES agreed LB2 skill-prune cannot extract first:
it calls _redact_compaction_text and _content_text_for_contains (cycle).
Move those two pure leaves into context_compressor_text_utils.py with
is-identical re-export through the godfile. Golden bodies byte-exact.

Part of NousResearch#78645
Part of NousResearch#78647

Signed-off-by: Andrex Ibiza <andrexibiza@users.noreply.github.com>
… (LB2)

Wave-2 redraw: banner-inclusive window 404-618 (golden
ec5defbef6a402ad302b28369c81f5f9182162f1c8353b231d2d863fe59305c0) into
context_compressor_skill_prune.py. Deps on the two text-util leaves now
import one-way from context_compressor_text_utils — no cycle. 12 members
re-exported is-identical through the godfile. 35/35 targeted tests green.

Part of NousResearch#78645
Part of NousResearch#78647

Signed-off-by: Andrex Ibiza <andrexibiza@users.noreply.github.com>
@andrexibiza

Copy link
Copy Markdown
Contributor Author

Interlock: Part of #78645 + #78647. 5/5 blind APPROVED receipts in worktree tmp/PASS_*_VERDICT.md.

@alt-glitch alt-glitch added type/refactor Code restructuring, no behavior change comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint area/compression Context compression and continuation sessions P3 Low — cosmetic, nice to have sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Aug 6, 2026
@andrexibiza

Copy link
Copy Markdown
Contributor Author

Interlock completion for the context-compressor shard campaign:

The full related set is explicitly recorded in #81074, including the prior compressor shards, same-surface colliders/fixers, and their referenced issue nodes. The residual agent/context_compressor.py remains alive until the 2k Law is satisfied.

@Enough1122

Copy link
Copy Markdown
Contributor

AI code review — automated review for reference, author can ignore or act on any point.

refactor(context_compressor): extract skill-prune/ghost-skill cluster (LB2)

Declared god-file extraction with clean module boundaries and is-identity seam tests — this is the shape of refactor the repo wants. Observations:

  1. tests/agent/test_context_compressor_skill_prune_seam.py / test_context_compressor_text_utils_seam.py — the test_no_duplicate_defs_in_godfile tests read the god-file source (Path(cc.__file__).read_text() + src.count("def ...") == 0) to assert no duplicate definitions remain. This is a source-reading test, which the repo's testing guidelines explicitly ban ("Never read source code in tests"): it fails on formatting-only changes and passes even if a duplicate def were wired wrong. The is-identity assertions in test_all_members_resolve_is_identical_through_godfile already guard the real contract (the god file re-exports the same object); the source-grep tests can be dropped without losing behavioral coverage.
  2. test_import_orders_no_cycle uses importlib.reload on live modules mid-suite. It works, but reload is notoriously order-dependent (other tests importing the same modules can observe half-reloaded state). Since the extraction already proves import-order independence at import time (the god file imports the leaf first), consider whether the reload-based test is worth its fragility, or scope it to a subprocess.
  3. agent/context_compressor.py — the new imports carry # noqa: E402; if the file's remaining structure allows it, hoisting the import block into the normal top-of-file import region would remove the suppression (cosmetic).
  4. Behavioral coverage: the seam tests assert identity + a small smoke path, but the extraction is a pure move — the pre-existing behavior tests for ghost-skill handling (prune markers, protected names, reinjection) in the compressor test suite are what actually guard the logic. Confirm those still run against the re-exported names (they should, since the god file re-exports the identical objects); if any old test imported the helpers from context_compressor by name, the is-identity seam keeps them valid — good.
  5. Minor: context_compressor_skill_prune.py has a double blank line after the import block (lines 336-337) — style nit only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/compression Context compression and continuation sessions comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/refactor Code restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants