Repository navigation
fix(tokenless): attribute stash artifact kinds - #10941
Open
boluochoufeng wants to merge 1 commit into
Open
boluochoufeng wants to merge 1 commit into
boluochoufeng wants to merge 1 commit into
Conversation
`tokenless-runtime` now records the actual `compressor_id` in the `compression_artifacts` table of `stats.db` for every stash-producing domain instead of falling back to `"json_truncation"` whenever an applied run is neither `schema_compression` nor `json_record_reduction`. Previously, emitted stash keys from build-log reduction, diff reduction, HTML extraction (both standalone and JSON-embedded), and browser snapshot reduction were misattributed as `"json_truncation"`, distorting per-compressor artifact ownership. In `crates/tokenless-runtime/src/lib.rs`, replace the ad-hoc branch in `record_entry_stats` with an exhaustive `is_stash_producing_operation` match over `AppliedOperation` and an `artifact_kind_for_operations` helper that maps through `AppliedOperation::wire_str`. Selecting the first stash-producing operation ensures preceding lossless steps (such as `terminal_cleanup` or `tabular_compaction` in mixed output) do not mask the operation that emitted the recovery markers, while keeping the match exhaustive so future `AppliedOperation` variants require an explicit compile-time classification. Add unit coverage for all stash-producing variants, lossless prefixes, and defensive fallback behavior plus end-to-end SQLite runtime tests verifying `compression_artifacts.compressor_id` across schema, build-log, diff, standalone HTML, embedded HTML, browser snapshot, JSON record reduction, and JSON truncation paths. User-visible changes: - `tokenless compress`: Command syntax, compression output, and `tokenless stats summary` behavior are unchanged. New rows written to `compression_artifacts` in `stats.db` now store each domain's actual `compressor_id` (shared with `TokenlessRuntime`); historical rows are not rewritten. Fixes: 80938fb ("feat(tokenless)!: add protocol v2 lifecycle") Assisted-by: Antigravity Signed-off-by: blycf <1355990831@qq.com>
boluochoufeng
requested review from
Forrest-ly and
ikunkun-sys
as code owners
November 29, 2026 06:30
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
In
src/tokenless/crates/tokenless-runtime/src/lib.rs,record_entry_statsonly checkedAppliedOperation::SchemaCompressionandAppliedOperation::JsonRecordReductionwhen choosingcompression_artifacts.compressor_id, defaulting every other applied run with emitted stash keys to"json_truncation". As a result, stash artifacts written by build-log reduction, diff reduction, standalone/embedded HTML extraction, and browser snapshot reduction were all misattributed as"json_truncation"instats.db.What changed
if / else if / elsebranch insrc/tokenless/crates/tokenless-runtime/src/lib.rswith an exhaustiveis_stash_producing_operationmatch overAppliedOperationand anartifact_kind_for_operationshelper that derives labels directly fromAppliedOperation::wire_str.applied_operationsso preceding lossless operations (such asterminal_cleanupbeforebuild_log_reduction, ortabular_compaction/json_cleanupin mixed output) do not mask the operation that created the emitted markers; kept a defensive"unknown"fallback for an empty operation list instead of mislabeling it as"json_truncation".TokenlessRuntimeSQLite tests insrc/tokenless/crates/tokenless-runtime/src/tests.rsverifyingcompression_artifacts.compressor_idacrossschema_compression,build_log_reduction,diff_reduction, standalone and JSON-embeddedhtml_extraction,browser_snapshot_reduction,json_record_reduction,json_truncation, andtabular_row_reduction.Related issue
no-issue: focused correctness fix for
compression_artifacts.compressor_idattribution introduced when protocol v2 replacedstash_owning_compressorin80938fb46.User / Agent impact
None for CLI syntax, compression output, or
tokenless stats summaryresults. Newly recorded rows instats.db'scompression_artifactstable now store each domain's actualcompressor_id; historical rows are not rewritten.Risk and compatibility
Low risk. The change is isolated to internal
compressor_idlabel selection intokenless-runtime, keepsstatsandcompression_artifactsschemas unchanged, and does not altertokenless stats summary --jsonoutput orproviders/tokenlesscontracts.Validation
Ran on macOS (arm64) against branch base
9a99f8782(tokenless0.9.8):cargo fmt --manifest-path src/tokenless/Cargo.toml --all -- --check: passed.cargo clippy --manifest-path src/tokenless/Cargo.toml --all-targets -- -D warnings: passed (0 warnings).cargo test --manifest-path src/tokenless/Cargo.toml -p tokenless-runtime -- --test-threads=1: passed (307 passed, 0 failed, including 2 new artifact-attribution unit and SQLite end-to-end tests).cargo doc --manifest-path src/tokenless/Cargo.toml -p tokenless-runtime --no-deps: passed (0 warnings).Not run locally: PyO3 Python runtime suite (
make test-python-runtime), adapter/hook suites (make test-integration/make test-adapters), and Linux-onlyproviders/tokenlesstests; these will be exercised by GitHub Actions CI.Documentation and rollback
No user-facing CLI, SDK, or schema documentation changes are required. Reverting this single commit restores the prior fallback behavior without affecting stored stash payloads or existing database rows.