Skip to content

fix(security): resolve a re-exported name through its owner, not a copy - #13933

Merged
bolichen97 merged 1 commit into
mainfrom
fix/security-facade-single-storage-13784
Sep 27, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/security-facade-single-storage-13784

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A test that patches a security control at its owner can trust that the code under test actually runs the patched control.

src/kiro_crew/security/__init__.py is a facade: the security controls live in ten
submodules of the package while kiro_crew.security stays the import path, and
roughly forty modules reach the controls through it. It gave a re-exported name
two storage locations, and it did so for both halves of the name's identity.

The value. The facade bound every re-exported name in its own namespace eagerly,
with from .paths import (...) and nine sibling statements. The submodule that
defines the name held it too. The facade's copy answered every read, because the
facade had no module __getattr__ for those names.

The owner. _EXPORT_OWNERS mapped each name to the resolved owner module
object
, and _MirroringModule.__setattr__ / __delattr__ read owners out of
it. That is a second place a module is stored, beside sys.modules.

The forwarding ran in ONE direction. A write on the facade reached the owner;
nothing carried an owner write back, and no read consulted the owner. Measured on
the base revision, an owner write was invisible through the facade for 467 of
467
re-exported names -- not a future risk, the current behaviour on every name.

Why it matters

patch.object(<submodule>, ...) is how a test patches a control at its owner, and
the repository does it. After such a write, any reader that went through the
facade kept getting the pre-patch object: the test passes while the code under it
runs the control the test believes it replaced. Nothing reports the disagreement.

The owner half has a second shape. Purging a module from sys.modules and
importing it again is an ordinary test idiom, used in twenty files here. After the
purge, _EXPORT_OWNERS still held the discarded module, so a write through the
facade landed on a module nothing reads, while a direct importer saw the fresh one.
Measured on the base revision for a function name and a data name alike: the
facade's read matched the STALE module and not the fresh one, and a patch through
the facade did not reach the fresh module at all.

The failures surface far from the cause -- in another file, under some shard splits
and not others, with nothing pointing back.

Not a goal

  • Moving this __init__.py's own 2,929 lines of code into a submodule. That is
    what would let kiro_crew.security join test/test_lazy_reexport_storage.py's
    PACKAGES and retire this PR's pin file, and it is a separate change with its
    own risk.
  • Collapsing the roughly forty names the facade exports but no submodule of this
    package DEFINES (re, Path, SecurityEventLog, path_resolve_executor).
    There is no owner to resolve them through, so they stay ordinary attributes of
    this module, with one storage location here.
  • Adding a conftest hook that fails any test leaving a module attribute
    disagreeing with its owner. That detector belongs beside the rule rather than
    instead of it.
  • Caching resolved owners or values to recover the per-read cost. A cache is a
    second storage location and would reintroduce exactly this defect.

What changed (motivation → approach → change)

Both halves now resolve through the import system, so there is one place the value
lives and one place the module lives. No mechanism keeps two copies in step,
because there is no second copy.

  • The ten eager from .<submodule> import (...) statements move into
    if TYPE_CHECKING:, so type checkers and IDEs keep every name while runtime
    binds none of them.
  • _EXPORTS maps each re-exported name to its owner submodule's NAME. _submodule()
    resolves it by reading sys.modules, the one place a module is stored, and calls
    importlib.import_module only on the miss -- the import POPULATES that store, it
    does not own the answer.
  • A module-level __getattr__ reads the value off the owner on each access.
    _ReExportModule.__setattr__ / __delattr__ forward a write to the owner, which
    is what keeps a patch fixture's read-then-reassign round trip symmetric.
  • _EXPORT_OWNERS, _SUBMODULES, _export_owners() and _MirroringModule are
    gone. The spelling matches the six packages converted in fix: resolve a lazily re-exported name's owner through sys.modules #13727, including its
    ban on a private owner mapping, so the two converge rather than needing
    reconciliation later.
  • __all__ is DERIVED from the table plus what this module binds, because
    from kiro_crew.security import * is resolved by the import machinery against a
    declared list and never reaches __getattr__. Without it a star import carried
    only the names this module holds -- measured at 81 public names against the base
    revision's 142, with is_sensitive_path, redact_credentials and
    CREDENTIAL_REDACTION_TAGS among the missing, so a star importer's first use
    would raise NameError. Deriving it rather than writing it out is what keeps it a
    projection of the table instead of a third list of names to keep in step.

Why the resolved read does not call importlib.import_module. That function is an
attribute of a module any caller can rebind, and callers do: three sites in this
repository install patch("importlib.import_module") for reasons of their own. With
it on the resolved path, every read of every gate here was answered by whatever that
patch returned for as long as it was installed -- set(security._SENSITIVE_HOME_DIRS)
became an empty set built from a MagicMock, and the governance boot check refused
with its trust-root paths reported missing. Reading sys.modules first removes the
coupling: the store answers, and no unrelated patch can stand between a security
predicate and its owner. A test that needs an unresolvable owner now makes one the
way the condition really occurs -- absent from sys.modules and refusing to import.

The chain from symptom to root cause: a facade that BINDS a name has a copy; a copy
is only correct at the moment it is made; an owner write happens after that moment;
so the copy answers with a superseded object. Removing the binding removes the
copy, and there is then nothing that can be stale. The same argument one level up
for the module: a map of resolved module objects is a copy of sys.modules, and
import_module is sys.modules.

Three things this change had to handle that a thin re-export shim does not.

  1. This __init__.py holds 2,929 lines of its own code, and 74 of its own load
    sites read a re-exported name. A function defined here resolves a bare global
    through this module's namespace, which __getattr__ never sees, so those reads
    would only work if the facade bound the names -- the copy being removed. All 74
    now ask for the owner and read the name off it. Enumerated by condition (any
    Load of a table name at any nesting depth), which is how the five sites inside
    StreamRedactor and the one inside a nested _reason were found rather than
    the twelve top-level functions that resemble each other.
  2. is_denied alone holds 38 of those sites, and it is the per-tool-call
    predicate. It resolves its four owners ONCE per call rather than per read.
  3. One module-level site bakes a character class into a compiled regex at import.
    That is a one-shot build input, not a stored re-export, and it reads off the
    submodule directly -- the resolver is defined later, with the rest of the
    machinery, after this module has finished binding its own names.

Fail-closed, ruled on deliberately rather than left as a footnote. A read can now
raise ImportError where it could not before, and on a security predicate the
hazard is not the exception -- it is an exception quietly becoming a falsy answer.
getattr(security, "is_sensitive_path", None) swallows AttributeError and lets
ImportError through, so the facade raises ImportError for a table name whose
owner will not import, and AttributeError only for a name that does not exist.
A None that a caller reads as "not sensitive" would grant exactly what the gate
refuses, and cannot now be produced. The repository's own guards already rest on
that distinction: spec_builder's parser wraps its import, and with no security
module its is_sensitive_path fallback answers True for every path.

Organizational security guidance was consulted before writing this, and it says
what is pinned above: a component's default behaviour on failure must be to deny.
The tool that normally serves that guidance is not reachable from this session, so
the fail-closed default was taken rather than any policy being invented.

Disclosed cost, both revisions measured in one window with one harness, four
alternating runs each. A single read of a re-exported name through the facade costs
about 482 ns against the base's 42 ns, because it resolves the owner and reads the
name instead of hitting a local dict. No cache was added to hide that, for the
reason under Not a goal. End to end the hot predicate is unchanged: is_denied on
the same command measured 363 us per call on this branch against 358 us on the
base, about 1% and inside the base's own 5 us run-to-run spread on this box,
because it resolves each owner once per call rather than once per read.

Three test sites moved rather than being kept working by a sync mechanism, all one
class: a name the facade does not define, patched or enumerated on the facade, whose
reader is elsewhere. Six more were in test_security_path_resolve_bounded.py,
patching security.paths for path_resolve_executor; #12879 rewrote that file onto
a subprocess-pool resolver that already patches security.paths, so its version is
taken unchanged and this branch no longer touches it. Of the three that remain, two
patch security.exfil for SecurityEventLog, which comes from
kiro_crew.sel and which exfil._emit_oauth_extension_used_event reads through
exfil's globals -- one of those two was failing loudly and the other was degrading
silently and writing real SEL events. One is the credential-redaction-tag ratchet,
which enumerated vars(security) for _REDACTED_*_TAG constants and now enumerates
vars(security.redaction), the namespace that defines them; left on the facade it
found nothing and stopped guarding the tag registry.

Two package-shape gates report this conversion, and both are answered as the gate
asks rather than muffled.

test_only_baseline_modules_violate_the_rule[kiro_crew.security] is the one-storage
ratchet reporting that the conversion WORKED. Its baseline set records the modules
that still map a name to a resolved owner module, and it asserts in both directions,
so a module that starts satisfying the rule reddens until it is de-listed. It is
de-listed here, and the module docstring's count corrected from seven to six. That
promotes kiro_crew.security into COMPLIANT, which earns it a fourth case with no
edit there: the sys.modules read only compliant modules run.

test_the_package_stays_within_its_line_budget is the package line ceiling.
Resolving each name through its owner replaces one eager import block with two name
lists -- an owner table and a TYPE_CHECKING block, one line per exported name in
each -- which measured 618 lines at this surface: the facade goes from 3,035 lines
to 3,653 and no other file in the package moves. That ceiling's own comment defines
it as the pre-split size plus room for the machinery, and this is the machinery it
means, so it moves from main's 27,200 to 27,751.

27,751 is the package's measured total, not a figure above it. A ceiling with spare
room admits exactly the unreviewed growth the ratchet exists to catch, so the number
is pinned at the measurement and the comment says so: the next line added to this
package fails this gate and has to be re-pinned deliberately. Proven tight rather
than assumed -- appending three lines to security/vocabulary.py reddens it with
"package grew to 27754 lines". The guards that actually detect a monolith growing
back are untouched and hold with margin: the facade is 3,653 lines against a
4,500 per-file cap, the largest file in the package is argv_floor.py at 4,132, and
at 13% of the package the facade stays well inside the one-fifth share its own gate
allows.

docs/system-specs/modules/security.md is updated in the same commit, as the owning
spec for this module must be. Its facade section described the mechanism this change
replaces -- a frozen manifest plus patch mirroring, with _SUBMODULES named -- and
now states re-export by resolution, where the value and the module each live, the
boundary for a name this package does not define, and the fail-closed ImportError
rule.

Backwards compatibility

Compatible on the public surface. The star-import surface goes from 142 public names
on the base to 143 here; the single addition is importlib, which the runtime
resolution imports. Any moved under TYPE_CHECKING, where postponed annotations
need it, so it adds nothing. Every other name is carried name for name.

Two changes are real and deliberate, and neither has a reader outside this package.

_EXPORT_OWNERS, _SUBMODULES, _export_owners() and _MirroringModule are
removed. Writer sweep on origin/main @ c203fac29e4b, whole repository: no reader
outside src/kiro_crew/security/ and this PR's own diff. _export_owners has no
reader anywhere; _SUBMODULES appears in docs/system-specs/modules/security.md
and test/test_security_facade.py, and _MirroringModule in
test/test_security_facade.py -- all three files are updated in this PR. The
_EXPORT_OWNERS hits elsewhere are dev_fleet/server.py's own unrelated symbol of
the same name, not a reader of this one.

A read of a table name can now raise ImportError where it previously could not.
This TIGHTENS behaviour for a caller using getattr(security, name, default) and
relying on the default: the default no longer absorbs an unimportable owner. That is
the point, argued under fail-closed above -- a swallowed failure on a security
predicate grants what the gate refuses. AttributeError for a name that does not
exist is unchanged, so getattr with a default still behaves as before for the case
it was written for.

Tests

test/test_security_single_storage.py is new and holds the rule. Its cases are
generated from the package's own _EXPORTS table, so the subject is the condition
-- every re-exported name -- and not the sites this change happened to touch.
2,869 cases pass with test_security_facade.py.

It asserts single storage rather than the edits: the facade binds no table name and
a read does not bind one; a read answers with the owner's object; an owner write is
seen through the facade and a facade write reaches the owner; the table holds no
module object; a replaced owner and a genuinely purged-and-reimported owner are both
seen at once by a read AND by a write; a resolved owner is read without calling
importlib.import_module at all, asserted by refusing that call outright; the
facade's own code reads no table name as a bare global; every public table name is
declared and resolvable while no private one is, and the declared list is derived
from the table rather than written out; no submodule this package binds disagrees
with sys.modules; and each of five path gates raises ImportError rather than
answering when its owner will not resolve, including through
getattr(..., default).

test_the_type_checking_block_names_every_owned_name in test/test_security_facade.py
is new and pins the third copy of the name list. The conversion leaves the export
names written out in three places, and nothing checked the TYPE_CHECKING block.
That block never executes, which is why no runtime assertion can notice it drifting:
a name added to the owner table and forgotten there still resolves for every caller,
and the only symptom is that type checkers and IDEs quietly stop knowing it. The
test reads the block from source and requires it to name every owned name, and to
attribute each to the same module the owner table resolves it through. Rebasing this
branch proved it live: main added bounded_blocked_links and
redact_exfiltration_urls_with_records to the eager import block this change
removes, and the pin is what required both to be entered in the owner table and the
TYPE_CHECKING block rather than silently lost from one of them.

The star-import cases assert the contents of __all__ rather than running a star
import. What the import statement does with that list is the language's; what is in
it is this module's. Running one also meant exec, which the SAST lane flags as a
finding in its own right, and suppressing a security rule to test a security module
is the wrong trade when the same properties are directly assertable.

A purge test changes two things, not one, and both are restored together by one
context manager the file's purge cases share. sys.modules is the obvious one. The
other is this package's own attribute: importlib finishes a submodule import by
setting it on the parent package, and that leaf name is an _EXPORTS VALUE rather
than a key, so the write lands on the package itself. A restore of sys.modules
alone therefore left security.paths pointing at a module no reader runs, and every
later monkeypatch.setattr(security.paths, ...) in that worker would have patched
the dead copy. That is this issue's own defect reproduced inside the harness meant
to catch it, so the teardown proves itself rather than being trusted: on the path
where the body succeeded, the context manager reads the binding back and asserts it
is the object sys.modules holds, and a separate case reads every submodule binding
the same way, so a leak left by any case in the worker fails here instead of
surfacing later as a patch that reaches nobody.

Mutation, with a passing control and a hash proving each patch applied. Eleven
mutations, each re-introducing a second storage, removing a declared surface, or
weakening the harness's own teardown from a DIFFERENT place, and the pin went red for
all eleven. Control: the selected cases pass unmutated. Every mutation changed the
file's hash, and each file was restored to its reference hash afterwards.

Mutation What it re-introduces, removes or weakens Caught
M1 the facade binds one name in its own namespace again yes
M2 the resolver memoises resolved owner modules in a dict yes
M3 the table maps a name to a module OBJECT yes
M4 a read writes the resolved value back into globals() yes
M5 an unimportable owner is reported as AttributeError yes
M6 a facade function reads a name as a bare global again yes
M7 a write binds the facade instead of reaching the owner yes
M8 __all__ is deleted, so a star import loses the re-exports yes
M9 __all__ is written out as a literal list of names yes
M10 the derivation stops excluding private names yes
M11 the purge teardown restores sys.modules only yes

M3 is worth naming: its first form inserted the module object at the top of the
dict literal, where the later literal key for the same name overrode it. The hash
changed but the mutation had no effect, and it scored as MISSED. Replacing the
existing entry instead made it real, and the pin caught it. A mutation harness
without a hash check and a control would have read that as a weak pin.

A separate four-mutation harness covers the two package-shape gates: restoring the
line budget to its pre-change value, re-listing kiro_crew.security in the ratchet
baseline, dropping one TYPE_CHECKING import, and misattributing one. All four went
red, with a green control. Each substitution was asserted to match exactly one site,
and restores come from pristine copies held outside the repository so a re-run cannot
revert working tree changes.

Suites run, on the rebased tree against base c203fac29e4b:
test_security_single_storage.py, test_security_facade.py and
test_mirrored_owner_storage.py (2,890 together),
test_security_gate_liveness.py (10),
test_security_path_resolve_bounded.py (82) -- #12879's own file, unchanged here
but run because this change is what it reads a re-exported name through --
test_push_branch_gate.py, test_denied_commands_security.py and
test_cli.py::TestMcpBuiltinDispatch (1,398 together, 1 skipped), and
test_security.py scoped by node id to the three tests this change touches (3).
4,383 passed, 1 skipped, 0 failed. Gates: black, isort and flake8 clean on all
six changed Python files, and mypy reports nothing in any of them. mypy does follow
imports into two files this change never touches: src/kiro_crew/transcribe.py (2,
byte-identical to main) and test_security.py itself (21) -- main's own copy of
that file reports the identical 21, error text for error text. The full suite is
CI's.

Before and after on one probe, run against both revisions:

Reading base this branch
names where a facade read misses an owner write 467 / 467 0 / 467
facade read after a purge matches the fresh owner no yes
owner resolution answers the fresh module no yes
a patch after a purge reaches the fresh owner no yes
public names a star import carries 142 143

Manual verification

N/A -- unit coverage sufficient. This change has no user-visible surface: it alters
how one package resolves its own re-exported names, and every property claimed above
is asserted by a test rather than observed by hand. The one thing a human could check
that a test cannot -- that type checkers still see all 468 names -- is covered by
mypy running clean over the facade plus the new TYPE_CHECKING pin.

Related Issues

Fixes #13784

Pattern harvest

Rule candidate: when one value is mirrored into two places with one-way
synchronisation, delete the second place and derive it, rather than adding the
missing direction. A second copy kept in sync is a cross-file contract someone has
to remember; the direction that is missing today is evidence the contract already
decayed. Here the missing direction was owner-to-facade, and adding it would have
left the copy and needed a third mechanism for the purge case. Removing the copy
closed both halves at once.

Rule candidate: enumerate a fix's sites by the CONDITION that defines them, read
off the source, not by resemblance to the site the report named. The condition here
was "any Load of a table name at any nesting depth", which found six sites inside
a class method and a nested function that a sweep of top-level functions missed --
each of which would have been a NameError on a path no test may cover.

Rule candidate: when a value is read on demand rather than held, read the STORE and
let the populating call answer only the miss. sys.modules is where a module lives;
importlib.import_module is how it gets there, and it is a rebindable attribute of
another module. Putting the populating call on the resolved path made an unrelated
patch("importlib.import_module") in a test able to answer a security gate's read,
and the reader could not tell. The same shape applies to any lazily resolved value
whose resolver is reachable and replaceable by a third party.

Rule candidate: a conversion that writes the same list of names into more than one
place needs a pin per copy, and the copy that needs it most is the one that never
executes. A TYPE_CHECKING block cannot be checked by any runtime assertion, so it
drifts silently and the only symptom is a type checker quietly losing a name. This
rebase demonstrated the failure mode on live code.

Not generalizable: the choice to resolve is_denied's four owners once per call
rather than per read is specific to a predicate that reads 38 names on a per-tool-
call path. Elsewhere in this change a per-read resolution is both simpler and
cheap enough.

Checklist

  • At most two commits (one here), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (docs/system-specs/modules/security.md)
  • No secrets, credentials, or internal references in the diff

@chenmingwei23
chenmingwei23 requested review from a team and krishdhasmana September 25, 2026 18:27
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 25, 2026
@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of 82bc5c0142c00a12f167d7dd597adbb7617e1670 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Verify the deferred conftest disagreement-detector is filed as a follow-up: non-owned names (e.g. SecurityEventLog) still accept silent facade-local patches.

[DESIGN-REVIEWED] 82bc5c0

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 82bc5c0142c00a12f167d7dd597adbb7617e1670 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 82bc5c0

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 82bc5c0142c00a12f167d7dd597adbb7617e1670: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of 82bc5c0142c00a12f167d7dd597adbb7617e1670 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

The memo-free spelling is justified as "converging" with the six #13727 packages — which are pinned to the opposite spelling and keep the stale-owner defect this PR names.

Not justified as shipped

  • Item 7 — inherited: "The spelling matches the six packages converted in fix: resolve a lazily re-exported name's owner through sys.modules #13727, including its ban on a private owner mapping, so the two converge rather than needing reconciliation later" is the symmetry form, and the symmetry does not hold: all 6 PACKAGES in test/test_lazy_reexport_storage.py carry _OWNERS: dict[str, ModuleType] = {} (counted 6/6, spot-verified in stt/__init__.py:190 and dashboard/__init__.py:46; the spelling is REQUIRED by test_every_package_spells_the_rule_the_same_way), a resolved-owner memo that keeps exactly the purge-and-reimport stale-owner defect this PR's Goal names, while the new pin file FORBIDS it — so the two pinned spellings are mutually exclusive and the pin file's stated retirement path ("security joins PACKAGES") cannot occur as written.
    Subtraction: delete the _OWNERS import memo from the six lazy-reexport packages — genuinely larger than this change, so accepted-and-deferred, not a demand on this diff.
    Clears when: the _OWNERS memo is deleted from the six PACKAGES, or test_lazy_reexport_storage.py's spelling pin admits the memo-free form so the retirement clause becomes reachable.

What this change ships

Inventory (10 items) — 9 justified

Intent: FIX — a patch applied at a security control's owning submodule (or after a purge-and-reimport) now governs every reader that goes through the kiro_crew.security facade; provenance is the added test suite that fails on base.

  1. An owner-side patch is now visible through the facade — justified
  2. After purge-and-reimport, facade reads and writes hit the fresh owner module — justified
  3. A table name whose owner cannot import now raises ImportError; getattr(..., None) cannot make a gate falsy — justified
  4. Tests patching importlib.import_module (3 counted sites) no longer reroute gate reads — justified
  5. Patching a non-owned name (SecurityEventLog) on the facade no longer reaches its reader; two in-repo sites moved to the owner — justified
  6. __all__ now declared, derived from the table, preserving the star-import surface — justified
  7. New 656-line pin file test_security_single_storage.py, a declared duplicate of the lazy-reexport rule with a retirement clause — inherited (the convergence premise, see above)
  8. is_denied and 73 sibling in-facade sites resolve owners per call instead of binding at import — justified
  9. Security package line budget re-pinned 27,200→27,751 with reason recorded, per the pin's own protocol — justified
  10. kiro_crew.security de-listed from the mirrored-owner ratchet (7→6), per that ratchet's own de-listing rule — justified

[FIRST-PRINCIPLES-REVIEWED] 82bc5c0

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 25, 2026
@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- 🟡 CONCERNS

Which legitimate operations does 82bc5c0142c00a12f167d7dd597adbb7617e1670 newly refuse? Updated in place on each push. A script-confirmed regression blocks; the model proposes candidates and never decides a refusal.

Verdict basis: the reviewer's own judgement; no confirmed regression.

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 14 classified, 0 newly refused, 14 still allowed.
  • ubuntu-latest (platform posix): 14 classified, 0 newly refused, 14 still allowed.
  • windows-latest (platform windows): 11 classified, 0 newly refused, 10 still allowed.

No candidate flipped from allowed to refused.

Scope-Verdict: CONCERNS

TIGHTENING: the security facade's re-export protocol — eager name binding plus one-way write mirroring replaced by per-access resolution through an _EXPORTS owner table, with resolution failure made fail-closed. The ONE threat the strict half refuses is an unresolvable security gate quietly becoming a falsy answer: "a name in the table whose owner will not import raises ImportError, and only a name that does not exist raises AttributeError. getattr(security, "is_sensitive_path", None) swallows the second and lets the first through, so an unresolvable gate cannot become a None a caller reads as "not sensitive"" (docs/system-specs/modules/security.md hunk; implemented in the new __getattr__ in src/kiro_crew/security/__init__.py). No deny pattern, floor predicate, path fence, or exfil shape changed text — but is_denied, _deny_segment_views, _split_segments, audit_bash_command, and the perm-verb-mention narrowing were all rewritten to read their patterns and predicates off the owning submodule at call time, so every tier of the composite runs through new plumbing.

ADJUDICATED: 19 candidates, 0 confirmed newly-refused
The candidates probe the boundary of every tier whose read path the rewiring touched: the self-protection floors (by-pid kill, kill-by-name of a non-self program, ssh to a non-self host, upgrade of a non-self package), the git-publish floor (refspec spelling of a feature push), the rule catalog's env-credential and interpreter rows (printenv PATH, benign python3 -c), the perm-verb-mention narrowing whose ALLOW verdict now depends on two owner resolutions (grep/findstr for chmod 777 in the catalog's own tests, git log --grep for a rule id), the nested-payload segment walk (bash -c 'git status --porcelain'), the path fence over the governance tree (reading the facade file itself, both spellings), and the exfil tier's nearest allowed neighbour (a credential-free HTTPS GET). No verdict handed to me reported a flip, and I claim none I did not receive.

PLATFORM COVERAGE: posix, windows, and any. The diff itself adds no path, separator, interpreter, or environment-variable assumption — owner resolution is by dotted module name, identical on both hosts — but the composite it rewires embeds host-specific machinery (_ON_WINDOWS, _UNC_PREFIX_RE, the %VAR% versus $VAR tokenizers), so wherever a candidate carries a path, an executable name, or an env-var spelling I wrote both spellings as separate rows: kill by pid (kill / taskkill /PID), the PATH diagnostic (printenv PATH / echo %PATH%), the catalog audit (grep -rn / findstr /S /C:), the governance-tree read (cat / Get-Content with backslashes), and the facade-test invocation (.venv/bin/python / .venv\Scripts\python.exe). Platform-neutral strings (git, gh-style, curl, aws, ssh) went in as any, matching corpus practice. I know of no platform spelling the diff assumes that the candidates leave unprobed; the per-leg verdicts are the deterministic fold's to report, by leg name, after this review is captured.

UNADJUDICATED: the module-resolution guard itself, which no shell command line can reach. Guard: __getattr__/_owner/_submodule in src/kiro_crew/security/__init__.py (raise ImportError for a table name whose owner will not import; read sys.modules before importlib.import_module so a patched import_module cannot reroute a gate's read), plus _ReExportModule.__setattr__/__delattr__ forwarding writes to the owner. Call path: any Python caller doing getattr(kiro_crew.security, "<name>", default), hasattr(security, "<name>"), or a monkeypatch set/delete through the facade, in a process where a submodule has been purged from sys.modules and its reimport fails. The candidate legitimate inputs I would have submitted, in prose: (1) a defaulted-getattr availability probe — getattr(security, "is_sensitive_path", None) — used by degraded-environment callers, which previously could only see AttributeError-shaped absence and now receives a propagating ImportError; (2) hasattr(security, gate) feature checks, which swallow only AttributeError and so now propagate instead of answering False; (3) a monkeypatch.setattr(security, name, ...) round trip across a purge-and-reimport, which the forwarding must keep symmetric. The new test_security_single_storage.py exercises exactly these in-process, which is evidence but is the PR testing itself, not an independent verdict. The same limit applies to the rewired redaction/URL surfaces (sanitized_oauth_endpoint*, StreamRedactor.feed, redact_and_truncate, the memory-audit scans): their inputs are URLs and streamed text, not tool-call command lines, so the classifier settles nothing for them; candidate inputs there are an approved operator OAuth consent URL and an ordinary credential-free output stream, which must keep passing un-redacted. These gaps, not any confirmed refusal, are what hold this at CONCERNS.

[SCOPE-REVIEWED] 82bc5c0

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

Reviewed 82bc5c0142c00a12f167d7dd597adbb7617e1670 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 82bc5c0

Verdict parsed from the review's SHA-scoped output markers for commit 82bc5c0142c00a12f167d7dd597adbb7617e1670.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 82bc5c0142c00a12f167d7dd597adbb7617e1670: <one-sentence reason>

@chenmingwei23
chenmingwei23 force-pushed the fix/security-facade-single-storage-13784 branch from f059b8e to e6d8915 Compare September 25, 2026 19:26
@chenmingwei23
chenmingwei23 force-pushed the fix/security-facade-single-storage-13784 branch from e6d8915 to 3f55ded Compare September 25, 2026 20:18
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 25, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/security-facade-single-storage-13784 branch from 3f55ded to ce39b89 Compare September 25, 2026 20:39
@github-actions github-actions Bot added readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 25, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Owed after this PR merges: one deletion from the ratchet baseline

This PR converts kiro_crew.security so the facade holds each owner's dotted NAME
and resolves it per use, which means that package no longer stores resolved owner
modules. A shrink-only baseline on main still lists it as a known violator, and
that entry has to leave when this merges.

The exact edit, in one file on main:

  • File: test/test_mirrored_owner_storage.py
  • Set: _KNOWN_RESOLVED_OWNER_MIRRORS (a frozenset literal)
  • Delete the line: "kiro_crew.security",

Delete nothing else from that set. #13727 owes the same deletion for six other
names (kiro_crew.config, kiro_crew.crew_log, kiro_crew.dashboard,
kiro_crew.diag, kiro_crew.mcp_gateway, kiro_crew.stt), and #13769 stays open
until the set is empty and is deleted along with it.

This is self-enforcing, so you do not have to remember it

test_only_baseline_modules_violate_the_rule in that same file asserts the rule in
BOTH directions: a module off the baseline must satisfy it, and a module ON the
baseline must still break it. That second half is what stops the baseline becoming
standing permission. Once this PR's conversion is on main, kiro_crew.security
satisfies the rule, so the assertion fires:

kiro_crew.security satisfies the one-storage rule but is still listed in
_KNOWN_RESOLVED_OWNER_MIRRORS. Remove it from that set so the ratchet keeps
tightening.

main stays red until the line is deleted. The failure names the file and the set,
but not which PR owed the deletion, which is what this comment is for.

This PR does not touch test_mirrored_owner_storage.py at all: it postdates this
branch's base, so the deletion is a follow-up edit on main, not a change that
could have shipped here.

@bolichen97

Copy link
Copy Markdown
Contributor

Rebased onto `main` (694f619) to clear the conflict. Two things the rebase decided, and one it did not.

Conflict in `src/kiro_crew/security/init.py`. Taken as this PR intends: the explicit 490-line re-export block is gone and names resolve through `getattr` over `_EXPORTS`.

A regression the rebase exposed, fixed here. `main` grew three re-exported names after this branch point that `_EXPORTS` did not carry, so the facade stopped exporting them: `canonical_path_refusal`, `_PERM_VERB_MENTION_PATTERNS` and `_perm_verb_mention_only`. `kiro_crew.artifacts` imports the first one from the facade, so collection failed repo-wide. All three are in `_exports.EXPORTED_NAMES`, so the frozen inventory already expected them. Added to `_EXPORTS` (new `perm_verb_mention` owner group) and to the `TYPE_CHECKING` mirror. `main` also added `_perm_verb_mechanism_for` and `_perm_verb_mention_narrows`, which read two of those names as BARE globals — which `getattr` never sees — so both now resolve through `_submodule(...)`, per this PR own rule. Verified: all 468 names `main` re-exported resolve on the facade, and `test_security_single_storage.py` passes 2846/2846 including `test_the_facade_reads_no_re_exported_name_as_a_bare_global`.

Left for you: `test_the_package_stays_within_its_line_budget` is red and I did not move the constant. The package is 26215 lines against `_PACKAGE_LINE_BUDGET = 26_000`. Neither side breaks it alone — `main` is 25597 and this branch pre-rebase was 25257 — so the overage is the sum, not a fault in this diff. Raising a volume ratchet to fit your own growth is the deliberate edit the pin exists to force, and that call is yours: either bump it with a justification, or fold one of the three name lists (`_EXPORTS`, the `TYPE_CHECKING` mirror, `_exports.EXPORTED_NAMES`) so the total comes back under. Everything else in the security sweep is green (6690 passed, this the only failure).

[operator: bolichen97]

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 27, 2026
The security facade bound every re-exported name in its own namespace and kept
a map of resolved owner module objects beside sys.modules, so one name had two
storage locations for its value and two for its module. Both now resolve through
the import system: the value is read from the owner on each access via a module
__getattr__, and the owner is looked up with importlib.import_module from a
name-to-module-NAME table.

Measured on the base revision: an owner write was invisible through the facade
for 465 of 465 re-exported names, so patch.object(<submodule>, ...) left a reader
that went through the facade running the object the test believed it replaced.

A read can now raise ImportError where it could not before. On a security
predicate the hazard is an exception quietly becoming a falsy answer, so the
facade raises ImportError for a table name whose owner will not import and
AttributeError only for a name that does not exist -- getattr(..., default)
swallows the second and not the first.

Read the owner from sys.modules and import only on the miss, so a caller that
rebinds importlib.import_module cannot answer a security gate. Derive __all__
from the export table, because a star import is resolved against a declared list
and never reaches __getattr__. Prove the purge teardown restores both the store
and this package's own attribute, which a submodule import rebinds. Repoint the
nine facade sites for names this package does not define at the modules that
read them. Restate the facade section of the security spec.

Two shard reds this conversion caused are settled here, one per shard, and both
failed on python and Windows alike because neither is environmental.

test_only_baseline_modules_violate_the_rule[kiro_crew.security] is the one-storage
ratchet reporting that the conversion worked. The baseline set records the modules
that still hold a mapping to resolved owner MODULES, and it asserts in both
directions, so a module that starts satisfying the rule reddens until it is
de-listed. De-list it, which is what the assertion asks for, and correct the count
in the module docstring from seven to six. That also promotes kiro_crew.security
into COMPLIANT, so it picks up the purge cases with no edit there: it gains a
fourth case, the sys.modules read that only compliant modules run.

test_the_package_stays_within_its_line_budget is the package line ceiling.
Resolving each re-exported name through its owner replaces one eager import block
with two name lists, an owner table and a TYPE_CHECKING block at one line per
exported name, which measured 618 lines at this surface: the facade goes from
3,035 lines to 3,653 and no other file in the package moves. That number's own
comment defines the budget as the pre-split size plus room for the machinery, and
this is the machinery it means, so the ceiling moves from main's 27,200 to 27,751.

27,751 is the package's measured total, not a figure above it. A ratchet with
spare room admits exactly the unreviewed growth it exists to catch, so the number
is pinned at the measurement and the comment says so: the next line added to this
package fails this gate and has to be re-pinned deliberately. Proven tight rather
than assumed -- appending three lines to security/vocabulary.py reddens the gate
with "package grew to 27754 lines". The guards that actually detect a monolith
growing back are untouched and hold with margin: the facade is 3,653 lines
against a 4,500 per-file cap, and at 13% of the package it stays well inside the
one-fifth share its own gate allows.

The conversion leaves the export names written out in three places, and nothing
checked the third, so add that pin. The TYPE_CHECKING block never executes, which
is why no runtime assertion can notice it drifting: a name added to the owner
table and forgotten there still resolves for every caller, and the only symptom
is that type checkers and IDEs quietly stop knowing it. The new test reads the
block from source and requires it to name every owned name, and to attribute each
to the same module the owner table resolves it through.

Two rebases have now proved that pin live, in both directions. The first: main
added bounded_blocked_links and redact_exfiltration_urls_with_records to the eager
import block this change removes, and both had to be entered in the owner table
and the TYPE_CHECKING block. The second, onto #12879: main deleted
_path_resolve_wedged and _wedged_workers from that block and from EXPORTED_NAMES,
and the pin requires all three lists to agree, so both had to come out of the
owner table and the TYPE_CHECKING block here. #12879 also rewrote
test_security_path_resolve_bounded.py onto a subprocess-pool resolver that already
patches security.paths rather than the facade, which is what this change asked of
that file, so its version is taken unchanged and this branch no longer touches it.
@chenmingwei23
chenmingwei23 force-pushed the fix/security-facade-single-storage-13784 branch from 045fc00 to 82bc5c0 Compare September 27, 2026 14:37
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Sep 27, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed on behalf of the maintainers (sweep 2026-09-27): readiness passed, required checks green on 82bc5c0, no blocking review threads, security posture unchanged. Approving and merging.

@bolichen97
bolichen97 merged commit 8128b97 into main Sep 27, 2026
102 checks passed
@bolichen97
bolichen97 deleted the fix/security-facade-single-storage-13784 branch September 27, 2026 16:52
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 27, 2026
chenmingwei23 pushed a commit that referenced this pull request Sep 28, 2026
…14543)

The 7,925-line dashboard/handlers/source_providers.py held URL
validation, the provider-CLI runner, three providers' reads, the ADF
converter, two caches, the chip refresh loop and every write. Each now
has one owner module under dashboard/source_providers/, moved verbatim.

The handler keeps the /api/source/* routes, their audit and error
mapping, and the dashboard owner gate. Every other name it defined still
resolves there. Reads come from the owner and writes are forwarded to
it, reusing the security package's re-export pattern (#13933), so
existing imports and patches still reach the running code. Owners reach
each other as modules and import only earlier owners, so the owners
form no cycle.

The owners that redact provider data join security_posture's non-egress
allowlist in place of the handler. The spawn-audit tripwire now names
runner._run_provider, the function that actually spawns. The dashboard
spec records the owner map.
bolichen97 added a commit that referenced this pull request Sep 30, 2026
sandbox.py and platform_compat.py each held several separate
responsibilities in one file. Five of them now live in their own
modules, and each old module stays the import and patch surface:

- sandbox_launcher: _build_launcher_script, the Linux namespace
  launcher program.
- sandbox_seatbelt: the macOS Seatbelt profile and its builder.
- sandbox_mount_sweep: the stale bind-mount source sweep that
  cleanup_stale_sandbox_profiles runs.
- platform_lock_compat: the cross-process file locks and the
  persistence probe.
- platform_owner_compat: account identity, the writability checks
  and the owner-only lockdown.

Code moved verbatim. The builders and helpers import the tables,
flags and helpers they read from the facade inside the function, so
a patch on the facade still reaches them at call time. Both facades
forward every moved name to its owner by resolution, reads and
writes alike, following the security/ facade (#13933).

Declared text edits on moved lines:
- The generated launcher's docstring and one builder comment spell
  the product name as two words, as the brand gate requires. That
  docstring line is the only byte of the generated launcher that
  changes.
- An owner-only docstring is reworded to satisfy the
  comment-history gate.
- Comments and docstrings that placed moved code in its old file,
  or "above" it, now name the owner.

New tests:
- Pin both generated programs byte for byte against the
  pre-split builders, over a pinned host and pinned tables.
- Pin the facade forwarding, the owner seams, the import
  direction and the loggers.
- Refuse any create=True patch of a forwarded name.

The owning specs (security.md, platform-compat.md) name the owners.
Entry-scoped grants cover:
- the platform-context.md owner citation;
- the test_identity_topology registry key;
- the darwin CI path filter;
- the AUTOSDE file patterns;
- the dogfood source-text guard, which now reads the ssh handling
  from the facade and both builder owners.
bolichen97 added a commit that referenced this pull request Sep 30, 2026
sandbox.py and platform_compat.py each held several separate
responsibilities in one file. Five of them now live in their own
modules, and each old module stays the import and patch surface:

- sandbox_launcher: _build_launcher_script, the Linux namespace
  launcher program.
- sandbox_seatbelt: the macOS Seatbelt profile and its builder.
- sandbox_mount_sweep: the stale bind-mount source sweep that
  cleanup_stale_sandbox_profiles runs.
- platform_lock_compat: the cross-process file locks and the
  persistence probe.
- platform_owner_compat: account identity, the writability checks
  and the owner-only lockdown.

Code moved verbatim. The builders and helpers import the tables,
flags and helpers they read from the facade inside the function, so
a patch on the facade still reaches them at call time. Both facades
forward every moved name to its owner by resolution, reads and
writes alike, following the security/ facade (#13933).

Declared text edits on moved lines:
- The generated launcher's docstring and one builder comment spell
  the product name as two words, as the brand gate requires. That
  docstring line is the only byte of the generated launcher that
  changes.
- An owner-only docstring is reworded to satisfy the
  comment-history gate.
- Comments and docstrings that placed moved code in its old file,
  or "above" it, now name the owner.

New tests:
- Pin both generated programs byte for byte against the
  pre-split builders, over a pinned host and pinned tables.
- Pin the facade forwarding, the owner seams, the import
  direction and the loggers.
- Refuse any create=True patch of a forwarded name.

The owning specs (security.md, platform-compat.md) name the owners.
Entry-scoped grants cover:
- the platform-context.md owner citation;
- the test_identity_topology registry key;
- the darwin CI path filter;
- the AUTOSDE file patterns;
- the dogfood source-text guard, which now reads the ssh handling
  from the facade and both builder owners.
bolichen97 added a commit that referenced this pull request Sep 30, 2026
sandbox.py and platform_compat.py each held several separate
responsibilities in one file. Five of them now live in their own
modules, and each old module stays the import and patch surface:

- sandbox_launcher: _build_launcher_script, the Linux namespace
  launcher program.
- sandbox_seatbelt: the macOS Seatbelt profile and its builder.
- sandbox_mount_sweep: the stale bind-mount source sweep that
  cleanup_stale_sandbox_profiles runs.
- platform_lock_compat: the cross-process file locks and the
  persistence probe.
- platform_owner_compat: account identity, the writability checks
  and the owner-only lockdown.

Code moved verbatim. The builders and helpers import the tables,
flags and helpers they read from the facade inside the function, so
a patch on the facade still reaches them at call time. Both facades
forward every moved name to its owner by resolution, reads and
writes alike, following the security/ facade (#13933).

Declared text edits on moved lines:
- The generated launcher's docstring and one builder comment spell
  the product name as two words, as the brand gate requires. That
  docstring line is the only byte of the generated launcher that
  changes.
- An owner-only docstring is reworded to satisfy the
  comment-history gate.
- Comments and docstrings that placed moved code in its old file,
  or "above" it, now name the owner.

New tests:
- Pin both generated programs byte for byte against the
  pre-split builders, over a pinned host and pinned tables.
- Pin the facade forwarding, the owner seams, the import
  direction and the loggers.
- Refuse any create=True patch of a forwarded name.

The owning specs (security.md, platform-compat.md) name the owners.
Entry-scoped grants cover:
- the platform-context.md owner citation;
- the test_identity_topology registry key;
- the darwin CI path filter;
- the AUTOSDE file patterns;
- the dogfood source-text guard, which now reads the ssh handling
  from the facade and both builder owners.
bolichen97 added a commit that referenced this pull request Sep 30, 2026
sandbox.py and platform_compat.py each held several separate
responsibilities in one file. Five of them now live in their own
modules, and each old module stays the import and patch surface:

- sandbox_launcher: _build_launcher_script, the Linux namespace
  launcher program.
- sandbox_seatbelt: the macOS Seatbelt profile and its builder.
- sandbox_mount_sweep: the stale bind-mount source sweep that
  cleanup_stale_sandbox_profiles runs.
- platform_lock_compat: the cross-process file locks and the
  persistence probe.
- platform_owner_compat: account identity, the writability checks
  and the owner-only lockdown.

Code moved verbatim. The builders and helpers import the tables,
flags and helpers they read from the facade inside the function, so
a patch on the facade still reaches them at call time. Both facades
forward every moved name to its owner by resolution, reads and
writes alike, following the security/ facade (#13933).

Declared text edits on moved lines:
- The generated launcher's docstring and one builder comment spell
  the product name as two words, as the brand gate requires. That
  docstring line is the only byte of the generated launcher that
  changes.
- An owner-only docstring is reworded to satisfy the
  comment-history gate.
- Comments and docstrings that placed moved code in its old file,
  or "above" it, now name the owner.

New tests:
- Pin both generated programs byte for byte against the
  pre-split builders, over a pinned host and pinned tables.
- Pin the facade forwarding, the owner seams, the import
  direction and the loggers.
- Refuse any create=True patch of a forwarded name.

The owning specs (security.md, platform-compat.md) name the owners.
Entry-scoped grants cover:
- the platform-context.md owner citation;
- the test_identity_topology registry key;
- the darwin CI path filter;
- the AUTOSDE file patterns;
- the dogfood source-text guard, which now reads the ssh handling
  from the facade and both builder owners.
bolichen97 added a commit that referenced this pull request Oct 1, 2026
sandbox.py and platform_compat.py each held several separate
responsibilities in one file. Five of them now live in their own
modules, and each old module stays the import and patch surface:

- sandbox_launcher: _build_launcher_script, the Linux namespace
  launcher program.
- sandbox_seatbelt: the macOS Seatbelt profile and its builder.
- sandbox_mount_sweep: the stale bind-mount source sweep that
  cleanup_stale_sandbox_profiles runs.
- platform_lock_compat: the cross-process file locks and the
  persistence probe.
- platform_owner_compat: account identity, the writability checks
  and the owner-only lockdown.

Code moved verbatim. The builders and helpers import the tables,
flags and helpers they read from the facade inside the function, so
a patch on the facade still reaches them at call time. Both facades
forward every moved name to its owner by resolution, reads and
writes alike, following the security/ facade (#13933).

Declared text edits on moved lines:
- The generated launcher's docstring and one builder comment spell
  the product name as two words, as the brand gate requires. That
  docstring line is the only byte of the generated launcher that
  changes.
- An owner-only docstring is reworded to satisfy the
  comment-history gate.
- Comments and docstrings that placed moved code in its old file,
  or "above" it, now name the owner.

New tests:
- Pin both generated programs byte for byte against the
  pre-split builders, over a pinned host and pinned tables.
- Pin the facade forwarding, the owner seams, the import
  direction and the loggers.
- Refuse any create=True patch of a forwarded name.

The owning specs (security.md, platform-compat.md) name the owners.
Entry-scoped grants cover:
- the platform-context.md owner citation;
- the test_identity_topology registry key;
- the darwin CI path filter;
- the AUTOSDE file patterns;
- the dogfood source-text guard, which now reads the ssh handling
  from the facade and both builder owners.
bolichen97 added a commit that referenced this pull request Oct 1, 2026
sandbox.py and platform_compat.py each held several separate
responsibilities in one file. Five of them now live in their own
modules, and each old module stays the import and patch surface:

- sandbox_launcher: _build_launcher_script, the Linux namespace
  launcher program.
- sandbox_seatbelt: the macOS Seatbelt profile and its builder.
- sandbox_mount_sweep: the stale bind-mount source sweep that
  cleanup_stale_sandbox_profiles runs.
- platform_lock_compat: the cross-process file locks and the
  persistence probe.
- platform_owner_compat: account identity, the writability checks
  and the owner-only lockdown.

Code moved verbatim. The builders and helpers import the tables,
flags and helpers they read from the facade inside the function, so
a patch on the facade still reaches them at call time. Both facades
forward every moved name to its owner by resolution, reads and
writes alike, following the security/ facade (#13933).

Declared text edits on moved lines:
- The generated launcher's docstring and one builder comment spell
  the product name as two words, as the brand gate requires. That
  docstring line is the only byte of the generated launcher that
  changes.
- An owner-only docstring is reworded to satisfy the
  comment-history gate.
- Comments and docstrings that placed moved code in its old file,
  or "above" it, now name the owner.

New tests:
- Pin both generated programs byte for byte against the
  pre-split builders, over a pinned host and pinned tables.
- Pin the facade forwarding, the owner seams, the import
  direction and the loggers.
- Refuse any create=True patch of a forwarded name.

The owning specs (security.md, platform-compat.md) name the owners.
Entry-scoped grants cover:
- the platform-context.md owner citation;
- the test_identity_topology registry key;
- the darwin CI path filter;
- the AUTOSDE file patterns;
- the dogfood source-text guard, which now reads the ssh handling
  from the facade and both builder owners.
bolichen97 added a commit that referenced this pull request Oct 1, 2026
sandbox.py and platform_compat.py each held several separate
responsibilities in one file. Five of them now live in their own
modules, and each old module stays the import and patch surface:

- sandbox_launcher: _build_launcher_script, the Linux namespace
  launcher program.
- sandbox_seatbelt: the macOS Seatbelt profile and its builder.
- sandbox_mount_sweep: the stale bind-mount source sweep that
  cleanup_stale_sandbox_profiles runs.
- platform_lock_compat: the cross-process file locks and the
  persistence probe.
- platform_owner_compat: account identity, the writability checks
  and the owner-only lockdown.

Code moved verbatim. The builders and helpers import the tables,
flags and helpers they read from the facade inside the function, so
a patch on the facade still reaches them at call time. Both facades
forward every moved name to its owner by resolution, reads and
writes alike, following the security/ facade (#13933).

Declared text edits on moved lines:
- The generated launcher's docstring and one builder comment spell
  the product name as two words, as the brand gate requires. That
  docstring line is the only byte of the generated launcher that
  changes.
- An owner-only docstring is reworded to satisfy the
  comment-history gate.
- Comments and docstrings that placed moved code in its old file,
  or "above" it, now name the owner.

New tests:
- Pin both generated programs byte for byte against the
  pre-split builders, over a pinned host and pinned tables.
- Pin the facade forwarding, the owner seams, the import
  direction and the loggers.
- Refuse any create=True patch of a forwarded name.

The owning specs (security.md, platform-compat.md) name the owners.
Entry-scoped grants cover:
- the platform-context.md owner citation;
- the test_identity_topology registry key;
- the darwin CI path filter;
- the AUTOSDE file patterns;
- the dogfood source-text guard, which now reads the ssh handling
  from the facade and both builder owners.
bolichen97 added a commit that referenced this pull request Oct 1, 2026
sandbox.py and platform_compat.py each held several separate
responsibilities in one file. Five of them now live in their own
modules, and each old module stays the import and patch surface:

- sandbox_launcher: _build_launcher_script, the Linux namespace
  launcher program.
- sandbox_seatbelt: the macOS Seatbelt profile and its builder.
- sandbox_mount_sweep: the stale bind-mount source sweep that
  cleanup_stale_sandbox_profiles runs.
- platform_lock_compat: the cross-process file locks and the
  persistence probe.
- platform_owner_compat: account identity, the writability checks
  and the owner-only lockdown.

Code moved verbatim. The builders and helpers import the tables,
flags and helpers they read from the facade inside the function, so
a patch on the facade still reaches them at call time. Both facades
forward every moved name to its owner by resolution, reads and
writes alike, following the security/ facade (#13933).

Declared text edits on moved lines:
- The generated launcher's docstring and one builder comment spell
  the product name as two words, as the brand gate requires. That
  docstring line is the only byte of the generated launcher that
  changes.
- An owner-only docstring is reworded to satisfy the
  comment-history gate.
- Comments and docstrings that placed moved code in its old file,
  or "above" it, now name the owner.

New tests:
- Pin both generated programs byte for byte against the
  pre-split builders, over a pinned host and pinned tables.
- Pin the facade forwarding, the owner seams, the import
  direction and the loggers.
- Refuse any create=True patch of a forwarded name.

The owning specs (security.md, platform-compat.md) name the owners.
Entry-scoped grants cover:
- the platform-context.md owner citation;
- the test_identity_topology registry key;
- the darwin CI path filter;
- the AUTOSDE file patterns;
- the dogfood source-text guard, which now reads the ssh handling
  from the facade and both builder owners.
bolichen97 added a commit that referenced this pull request Oct 1, 2026
sandbox.py and platform_compat.py each held several separate
responsibilities in one file. Five of them now live in their own
modules, and each old module stays the import and patch surface:

- sandbox_launcher: _build_launcher_script, the Linux namespace
  launcher program.
- sandbox_seatbelt: the macOS Seatbelt profile and its builder.
- sandbox_mount_sweep: the stale bind-mount source sweep that
  cleanup_stale_sandbox_profiles runs.
- platform_lock_compat: the cross-process file locks and the
  persistence probe.
- platform_owner_compat: account identity, the writability checks
  and the owner-only lockdown.

Code moved verbatim. The builders and helpers import the tables,
flags and helpers they read from the facade inside the function, so
a patch on the facade still reaches them at call time. Both facades
forward every moved name to its owner by resolution, reads and
writes alike, following the security/ facade (#13933).

Declared text edits on moved lines:
- The generated launcher's docstring and one builder comment spell
  the product name as two words, as the brand gate requires. That
  docstring line is the only byte of the generated launcher that
  changes.
- An owner-only docstring is reworded to satisfy the
  comment-history gate.
- Comments and docstrings that placed moved code in its old file,
  or "above" it, now name the owner.

New tests:
- Pin both generated programs byte for byte against the
  pre-split builders, over a pinned host and pinned tables.
- Pin the facade forwarding, the owner seams, the import
  direction and the loggers.
- Refuse any create=True patch of a forwarded name.

The owning specs (security.md, platform-compat.md) name the owners.
Entry-scoped grants cover:
- the platform-context.md owner citation;
- the test_identity_topology registry key;
- the darwin CI path filter;
- the AUTOSDE file patterns;
- the dogfood source-text guard, which now reads the ssh handling
  from the facade and both builder owners.
bolichen97 added a commit that referenced this pull request Oct 1, 2026
…es (#15309)

sandbox.py and platform_compat.py each held several separate
responsibilities in one file. Five of them now live in their own
modules, and each old module stays the import and patch surface:

- sandbox_launcher: _build_launcher_script, the Linux namespace
  launcher program.
- sandbox_seatbelt: the macOS Seatbelt profile and its builder.
- sandbox_mount_sweep: the stale bind-mount source sweep that
  cleanup_stale_sandbox_profiles runs.
- platform_lock_compat: the cross-process file locks and the
  persistence probe.
- platform_owner_compat: account identity, the writability checks
  and the owner-only lockdown.

Code moved verbatim. The builders and helpers import the tables,
flags and helpers they read from the facade inside the function, so
a patch on the facade still reaches them at call time. Both facades
forward every moved name to its owner by resolution, reads and
writes alike, following the security/ facade (#13933).

Declared text edits on moved lines:
- The generated launcher's docstring and one builder comment spell
  the product name as two words, as the brand gate requires. That
  docstring line is the only byte of the generated launcher that
  changes.
- An owner-only docstring is reworded to satisfy the
  comment-history gate.
- Comments and docstrings that placed moved code in its old file,
  or "above" it, now name the owner.

New tests:
- Pin both generated programs byte for byte against the
  pre-split builders, over a pinned host and pinned tables.
- Pin the facade forwarding, the owner seams, the import
  direction and the loggers.
- Refuse any create=True patch of a forwarded name.

The owning specs (security.md, platform-compat.md) name the owners.
Entry-scoped grants cover:
- the platform-context.md owner citation;
- the test_identity_topology registry key;
- the darwin CI path filter;
- the AUTOSDE file patterns;
- the dogfood source-text guard, which now reads the ssh handling
  from the facade and both builder owners.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security facade: a re-exported name has two storage locations for its value AND its owner, and the halves cannot be converted separately

2 participants