Skip to content

Implement TokenJuice pipeline and policy primitives#7

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

Implement TokenJuice pipeline and policy primitives#7
senamakel wants to merge 122 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

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 46 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e0a5f27f-8da0-4d65-ae42-3bd9a1480dfe

📥 Commits

Reviewing files that changed from the base of the PR and between 41b5ca8 and 92fbb2e.

📒 Files selected for processing (103)
  • Cargo.toml
  • README.md
  • docs/reduce-json-protocol.md
  • docs/references/web-extract-truncate-store-spec.md
  • plan/content-compressor-roadmap.md
  • plan/conversation-compression-plan.md
  • plan/current-state-and-critique.md
  • plan/openhuman-algorithm-port-plan.md
  • plan/openhuman-integration-plan.md
  • plan/pipeline-and-ccr-plan.md
  • plan/reference-algorithm-summary.md
  • plan/rule-cli-and-safety-parity-plan.md
  • prompt.md
  • src/cache/mod.rs
  • src/cache/store.rs
  • src/cache_hints.rs
  • src/compress.rs
  • src/compressors/code.rs
  • src/compressors/diff.rs
  • src/compressors/html.rs
  • src/compressors/json.rs
  • src/compressors/log.rs
  • src/compressors/ml_text.rs
  • src/compressors/mod.rs
  • src/compressors/search.rs
  • src/compressors/text.rs
  • src/compressors/web_extract.rs
  • src/conversation/boundary.rs
  • src/conversation/budget.rs
  • src/conversation/mod.rs
  • src/conversation/subagent.rs
  • src/conversation/summary.rs
  • src/conversation/tool_digest.rs
  • src/conversation/types.rs
  • src/lib.rs
  • src/live_zone.rs
  • src/main.rs
  • src/ml.rs
  • src/observability.rs
  • src/pipeline/estimate.rs
  • src/pipeline/mod.rs
  • src/pipeline/report.rs
  • src/pipeline/runner.rs
  • src/pipeline/transform.rs
  • src/policy/mod.rs
  • src/policy/shell.rs
  • src/protocol.rs
  • src/reduce.rs
  • src/reduce_tests.rs
  • src/relevance/bm25.rs
  • src/relevance/mod.rs
  • src/rules/builtin.rs
  • src/rules/builtin_tests.rs
  • src/rules/loader.rs
  • src/rules/mod.rs
  • src/rules/verify.rs
  • src/savings.rs
  • src/tool_integration.rs
  • src/types.rs
  • src/vendor/rules/ci__github-actions.json
  • tests/cli.rs
  • tests/compressor_fixtures.rs
  • tests/compressor_fixtures/diff_generated_bundle.fixture.json
  • tests/compressor_fixtures/diff_lockfile.fixture.json
  • tests/compressor_fixtures/json_adaptive_saturation_anchor.fixture.json
  • tests/compressor_fixtures/json_constant_columns.fixture.json
  • tests/compressor_fixtures/json_discriminator_anchor.fixture.json
  • tests/compressor_fixtures/json_duplicate_cluster_anchor.fixture.json
  • tests/compressor_fixtures/json_early_saturation_anchor.fixture.json
  • tests/compressor_fixtures/json_error_anchor.fixture.json
  • tests/compressor_fixtures/json_heterogeneous_buckets.fixture.json
  • tests/compressor_fixtures/json_information_dense_anchor.fixture.json
  • tests/compressor_fixtures/json_latest_query_anchor.fixture.json
  • tests/compressor_fixtures/json_near_duplicate_cluster_anchor.fixture.json
  • tests/compressor_fixtures/json_nested_columns.fixture.json
  • tests/compressor_fixtures/json_numeric_change_point_anchor.fixture.json
  • tests/compressor_fixtures/json_numeric_outlier_anchor.fixture.json
  • tests/compressor_fixtures/json_oldest_query_anchor.fixture.json
  • tests/compressor_fixtures/json_query_anchor.fixture.json
  • tests/compressor_fixtures/json_sparse_anchor.fixture.json
  • tests/compressor_fixtures/json_spread_anchor.fixture.json
  • tests/compressor_fixtures/json_stringified_columns.fixture.json
  • tests/compressor_fixtures/search_ranked.fixture.json
  • tests/compressor_fixtures/textcrusher_signal.fixture.json
  • tests/diff_noise_policy_fixtures.rs
  • tests/diff_noise_policy_fixtures/configured_path.fixture.json
  • tests/diff_noise_policy_fixtures/semantic_hunk.fixture.json
  • tests/diff_noise_policy_fixtures/whitespace_only.fixture.json
  • tests/e2e_tool_output.rs
  • tests/fixtures/find_safe_inventory.fixture.json
  • tests/fixtures/gh_actions_failure.fixture.json
  • tests/log_template_fixtures.rs
  • tests/log_template_fixtures/worker_progress.fixture.json
  • tests/ml_tag_protection_fixtures.rs
  • tests/ml_tag_protection_fixtures/drop_placeholder.fixture.json
  • tests/ml_tag_protection_fixtures/restore_workflow_block.fixture.json
  • tests/reduce_json_stats.rs
  • tests/search_read_fixtures.rs
  • tests/search_read_fixtures/ranking.fixture.json
  • tests/search_read_fixtures/snippet_windows.fixture.json
  • tests/search_read_fixtures/vendor_generated.fixture.json
  • tests/web_extract_fixtures.rs
  • tests/web_extract_fixtures/markdown_article.fixture.json

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
path = "src/main.rs"

[[bin]]
name = "tinyjuice-hooks"

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 Keep hook entrypoints on the tinyjuice binary

With this bin rename, cargo install tinyjuice now exposes the existing hook installer/entrypoints as tinyjuice-hooks, while the hook templates, defaults, and docs still configure agents to run commands such as tinyjuice codex-post-tool-use, tinyjuice claude-code-post-tool-use, and tinyjuice install claude-code. Those commands now hit the new reducer CLI in src/main.rs, so existing Codex/Claude hooks break after upgrade and fresh Claude installs fail unless users manually discover and override the renamed binary.

Useful? React with 👍 / 👎.

Comment thread src/cache_hints.rs
Comment on lines +100 to +106
if !message_roles.is_empty() {
hints.push(PromptCacheHint {
provider: "anthropic".to_owned(),
message_index: Some(0),
ttl: PromptCacheTtl::Ephemeral,
placement: CacheMarkerPlacement::SystemPrompt,
});

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 Only emit system cache hints for system messages

When the role list has no system message, this still emits a SystemPrompt hint for message_index: 0, and the last-three non-system pass can emit a second Message hint for that same user message. Adapters applying these hints can mark a user turn as the system-prompt cache carrier or attach duplicate cache controls to one message; gate this hint on the first role actually being system, otherwise let index 0 be handled by the message-carrier logic.

Useful? React with 👍 / 👎.

Comment thread src/main.rs
report.duplicate_ids.len(),
report.shadowed_rules.len()
);
failed |= !report.parse_errors.is_empty() || !report.duplicate_ids.is_empty();

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 Fail verification when regex validation fails

In a rules-only verification run, invalid regexes are printed but do not set failed, so tinyjuice verify --rules exits successfully even when verify_rules found patterns the compiler will silently drop. That lets CI/PR checks accept a broken builtin rule set with disabled filters, counters, or output matches; include !report.invalid_regexes.is_empty() in this failure condition.

Useful? React with 👍 / 👎.

Comment thread src/rules/verify.rs

for input in inputs {
inputs_seen += 1;
let classification = classify_execution(&input, rules, None);

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 Normalize command-only inputs before discovery classification

Discovery classifies the raw ToolExecutionInput, but runtime reduction first calls normalize_execution_input, so payloads that provide command without argv are misclassified here. For example command: "git status" will be reported as generic/fallback because rules like git/status require argv0/argvIncludes, even though production reduction handles the same input; normalize before classification (and use the normalized input for the discovery key) to avoid misleading rule-coverage reports.

Useful? React with 👍 / 👎.

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