Skip to content

S3: the no-copy ban-set is a declaration, not a length accident #244

Closed as not planned

Description

@Polichinel

Part of the #241 epic. Registers C-57. Depends on #243.

Problem

Two things decide what the no-copy scan hunts for, and both are currently accidents.

1. The secret table is exempted by an inline literal. tests/test_env_declaration.py:1042:

scanned_sections = tuple(
    name for name, role in _TABLE_ROLE.items() if role == "CONSUMED" and name != "secret"
)

Two lines above sits a comment claiming the scope comes from the declared partition and not from an inline tuple. No reason for the exemption is recorded anywhere — not in the code, not in an ADR, not in the register.

Measured against views-appwrite origin/main (v1.6.0): [secret] has 7 rows and none carries a value, so the clause removes exactly zero entries today, and the isinstance(body.get("value"), str) filter on the next line already does the work. The day any secret row gains a value — a key id, a header name, a non-secret slot identifier — the one table class whose leak matters most is silently outside a scan running in public CI. assert _CONSUMED_TABLES does not cover it: secret alone keeps _CONSUMED_TABLES truthy while scanned_sections goes empty.

2. Removing the six-character floor admitted this repository's own package names into the ban-set. Measured: the registry's two shortest values are the exact contents of PARTNER_PACKAGES — this package's own directory names — matched by exact string equality against every non-docstring string constant under views_postprocessing/.

The justification given was "measured, removing it keeps the suite green". That measured today's source. The next logging.getLogger(<partner>), if partner == <partner>:, or Literal[<partner>, ...] (still an ast.Constant) fails a security guard with "coordinate value(s) from the registry are copied into this repo" for code that copied nothing. Per this file's own repeatedly-cited doctrine — ADR-014 §3, a guard that cries wolf gets narrowed or deleted — the guard is then weakened, and the real rule goes unguarded. It also hands views-appwrite a way to redden this repository by declaring any short ordinary word as a value, which is C-86's coupling arriving through the guard meant to reduce it.

Work

  1. Delete the secret exemption, or replace it with a declared exclusion carrying a stated reason and a test. Deleting is safe today and preferred — the isinstance filter already handles valueless rows, and the exemption's only effect is a future hole.
  2. Replace the length floor with a declared exclusion. A value that is also one of this package's own directory names cannot be distinguished from ordinary code by exact string equality. Exclude those by name, with the reason written down, rather than by a length threshold that excludes them as a side effect.
  3. State the hole this leaves: a genuine copy of a value that equals a package name will not be caught by the AST branch. That is accepted; S2: replace the assignment parser with a pair matcher, and give the scan a stopping rule #243's pair-matching still catches it in markdown, where NAME=<value> disambiguates.

Acceptance criteria

  • scanned_sections derives from _TABLE_ROLE with no inline name literal, or the exclusion is declared with a reason and a test asserting the reason still holds.
  • A test fails if a [secret.*] row gains a value and is not scanned.
  • The ban-set excludes package-name-colliding values by declaration; a test asserts the exclusion list equals the actual collision set, so it cannot silently grow.
  • Mutation-proven: adding logging.getLogger(<a partner name>) to a package module does not fail the scan; adding a real coordinate value does.
  • C-57 amended with the measured facts and the accepted residual.

Implementation notes

test_the_role_vocabulary_is_closed currently asserts that _TABLE_ROLE's values drive which sections the no-copy check reads — which line 1042 falsifies. Fix the code, not that assertion.

Testing

pytest -q tests/test_env_declaration.py plus the two mutations above.

Labels

story, implementation, testing

Activity

  1. added
    story
    implementation
    testing
    on Aug 12, 2026
  2. Polichinel commented on Aug 12, 2026

    @Polichinel
    CollaboratorAuthor

    Merged into #243.

    Splitting "what the scanner hunts" from "how it matches" was an artefact of reviewing them separately — they are one change to one function, and doing them apart means touching the same twenty lines twice.

    Both items carried over intact:

    • the secret exemption (an inline literal under a comment claiming there is no inline literal; measured — it removes zero entries today and its only effect is a future hole)
    • the package-name collision in the ban-set (the two shortest registry values are the exact contents of PARTNER_PACKAGES)

    Closing as merged, not as rejected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    implementationstorytesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions