traverse-framework / traverse-framework/registry
Publish text.truncate@1.0.1 — stop invalid/oversized max_length from wiping text
- Dominant language
- Rust
- Stars
- 1
- Forks
- 1
- Avg merge
- 1h 17m
- Merged PRs (30d)
- 217
Description
## Why
`text.truncate@1.0.0` landed in #487 (Closes #486). A follow-up review found that `handle` maps a failed `max_length` parse to `0`, and `truncate_text` then returns `(\"\", true)` for any non-empty text.
On the published `wasm32-unknown-unknown` artifact, `usize::MAX` is `2^32-1`. Host `cargo test` is 64-bit, so CI never sees this. Omitted/`null`/string budgets, non-integers (`1.5`), and values `> u32::MAX` (`4294967296`, `1e10`, `Number.MAX_SAFE_INTEGER`) all wipe the string today. The last group is a legal JSON Schema integer (`minimum: 0`, no `maximum`), so host schema validation does not save you. That also breaks the 1.0.0 postcondition that `truncated` is true **exactly** when the input exceeded `max_length`.
1.0.0 is immutable. Fix this with a successor version. Review that asked for this: https://github.com/traverse-framework/registry/pull/487#pullrequestreview-5204003632
@Rayan-and-beyond — you published 1.0.0; this is yours to take if you want it.
## One-PR ask
Publish **`text.truncate@1.0.1`**. Do not edit `capabilities/text/text.truncate/1.0.0/`.
### Must change (correctness)
1. Saturate overflow to `usize::MAX` (any 20k-char input then fits → no truncate). Do not reject `number > usize::MAX as f64` and fall through to `0`.
2. Do not treat parse failure as a zero budget. Keep the original text and `truncated: false`, or return an explicit invalid-input shape. Never empty the string because `max_length` failed to parse.
3. Add `maximum: 20000` on `max_length` so it matches `text.maxLength`.
4. Add tests that are visible on wasm32 / independent of host `usize` width: `handle(\"hello\", 1e10)` and `handle(\"hello\", 1.5)` must not return empty. The existing `invalid_lengths_are_rejected_by_parser` test only hits the helper — run `handle` on a bad budget with non-empty text.
### Should change (contract + tests)
5. Bound `ellipsis` with `maxLength` (32 or 128 is enough; 20000 if you want it to match `text`).
6. Assert `truncated` on `custom_ellipsis_is_counted_in_limit`, `ellipsis_is_clipped_when_it_exceeds_budget`, and `empty_ellipsis_uses_entire_budget_for_text`.
7. Add `max_length == 1` with the default one-scalar `…` (ellipsis replaces the text entirely — specified in 1.0.0, untested).
### Nits (include while you are there)
8. Use case 2 says “byte-for-byte unchanged.” Reword to Unicode-scalar identity so it matches the rest of the contract.
9. Add at least one `happy: false` use case for the invalid/fallback budget path, same shape as `formatting.format-currency` / `text.detect-entities`.
### Out of scope
- Grapheme clusters, ZWJ emoji, HTML, display width (keep 1.0.0's documented limits).
- Crate rename (`capability-src/text-truncate` + `text-truncate-agent` stays).
- Yanking 1.0.0 (typical preview callers with `max_length` 80–200 are fine; `^1.0.0` will pick up 1.0.1).
## Publish path
- New `capabilities/text/text.truncate/1.0.1/contract.json` + rebuilt WASM + inventory `published_versions` entry.
- `artifact.digest` / `artifact.url` for release tag `artifacts/text.truncate-1.0.1`.
- Same governing specs as #487: `001-registry-foundation`, `014-extraction-compatibility`, `018-capability-test-coverage`, `023-authoring-assurance`, `024-capability-risk-classification-adoption`.
- Run `bash scripts/ci/pre_pr_check.sh ` before opening.
## Done when
- CI green on the publish PR
- Capability appears in the next index release after merge
- Review items 1–9 are in the 1.0.1 contract and `capability-src/text-truncate` tests
## Labels
`help wanted` · `good first issue` · `no-spec-needed`
Contributor guide
Research direction
Start with capability-src/text-truncate and its existing tests, then compare the immutable capabilities/text/text.truncate/1.0.0 contract with the requested 1.0.1 contract changes. Run the handle cases on wasm32, update the contract and tests, rebuild the WASM artifact, inventory entry, and release metadata, then run bash scripts/ci/pre_pr_check.sh . Done means CI is green and the capability is included in the next index release.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash, json, rust, wasm
- Domain
- build-system, release, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100