← Back to Pull requests

fix(contract): catch unlabeled provider tokens in the public boundary scan #7713

Closed
unknown closed this pull request without merging on Nov 01, 2026 10:25 UTC
View on GitHub
unknown unknown commented on Oct 30, 2026 02:37 UTC
Author

Goal And Delivered Outcome

A repository-publication gate that reports a live-looking provider credential as public-safe can leak that credential to GitHub or CI artifacts; after this change loopx check --scan-path — the scan canary premerge runs as a blocking check and the one CONTRIBUTING.md tells contributors to run before publishing — rejects unlabeled GitHub, Slack, npm, PyPI, Stripe, Google, AWS and JWT credential shapes instead of certifying them clean.

  • Outcome basis / optional anchor: observed defect reproduced through the real CLI at upstream main 2f544f969; the parent owner split is tracked by #5136, and the sibling-module changes in #7635 / #7636 explicitly left loopx/contract.py untouched.
  • Goal/source and gap: LEAK_RULES["credential"] in loopx/contract.py kept its own stale alternation, which only recognized credentials that carried a token= / password= / Authorization: / Bearer label. Unlabeled provider tokens therefore passed. The canonical public-safety owner loopx/public_safe_text.py already carries PROVIDER_TOKEN_SHAPE_PATTERN_SOURCE, which #7636 made the capability scanner consume, but the publication gate still had a narrower private copy.
  • Observable before → after, with the validation row that proves it: a file containing a synthetic GitHub PAT (GitHub's public documentation example, not a live credential) scanned ok: true, exit 0, public boundary scan clean at base; at this head the same command reports one credential error, ok: false, exit 1. See the real_entrypoint and regression_parity rows.
  • Issue/task and intended base: Closes #7712. Intended base: loopx-project/loopx main at 682080047 (rebased).
  • Author Declaration

  • Written by: A coding agent directed and reviewed by the operator submitting the PR.
  • AI disclosure: this change was drafted with AI assistance at my request, under my direction and review.

    Implemented against

  • Specification and revision: #7712 (opened by the same operator from the base reproduction), the parent architecture direction in #5136 at the time of writing, and the documented gate behaviour in CONTRIBUTING.md (loopx check --scan-path docs/ --scan-path examples/) and loopx/public_safe_text.py at 2f544f969.
  • Criteria:
  • | Criterion (spec clause) | Disposition | Symbol / path | Test or command |
    | --- | --- | --- | --- |
    | Unlabeled provider credentials are rejected by the publication scan | implemented | LEAK_RULES["credential"] in [loopx/contract.py](loopx/contract.py) | pytest tests/test_contract_credential_pattern_precision.py; real CLI probe |
    | The gate reuses the canonical provider-shape owner instead of a second copy (the #5136 direction) | implemented | PROVIDER_TOKEN_SHAPE_PATTERN_SOURCE import from [loopx/public_safe_text.py](loopx/public_safe_text.py) | owner-pin test |
    | No regression for labelled credentials or credential references | implemented | _credential_match_is_reference keeps ENV, Basic-template and placeholder handling; unlabeled matches use only the exact AWS documented example exemption | precision suite (44 passed), including two literal-token regressions |
    | No false positives for credential references or for repository material that keeps provider placeholders split | implemented | split literals in one example and one test; JSON \u0061 escapes in one fixture | whole-repository scan_public_boundary → ok: true, 0 hits, 87 reference hits |
    | Every provider shape the rule reuses is also a prefilter candidate, so no issuer is silently skipped | implemented | LEAK_RULES["credential"].required_literals in [loopx/contract.py](loopx/contract.py) | 13 new test_every_authoritative_leak_pattern_has_a_matching_prefilter cases |

  • Self-check before submission: I read the canonical owner, the capability scanner, the canary boundary check and the documented contributing workflow; ran the real CLI at base and head with an isolated home/registry so local runtime state could not influence the result; ran the focused suite, ruff, the example smoke and canary premerge. I deliberately did not widen the local_private_path rule (208 pre-existing false positives across docs/examples) or add a placeholder heuristic; the repository already has a recorded convention of splitting provider-shaped literals, which keeps every test exercising the scan.
  • Review Follow-up

  • Corrected the P2 reference-classification gap from the prior head. Unlabeled provider tokens are exempted only when the whole match is the AWS access-key id published in the official documentation; dummy or example inside an opaque token body no longer downgrades a credential to a reference.

  • Added unit and real loopx check --scan-path regressions for two synthetic provider shapes: a GitHub PAT containing dummy and an npm token containing example. Both now return exit 1 with a credential error.

  • Rebased onto main at 682080047. The focused precision suite is 44 passed; the adjacent contract/prefilter/chat batch is 134 passed, 4 failed, with only the pre-existing Windows platform failures described above.
  • Fixed the false DCO failure by rewriting the three commit messages from CRLF to LF. The commit trees are byte-identical to 05c8d665696c3e0f0139e8e4593c77b91392fc52, author and commit timestamps were preserved, and GitHub now reports Sign-off: success.
  • Scope And Continuation

  • Completed scope and remaining work: complete within this scope — the publication gate now recognizes the same provider shapes as the canonical owner and the capability scanner, and the repository stays green under its own scan. The broader consolidation described in #5136 (one classification owner for private-looking text) remains a separate architecture task and is not attempted here.
  • Slice boundary / successor: N/A — the defect is closed at the gate that caused it. If maintainers want LEAK_RULES to import the whole rule set instead of only the provider shape, that belongs to #5136 rather than to this fix.
  • Validation

  • Tested revision: e17c66ac36dbab273f46e600edebc051e61aaf45 (three commits rebased onto 682080047f4548d0266111f5e924512f550df9d9)

  • Run state: finished

  • Input classes: synthetic
  • | Check kind | Result | Public-safe evidence / limitation |
    | --- | --- | --- |
    | static | passed | uvx --from "ruff>=0.12,<0.16" ruff check loopx/contract.py tests/test_contract_credential_pattern_precision.py tests/test_chat_activity.py examples/control_plane/goal-artifact-lifecycle-projection-smoke.py → All checks passed. |
    | unit | passed | pytest tests/test_contract_credential_pattern_precision.py → 44 passed; includes 8 parametrized provider shapes, the canonical-owner pin, a short-lookalike negative case and two literal-token regressions. The combined precision/prefilter/chat run is 134 passed, 4 failed; the four are the same Windows symlink/CRLF harness failures at base. |
    | regression_parity | passed | With the new provider arm removed in place, the provider-shape, owner-pin and placeholder-body regressions fail; at this head the precision suite has 44 passing tests. This is a mutation-scoped check, so it fails for the reason the fix addresses. |
    | real_entrypoint | passed | Base 2f544f969: loopx check --scan-path <file with a synthetic GitHub PAT> → ok: true, exit 0, public boundary scan clean. Head: same command → ok: false, exit 1, one credential error. Isolated home/registry; no real credential used. |
    | integration | passed | loopx canary premerge --from-git-diff --git-diff-base upstream/main at the tested revision → status: passed, 11/11 selected checks, public boundary 0 failures, merge gate passed. The exact rebased head was also exercised through the documented CLI and focused suite. Two catalog canaries initially failed on this Windows host only because npm dev dependencies were missing and the console codec was cp936; both reproduce identically on the untouched base and pass after npm ci --ignore-scripts plus UTF-8 mode. |
    | manual | passed | Whole-repository scan_public_boundary → ok: true, zero unresolved hits; explicit credential references remain classified rather than deleted. |
    | real_backend | not_applicable | No database, authority store or network backend is touched. |

  • Coverage and gaps: the changed rule is exercised by both the unit suite and the real CLI path. The precision suite is 44 passed. The contract/prefilter/chat batch is 134 passed, 4 failed; the failures are the same Windows symlink-privilege and CRLF line-number cases at base, and are unrelated to this rule. The lifecycle-projection example and chat caller still exercise the same scan. I did not run the TypeScript package suites because no TypeScript file is touched.
  • Frontend / Visual Evidence

  • UI impact: none

  • Before: N/A

  • After: N/A

  • First viewport and preview: N/A — CLI contract only.

  • States and viewports shown: N/A

  • Source data: none

  • Attention review: N/A

  • Craft review: N/A
  • Type of Change

  • Bug fix

  • New feature

  • Breaking change

  • Refactoring (no functional changes)

  • Documentation update

  • Test update
  • LoopX Area

  • Control plane (goals, todos, quota, scheduler, registry, runtime)

  • Benchmark boundary (adapters, runners, verifiers, scoring, evidence)

  • Capability or extension (providers, adapters, skills)

  • Public docs or presentation surface (README, protocols, dashboard)

  • Build, packaging, installer, or CI

  • Host or runtime integration
  • Technical Direction

  • Direction / acceptance reference, when applicable: Core control-plane hardening for the publication boundary; follows the #5136 direction that one canonical owner decides live-looking text, without attempting that architecture change here.
  • Shared-authority RFC fixture impact

  • Production-scale fixture schema: N/A

  • Semantic dimensions changed, or reviewed no-impact rationale: N/A — no RFC or production-scale fixture schema is touched.

  • Provider conformance arms run: N/A

  • Read-only legacy/file/PostgreSQL three-arm rehearsal (required for promotion, runtime-routing, or compatibility-projection changes): N/A
  • Boundary Checklist

  • Neither the diff nor this PR body/comments/attachments disclose private state, credentials, raw traces or verifier output, internal links, or local machine paths (including .loopx/, .codex/goals/, and live ACTIVE_GOAL_STATE.md).

  • I did not duplicate maintainer-owned benchmark work unless a maintainer split out a public issue for it.

  • I kept the change scoped to the linked issue/task.

  • Existing English/Chinese RFC pairs (including ledger entries) both have a diff, and the local premerge check python3 scripts/check_rfc_bilingual.py --base origin/main --head HEAD passes, or no paired RFC changed.

  • I completed the visual evidence section for UI changes, or marked UI impact none.

  • Every commit includes a DCO Signed-off-by trailer (git commit -s).
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: JasonBuildAI Review duration: 3347m
    All Vouch review confidence checks passed
    Residual risk 0.33 = Change Risk (0.75) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.75 · 650 lines diff across 8 files
    0.75
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.075
    Real PR Conversation Timeline
    1 comments
    "Review active on #7713"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 75.2% (HIGH) · Higher = larger blast radius
    75.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 32.5% · Safe to merge
    32.5%