Skip to content

tests(continuation/X5.1): add request-compaction-tool.test.ts β€” resolves bootstrap#542#165

Merged
ronan-dandelion-cult merged 1 commit intoflesh_beast_figs/20260414-claudefrom
tests/x5.1-request-compaction-tool
Apr 18, 2026
Merged

tests(continuation/X5.1): add request-compaction-tool.test.ts β€” resolves bootstrap#542#165
ronan-dandelion-cult merged 1 commit intoflesh_beast_figs/20260414-claudefrom
tests/x5.1-request-compaction-tool

Conversation

@ronan-dandelion-cult
Copy link
Copy Markdown

Summary

Implements swim-34/X5.1 test authoring per karmaterminal/openclaw-bootstrap#542. New file `src/agents/tools/request-compaction-tool.test.ts`, 10 tests (all passing).

Scope

All six cases called out in #542 plus four edge cases that close the `>70` vs `>=70` fencepost ambiguity the issue body flagged:

# Test Spec row
1 ToolInputError when `agentSessionKey` is absent (a)
2 ToolInputError when `sessionId` is absent (a)
3 `context_threshold` rejection when usage < `MIN_CONTEXT_THRESHOLD` (b)
4 Still rejects at 69% (just-below-floor edge) edge
5 Enqueues when usage β‰₯ `MIN_CONTEXT_THRESHOLD` with no rate limit (c)
6 Accepts at exactly 70% (inclusive-floor edge) edge (fencepost resolved)
7 `rate_limit` rejection within `RATE_LIMIT_MS` window (d)
8 Accepts again once rate-limit window has elapsed edge
9 `[already-pending]` short-circuit does NOT re-enter `triggerCompaction` (e)
10 Documented status markers stable (`compaction_requested` / `rejected` / `already_pending`) (f)

Fencepost resolution

Source is `if (contextUsage < MIN_CONTEXT_THRESHOLD) { reject }` β€” so exactly 70% is accepted (inclusive floor). Tests 4 + 6 pin that. The spec's prose wobbled between `>70` and `>=70`; the source is the source of truth and the spec can match it going forward.

Uses existing test helpers

All state manipulation goes through the exported `_resetGuardState`, `_setPending`, `_resetVolitionalCounts`, and `_guards` helpers from the source module β€” no internal-state poking, no prototype mutation, per the repo testing guide.

Run it

```
pnpm test src/agents/tools/request-compaction-tool.test.ts

β†’ 10 passed, 553ms

```

Out of scope

πŸ€– Generated with Claude Code

Resolves swim-34/X5.1 (karmaterminal/openclaw-bootstrap#542).

Covers all six cases the spec asks for, plus four edge-case additions
that close the fencepost ambiguity the issue flagged:

Spec cases:
  (a) ToolInputError when session is absent (both agentSessionKey and
      sessionId separately).
  (b) context_threshold guard rejects when usage < MIN_CONTEXT_THRESHOLD.
  (c) Enqueues compaction when usage >= MIN_CONTEXT_THRESHOLD with no
      rate limit.
  (d) rate_limit guard rejects when called again within RATE_LIMIT_MS.
  (e) [already-pending] short-circuits with status=already_pending and
      does not re-enter triggerCompaction.
  (f) Documented status markers (compaction_requested / rejected /
      already_pending) are stable.

Edge cases:
  - 69% is still rejected (just-below-floor).
  - Exactly 70% is accepted (inclusive-floor β€” resolves the
    ">70 vs >=70" fencepost ambiguity from the issue body: source
    uses `<` for reject, so 70% exactly is accept).
  - A fresh request after RATE_LIMIT_MS elapses is accepted again.
  - agentSessionKey and sessionId each fail independently with
    ToolInputError.

Uses the exported test helpers (_resetGuardState, _setPending,
_resetVolitionalCounts, _guards) from the source module β€” no
internal-state poking, no prototype mutation.

Run: `pnpm test src/agents/tools/request-compaction-tool.test.ts`
  β†’ 10 passed, 553ms.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ronan-dandelion-cult ronan-dandelion-cult force-pushed the tests/x5.1-request-compaction-tool branch from 394734e to 8f9e380 Compare April 18, 2026 18:19
Copy link
Copy Markdown

@cael-dandelion-cult cael-dandelion-cult left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩸 LGTM. 193-line test file covers ToolInputError, threshold guards (including 69% boundary), enqueue paths β€” proper boundary discipline. Uses _resetGuardState/_resetVolitionalCounts in before/after, restoreAllMocks. Resolves bootstrap#542 cleanly. Ship it.

@ronan-dandelion-cult ronan-dandelion-cult merged commit 32118f7 into flesh_beast_figs/20260414-claude Apr 18, 2026
2 of 10 checks passed
@ronan-dandelion-cult ronan-dandelion-cult deleted the tests/x5.1-request-compaction-tool branch April 18, 2026 18:30
ronan-dandelion-cult pushed a commit that referenced this pull request Apr 19, 2026
…le + status restoration

Updates RFC docs/design/continue-work-signal-v2.md to reflect the totality of changes since 107ca2b (the prior RFC edit) plus the two ship-gate PRs about to land:

- Β§4.3: document session provider/model threading through volitional compaction (openclaw#191 / bootstrap#639). Three coupled defects: root cause, caller-honesty (phantom-counter), visibility (`unknown_model` classifier + `isLegitSkipReason` helper + `log.warn` on resolve-with-fallback + scope-aware `authProfileId`).
- Β§6.1: add `[context-pressure:noop]` log anchor with reason taxonomy (window-zero / below-threshold / band-dedup); document the bootstrap#580 investigation cycle (`:reach`/`:skip` instrumentation, root cause = sentinel collision on band 0, fix = -1 sentinel).
- Β§6.3: clarify Discord/agent path through src/auto-reply/status.ts was reconnected at openclaw#187 + tested at #188 (the line had been silently dropped in an earlier refactor); note `volitional: N` is honest only after #191.
- Β§6.4: replace 'instrumentation is not currently in place' note with status of distinguishing-instrumentation work (openclaw#164/171/172/173).
- Appendix C.1: add 'Closed failure modes' table β€” phantom-counter, hedge-timer ref leak, band-0 dedup, precondition-skip blindness, Copilot summarization headers, dist-bundle satellite chunks, subagent-announce runtime path mismatch.
- Appendix D.2: add evidence-location rows for the new file paths (volitional threading sites; armHedgeTimer; status renderer; request-compaction-tool tests; context-pressure noop sites; agent-runner runtime promotion; subagent-announce co-location; F-NOISE scheduler test).
- Header: bump test count (~180 across 13 files, was '172 across 8') to reflect additions in #165, #170, #188, #193.

Skip-list (no RFC mention): #174 sessions/config raw-key sweep (internal hygiene); #173 Copilot log-enabled nits (micro-hygiene); 86134af removal of investigation breadcrumbs (cycle is folded into Β§6.1 narrative).

Refs:
  openclaw#191 head fc3f415 (in-flight, MERGEABLE/UNSTABLE, APPROVED)
  openclaw#193 head 14483a6   (in-flight, MERGEABLE/UNSTABLE, APPROVED x2)
  openclaw#187, #188 (merged d787890)
  openclaw#160, #162, #164, #165, #169, #170, #171, #172, #173, #174

πŸ† in 🩲: this is a docs PR; if either #191 or #193 changes shape pre-merge the affected paragraph here will need a one-line touch-up.

Co-Authored-By: dandelion cult - ronan 🌊 <karmafeast@gmail.com>
ronan-dandelion-cult pushed a commit that referenced this pull request Apr 26, 2026
- L921: drop 'As of canonical2 <sha>' dev-state preamble; spec target reads independent of canonical2 marker
- L1343: drop 'swim-34/X5.1' cohort codename from #165 entry

Addresses 🌫 walker-2 holdout (#issuecomment-4323337991).
Mirror of cohort-label-strip pass; final upstream-presentable polish.
cael-dandelion-cult pushed a commit that referenced this pull request Apr 27, 2026
…urrent capability incorporation (#358)

* chore(rfc-fixup): initialize lane journal

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* chore(rfc-fixup): record source pre-read

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* docs(rfc): regenerate continuation ToC

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* docs(rfc): strip continuation process metadata

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* chore(rfc-fixup): note targetSessionKey state

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* docs(rfc): incorporate current continuation surfaces

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* docs(rfc): finalize continuation consistency pass

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* docs(rfc): record verification receipts

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* chore(rfc-fixup): note final gate rerun

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* chore: drop tmp-drop-me-gpt2-rfc-fixup.md scratch artifact

Mirror of #354 path-b cleanup (commit 2d6a734). Scratch worker
artifact must not land on upstream-presentable RFC PR.

* docs(rfc-fixup): strip remaining cohort/dev-state nouns

- L921: drop 'As of canonical2 <sha>' dev-state preamble; spec target reads independent of canonical2 marker
- L1343: drop 'swim-34/X5.1' cohort codename from #165 entry

Addresses 🌫 walker-2 holdout (#issuecomment-4323337991).
Mirror of cohort-label-strip pass; final upstream-presentable polish.

* docs(rfc-fixup): re-pad table column on L1343 after cohort-label strip

oxfmt --check failure on a079b04: removing ', swim-34/X5.1' (16 chars)
left the trailing-whitespace pad on L1343 mis-aligned with the rest of the
column. pnpm format:docs:check passes locally after this re-pad.

Pure cosmetic; no semantic change. Addresses 🌫 walker-2 #issuecomment-4323345225.

---------

Co-authored-by: Test User <test@example.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Ronan 🌊 <ronan@solidor.io>
karmafeast pushed a commit that referenced this pull request May 1, 2026
…urrent capability incorporation (#358)

* chore(rfc-fixup): initialize lane journal

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* chore(rfc-fixup): record source pre-read

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* docs(rfc): regenerate continuation ToC

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* docs(rfc): strip continuation process metadata

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* chore(rfc-fixup): note targetSessionKey state

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* docs(rfc): incorporate current continuation surfaces

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* docs(rfc): finalize continuation consistency pass

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* docs(rfc): record verification receipts

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* chore(rfc-fixup): note final gate rerun

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* chore: drop tmp-drop-me-gpt2-rfc-fixup.md scratch artifact

Mirror of #354 path-b cleanup (commit 2d6a734). Scratch worker
artifact must not land on upstream-presentable RFC PR.

* docs(rfc-fixup): strip remaining cohort/dev-state nouns

- L921: drop 'As of canonical2 <sha>' dev-state preamble; spec target reads independent of canonical2 marker
- L1343: drop 'swim-34/X5.1' cohort codename from #165 entry

Addresses 🌫 walker-2 holdout (#issuecomment-4323337991).
Mirror of cohort-label-strip pass; final upstream-presentable polish.

* docs(rfc-fixup): re-pad table column on L1343 after cohort-label strip

oxfmt --check failure on a079b04: removing ', swim-34/X5.1' (16 chars)
left the trailing-whitespace pad on L1343 mis-aligned with the rest of the
column. pnpm format:docs:check passes locally after this re-pad.

Pure cosmetic; no semantic change. Addresses 🌫 walker-2 #issuecomment-4323345225.

---------

Co-authored-by: Test User <test@example.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Ronan 🌊 <ronan@solidor.io>
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.

3 participants