Skip to content

Implement TokenJuice pipeline and policy primitives - #7

Open
senamakel wants to merge 129 commits into
mainfrom
work/prompt-md-next-slice
Open

Implement TokenJuice pipeline and policy primitives#7
senamakel wants to merge 129 commits into
mainfrom
work/prompt-md-next-slice

Conversation

@senamakel

@senamakel senamakel commented Jul 5, 2026

Copy link
Copy Markdown
Member

Summary

  • Ports and mirrors the TokenJuice/TinyJuice algorithm plan across the core crate and OpenHuman adapter surface.
  • Adds typed pipeline and injectable CCR store support, footer-safe recoverable outputs, shell policy handling, deterministic conversation helpers, savings metadata, web extraction, AST stub reads, compressor fixture coverage, ranked search-read scoring, subagent summaries, summary/cache hints, and recovery-tool migration status.
  • Updates the OpenHuman algorithm and integration plans to record the implemented state and the intentionally deferred roadmap work.

API Or Behavior Changes

  • CompressedOutput exposes separate body and recovery_footer fields while preserving compatibility text.
  • Store-injected router/report APIs and CcrStore implementations are available for isolated tests and host adapters.
  • Exact file reads remain byte-exact by default; stub reads require explicit host intent.
  • Lossy compressor paths decline when CCR retention fails, and recovery tools bypass recompression/caps.

Validation

  • cargo fmt --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test
  • OpenHuman focused TokenJuice adapter tests
  • OpenHuman cargo fmt --check
  • OpenHuman cargo check --lib

Documentation

  • Updated README.md/docs and implementation plans to reflect the implemented TokenJuice/TinyJuice surface without unsupported compression-percentage claims.

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Important

Approval pending

CodeRabbit has no unresolved comments, but it has not reviewed the latest commit.

Use the checkbox below to review the latest commit. CodeRabbit will approve the changes if it finds no blocking issues.

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@senamakel
senamakel marked this pull request as ready for review July 6, 2026 22:03

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 92fbb2e198

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Cargo.toml Outdated
Comment thread src/cache_hints.rs Outdated
Comment thread src/main.rs Outdated
Comment thread src/rules/verify.rs
@senamakel senamakel self-assigned this Aug 30, 2026
# Conflicts:
#	Cargo.toml
#	src/compress.rs
#	src/compressors/json.rs
#	src/types.rs
Extend the verify command to flag invalid regex patterns in rules, and refine the Anthropic cache hint logic to only cache the first message when it is a system prompt. These changes improve rule quality checks and reduce unnecessary cache usage for non-system initial messages.

Auto-committed-on: dragonfly
Auto-committed-on: dragonfly
…sages as system

Add a test to verify that anthropic cache hints correctly avoid marking user messages as system prompts, ensuring proper message type classification.
test(rules): add test for discovery normalizing command-only inputs before classification
Add a test to confirm that the discovery function normalizes command-only tool execution inputs before classification, preventing false positive fallback outputs.

Auto-committed-on: dragonfly
Reformatted the assertion in the anthropic cache hints test to improve readability by wrapping the chained method calls across multiple lines. No functional change was made.

Auto-committed-on: dragonfly
When the verify command encounters invalid regexes in rule files, it now prints each error with its path, rule ID, field, index, and the specific error message. This makes debugging configuration issues easier by surfacing the exact location and cause of each regex problem.

Auto-committed-on: dragonfly
Replace the negative lookahead patterns in all vendor rule counters with a simpler pattern that matches any line containing at least one non-whitespace character. The previous patterns attempted to exclude header lines but were fragile and caused regex validation failures, as seen in the updated test assertion that now expects no invalid regexes.

Auto-committed-on: dragonfly
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-30T17:47:27.904978Z 960424c New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 960424c153

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +287 to +290
let host = after_scheme
.split(['/', '?', '#'])
.next()
.unwrap_or_default()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Strip credentials from source host metadata

When a fetched URL contains userinfo, such as https://alice:password@example.com/page, this parser returns alice:password@example.com as source_host. That value is serialized in WebExtractReduction, defeating the URL-hashing/redaction design and exposing credentials downstream; parse or strip the userinfo@ portion before returning host metadata.

Useful? React with 👍 / 👎.

Comment on lines +157 to +159
let per_page_limit = (page_options.max_combined_inline_chars / input.pages.len())
.max(page_options.min_char_limit)
.min(page_options.char_limit);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Enforce the combined inline budget after adding footers

When a batch exceeds max_combined_inline_chars, this recalculates only each page's content limit, clamps it upward to min_char_limit, and does not reserve space for omission markers or recovery footers. Consequently, even the included two-page case with a combined limit of 80 returns substantially more than 80 inline characters, and the excess grows with page count, so hosts cannot rely on this option to protect the model context window.

Useful? React with 👍 / 👎.

Comment thread src/compress.rs
Comment on lines +305 to +306
let (body, recovery_footer, ccr_token) = if ccr_for_call {
let put = store.put(content);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Check footer savings before inserting into CCR

When a compressor body is smaller but the recovery footer makes the final result at least as large as the original, this inserts the original into the bounded FIFO store and only then returns passthrough at the later size check. Near the cache limits, repeated marginal attempts can evict CCR entries referenced by previously emitted recovery tokens even though these new entries are never exposed; derive the token/footer and reject the result before mutating the store, as the previous path did.

Useful? React with 👍 / 👎.

@tinysweeper

tinysweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown

How this change flows

2 changed behaviours across 1 relationship. No surrounding behaviour was found (60 graph nodes walked). 97 further behaviours left out to keep the diagram readable.

flowchart LR
  n0["CompressedOutput<br/>changed"]:::changed
  n1["CompressorKind<br/>changed"]:::changed
  n0 -->|uses| n1
  classDef changed fill:#0d4429,stroke:#238636,color:#e6edf3
  classDef impacted fill:#161b22,stroke:#6e7681,color:#c9d1d9
  classDef flagged fill:#5a1e02,stroke:#d93f0b,color:#ffffff
  classDef blocking fill:#67060c,stroke:#f85149,color:#ffffff
Loading

Green: changed behaviour. Grey: surrounding behaviour. Arrows name the call, use, implementation, or test relationship. Orange: has findings. Red: has a finding that blocks the merge.

tinysweeper 0.1.0

@tinysweeper tinysweeper Bot added the priority: p3 Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect. label Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: p3 Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant