Repository navigation
test(branding): add allowlist-style branding scan + pin ~50 known-debt strings (#67) - #71
Merged
Merged
Conversation
Adds `branding_lint_no_unrecognised_rtk_references_in_src` — an allowlist-style scan complementing the existing `FORBIDDEN_TOKENS` regression backstop. The new test fails on ANY case-insensitive `\brtk\b` in `src/*.rs` not matched by an explicit named allowlist rule, catching new leak classes at test time instead of via user report (the v0.1.8 → v0.1.9 whack-a-mole that drove this issue). Allowlist categories (17 named rules): - filesystem-path (.rtk/, ~/.rtk/, hook scripts, integrity sidecar) - env-var-shape (any `RTK_*` identifier) - upstream-attribution (rtk-ai/rtk, RTK AI Labs, [email protected]) - hook-protocol-literal (over-the-wire JSON values, parser markers) - test-fixture-argv0 (`vec!["rtk", ...]` in clap-parse tests) - tracking-label-string (rtk_cmd DB column, registry expectations) - hook-rewrite-output-literal (env-prefix / chain-preserve outputs) - raw-string-tracking-literal (`Some(r#"...rtk..."#.into())`) - known-unbranded-text-debt (enumerated cleanup-tracked surface) - doc-comment-example (`/// use rtk::xxx;`) - module-internal-identifier (`let rtk = ...`, `rtk_cmd:`, ...) - per-line allow marker (existing `// branding-lint: allow legacy`) - structural-needle (LEGACY_RTK_MD_FILES, etc) - history-comment (issue-# / commit-hash references in comments) - internal-comment mention (// or //! — NOT ///) - rustdoc-comment mention (/// — clap-help leak risk; see FORBIDDEN_TOKENS for specific-phrasing pin) - test-only fixture text (cargo banners, JSONL test fixtures, assertion diagnostics inside known test modules) Implementation notes: - Tracks multi-line raw-string state so `r#"..."#` literals containing fixture text are exempted en bloc - Sanity self-test: 4 leak simulations are asserted to be REJECTED by the allowlist (init-message, error-prefix, novel eprintln, novel panic) so a future "too broad" rule edit fails fast - Runs in <0.3s on full src/ (well under the 2s budget) - Failure messages name file:line + offending substring + available rule list, with explicit FIX OPTIONS guidance Existing tests retained: - `branding_lint_no_forbidden_upstream_literals_in_src` — regression-style FORBIDDEN_TOKENS backstop (pins specific leak-class phrasings) - `branding_lint_canonical_name_present_in_init` — inverse-rebrand sanity check - `branding_lint_config_files_pin_canonical_package_name` — Cargo.toml + release-please-config.json pinning Passes on develop tip with no production source changes (the known-unbranded-text-debt rule enumerates the existing rebrand- incomplete surface explicitly so each entry is auditable). Future NEW user-visible RTK leaks fail this test instead of shipping. Closes #67. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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.
Summary
Closes #67. Replaces regression-style branding lint (catch known leak patterns) with allowlist-style scan (catch ANY case-insensitive
\brtk\binsrc/*.rsnot matching an explicit rule). Future leaks fail at test time, not at user-report time.What it catches
17 named allowlist rules covering:
.rtk/filters.toml,~/.rtk/, ...)RTK_*env var identifiersrtk-ai/rtk,RTK AI Labs,[email protected])rtk_cmdcolumn nameformat!("rtk X")tracking labels insrc/discover/registry.rsonly (consumed by hook caller — see scope: standardise rewrite_command output prefix ( vs ) #62)vec!["rtk", ...]argv[0] test fixtures// branding-lint: allow legacymarkers (preserved)ALLOWED_FUNCTION_PREFIXESfor legacy-handling helpers (preserved)RTK_MD,RtkBlockUpsert, etc.)Known-debt catalogue (~50 strings)
Agent B's broad scan caught ~50 user-visible RTK strings the rebrand sweep missed. All pinned in a
KNOWN_UNBRANDED_TEXT_NEEDLESallowlist so the test passes on develop, but any new leak class outside this list fails immediately. Notable categories worth follow-up cleanup:src/discover/report.rs—"RTK Discover","Already using RTK:", table headerssrc/analytics/cc_economics.rs—"RTK Cmds","RTK compresses CLI outputs"src/analytics/session_cmd.rs—"RTK Session Overview","RTK", "Adoption"headerssrc/analytics/gain.rs—"RTK Parse Failures"src/hooks/init.rs— uninstall flow:"RTK was not installed","would uninstall RTK", etc.src/core/telemetry_cmd.rs—"RTK collects anonymous usage metrics"src/cmds/cloud/container.rs—"Usage: rtk docker logs","Usage: rtk kubectl logs"src/main.rs—"Usage: rtk proxy","Use: rtk init --agent X"src/hooks/integrity.rs—"To restore: rtk init -g","To inspect: rtk verify"src/cmds/git/git.rs—"[full diff: rtk git diff --no-compact]"src/parser/mod.rs—[RTK:PASSTHROUGH]/[RTK:DEGRADED]parser markerssrc/hooks/hook_cmd.rs—[rtk hook]stderr prefixsrc/learn/report.rs—"RTK Learn"headersrc/core/telemetry.rs—X-RTK-TokenHTTP header (programmatic — probably keep)A clean-up round is suitable for a separate PR; this PR is the detection layer.
Self-tests
4 leak-simulation tests assert the allowlist correctly REJECTS deliberate leaks (init-message-style, error-prefix-style, novel
eprintln!, novelpanic!). A future "too broad" rule edit fails fast.Verified
cargo test --test branding_lint— 4 pass, runtime 0.24scargo test --bin contextcrawler— 2119 pass / 0 failbranding_lint_no_forbidden_upstream_literals_in_srcretained as the regression-style backstopbranding_lint_config_files_pin_canonical_package_nameretainedtests/branding_lint.rs(+890 lines)Closes #67.