Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/c6-cluster-coefficients-numerics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: C6 cluster coefficient numerics (replay)
'on':
pull_request:
paths:
- 'tools/**'
- 'tests/test_direct_replay_import_triggers.py'
- 'frontiers/c6_cluster_coefficients_numerics_20260930/**'
- '.github/workflows/c6-cluster-coefficients-numerics.yml'
- 'tools/c6_coefficient_numerics_replay.py'
Expand All @@ -23,6 +25,10 @@ jobs:
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97
with:
python-version: '3.11.16'
- name: Check direct-helper import trigger coverage
run: |
python -B -S tests/test_direct_replay_import_triggers.py
python -B -O -S tests/test_direct_replay_import_triggers.py
- name: Verify full-shell output contracts in both Python modes
env:
PYTHONDONTWRITEBYTECODE: '1'
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/remainder-rate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Remainder rate exact controls
'on':
pull_request:
paths:
- 'tools/**'
- 'tests/test_direct_replay_import_triggers.py'
- 'frontiers/remainder_rate_20260930/**'
- '.github/workflows/remainder-rate.yml'
- 'tools/remainder_rate_replay.py'
Expand Down Expand Up @@ -33,6 +35,10 @@ jobs:
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97
with:
python-version: '3.11.16'
- name: Check direct-helper import trigger coverage
run: |
python -B -S tests/test_direct_replay_import_triggers.py
python -B -O -S tests/test_direct_replay_import_triggers.py
- name: Exercise full-shell rejection contracts in both modes
env:
PYTHONDONTWRITEBYTECODE: '1'
Expand Down
86 changes: 86 additions & 0 deletions reviews/direct_import_trigger_coverage_20261006/SCOPE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Direct-helper package-shadow trigger coverage

Dylan Roy — delegated AI engineering. Actual author OpenAI / GPT-6 Astra Pro,
`qs-direct-import-trigger-20261006-r7`, pickup Math-#322/6015484094.
Scientific effect NONE; source-exposed; organizational-independence credit 0.
Author replay is not nonauthor review. No author self-merge.

## Source and mechanism

Authenticated source cut: `11f9127f00ce922e5d39b0da42af76134eb78a21`.
Original complete workflows:

| Workflow | Bytes | Git blob |
|---|---:|---|
| c6-cluster-coefficients-numerics.yml | 3089 | e4f49dcb48350d2f1546a7d7d2108c112e9498f3 |
| remainder-rate.yml | 5354 | 3ee30582e1e3fd3c2ad997cf68cc9ed121d4c514 |

Both workflows prepend the repository's `tools` directory to `sys.path`, then
import a bare module. A same-name package containing `__init__.py` is selected
instead of the helper `.py` file. The two named paths are
`tools/c6_coefficient_numerics_replay/__init__.py` and
`tools/remainder_rate_replay/__init__.py`; neither matched the old filters.
This is a future-change coverage gap, not an allegation that such shadow
packages are presently committed or that a numerical output was incorrect.

This differs from #351/#361's `from tools...` package import: here a root
`tools.py` or `tools/__init__.py` alone does not affect the bare helper import.
The real probes retain those negative cases. No #361 source/review is reused
as approval of this new four-file change; its source stays frozen separately.

## Minimal change and preservation

Each workflow adds `tools/**` and this new regression file's trigger, then a
separate step invoking the complete regression normally and under `-O`.
The latter step precedes the original full-shell output-contract suite.
Removing exactly those two path lines and the four-line step recovers each
entire original workflow byte for byte. Existing imports and all original
run blocks, source preflights, historical dependency/API checks, final Git
checks, permissions, action/Python pins and job budgets are unchanged.
No helper, output contract, old test, proof, RESULTS, manifest, scientific
status, formal package, dependency or peer branch is changed.

## Actual local verification

Linux, CPython 3.13.5, selected authenticated source files only. Full GitHub
clone failed DNS resolution. No full local repository, authentic numerical
packet replay, blob-API fallback or local Lean compilation is claimed.

The new six-method suite against the original workflows failed first in
exactly ten intended subcases per outer mode: four shadow-path cases,
two self-trigger cases and four mode-wiring cases; zero harness errors.
The same suite then passed 6/6 normally and 6/6 optimized. Its real-import
method runs twenty actual Python children per suite: two helpers, two child
modes and five variants (module, regular shadow package, namespace directory,
unrelated tools initializer, root tools module). It extracts the exact two
import-setup lines from the current workflows; only the helper bodies and
filesystem are synthetic. Package execution is witnessed by a real marker.
No import/subprocess mock, network, real signer or scientific child is used.

Three isolated removal variants reject in both modes with exactly 4/2/2
assertion failures and zero errors: tools subtree coverage, self-trigger,
optimized invocation. Original RED and all later outputs are retained in the
owner evidence, not overwritten. Both complete YAML documents parsed and all
run blocks passed `bash -n`; PyYAML was used only for this local syntax check,
not added to the repository or required by the committed stdlib tests.

## Boundaries and release

The test's reader intentionally supports only the current flat positive list,
literal paths and a terminal `/**`; other syntax fails visibly. It is not a
replacement for a YAML parser or GitHub's scheduler. Normal GitHub changed-file
limits, branch filters and commit-skip behavior remain external boundaries.
No hosted changed-path-only scheduling experiment was performed locally.
Broad `tools/**` deliberately causes more dedicated runs. This does not
prevent an authorized source change, sandbox imports, cover every root
standard-library shadow/import hook, or establish mathematical acceptance.

Actual dedicated and applicable general CI, one nonauthor delta review, and a
separate eligible integrator's then-current source/check/ownership review and
expected-head merge remain required. No old candidate receipt transfers to a
new main. #316/#359 integration and #361/#363/C7 repairs retain their scopes.

Primary background consulted 6 October 2026: Python 3.13 Modules documentation,
https://docs.python.org/3.13/tutorial/modules.html ; GitHub workflow path filters,
https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax .
The observed package precedence is also established by the recorded real probes.
138 changes: 138 additions & 0 deletions tests/test_direct_replay_import_triggers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
"""Two bare-helper import trigger contracts; stdlib-only, synthetic import probes.

This checks the deliberately restricted current YAML layout, not GitHub's
scheduler. No scientific checker is executed by the synthetic import probes.
"""
import json
from pathlib import Path
import re
import subprocess
import sys
import tempfile
import unittest

ROOT = Path(__file__).resolve().parents[1]
SELF = 'tests/test_direct_replay_import_triggers.py'
SPECS = (
('c6-cluster-coefficients-numerics.yml', 'c6_coefficient_numerics_replay',
'frontiers/c6_cluster_coefficients_numerics_20260930/**',
'tests/test_c6_coefficient_numerics_workflow.py'),
('remainder-rate.yml', 'remainder_rate_replay',
'frontiers/remainder_rate_20260930/**', 'tests/test_remainder_rate_workflow.py'),
)


def positive_paths(text):
"""Only this flat positive list, with literal paths or terminal /**."""
prefix = ' pull_request:\n paths:\n'
if text.count(prefix) != 1:
raise ValueError('expected one pull-request path list')
tail = text.split(prefix, 1)[1]
if ' workflow_dispatch:\n' not in tail:
raise ValueError('missing path-list boundary')
block = tail.split(' workflow_dispatch:\n', 1)[0]
paths = []
for line in block.splitlines():
if not line.strip() or line.lstrip().startswith('#'):
continue
match = re.fullmatch(r" - '([A-Za-z0-9_./-]+(?:/\*\*)?)'", line)
if not match:
raise ValueError('unsupported path-list syntax')
path = match.group(1)
literal = path[:-3] if path.endswith('/**') else path
if any(part in ('', '.', '..') for part in literal.split('/')):
raise ValueError('noncanonical path')
paths.append(path)
if not paths or len(paths) != len(set(paths)):
raise ValueError('empty or duplicate path list')
return paths


def covered(paths, changed):
return any(changed.startswith(p[:-2]) if p.endswith('/**') else changed == p
for p in paths)


def source(name):
return (ROOT / '.github/workflows' / name).read_text()


class DirectReplayImportTriggers(unittest.TestCase):
def test_same_name_package_and_descendants_trigger(self):
for name, module, _, _ in SPECS:
paths = positive_paths(source(name))
for relative in ('__init__.py', 'nested/data.py'):
with self.subTest(workflow=name, relative=relative):
self.assertTrue(covered(paths, 'tools/' + module + '/' + relative))

def test_regression_file_triggers_both_workflows(self):
for name, *_ in SPECS:
with self.subTest(workflow=name):
self.assertTrue(covered(positive_paths(source(name)), SELF))

def test_both_modes_are_wired_before_existing_contract_suite(self):
for name, _, _, old_test in SPECS:
text = source(name)
for flags in ('-B -S', '-B -O -S'):
command = ' python ' + flags + ' ' + SELF + '\n'
with self.subTest(workflow=name, flags=flags):
self.assertEqual(text.count(command), 1)
self.assertLess(text.index(command), text.index(' -p ' + Path(old_test).name))

def test_original_paths_and_unrelated_negatives(self):
for name, module, packet, old_test in SPECS:
paths = positive_paths(source(name))
for expected in (packet, '.github/workflows/' + name, 'tools/' + module + '.py', old_test):
with self.subTest(workflow=name, preserved=expected):
self.assertIn(expected, paths)
for unrelated in ('tools.py', 'docs/README.md', 'other/tools/' + module + '/__init__.py'):
with self.subTest(workflow=name, unrelated=unrelated):
self.assertFalse(covered(paths, unrelated))

def test_list_reader_rejects_unsupported_syntax(self):
template = " pull_request:\n paths:\n%s\n workflow_dispatch:\n"
for row in (" - '!tools/**'", " - 'tools/*.py'", " - '../escape'",
" - '/tools/file.py'", " - 'tools/**' # suffix",
" - 'tools/**'\n - 'tools/**'", ' paths-ignore: []'):
with self.subTest(row=row), self.assertRaises(ValueError):
positive_paths(template % row)
self.assertEqual(positive_paths(template % " # note\n - 'tools/**'"), ['tools/**'])

def test_real_bare_import_selects_shadow_package_not_tools_package(self):
for name, module, _, _ in SPECS:
text = source(name)
lines = text.splitlines()
start = " sys.path.insert(0, str(pathlib.Path('tools').resolve()))"
self.assertEqual(lines.count(start), 1)
index = lines.index(start)
self.assertEqual(lines[index + 1], ' from ' + module + ' import replay')
snippet = '\n'.join(line[10:] for line in lines[index:index + 2])
for optimized in (False, True):
for variant in ('module', 'shadow-package', 'namespace-directory', 'tools-init', 'root-tools'):
with self.subTest(workflow=name, optimized=optimized, variant=variant):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory); tools = root / 'tools'; tools.mkdir()
module_body = "def replay():\n return 'MODULE'\n"
(tools / (module + '.py')).write_text(module_body)
if variant in ('shadow-package', 'namespace-directory'):
(tools / module).mkdir()
if variant == 'shadow-package':
(tools / module / '__init__.py').write_text(
"from pathlib import Path\nPath('package.marker').write_text('loaded')\n"
"def replay():\n return 'PACKAGE'\n")
if variant == 'tools-init':
(tools / '__init__.py').write_text("raise RuntimeError('tools initializer executed')\n")
if variant == 'root-tools':
(root / 'tools.py').write_text("raise RuntimeError('root tools executed')\n")
code = 'import pathlib, sys\n' + snippet + '\nprint(replay())\n'
argv = [sys.executable, '-B'] + (['-O'] if optimized else []) + ['-S', '-c', code]
result = subprocess.run(argv, cwd=root, capture_output=True, timeout=10)
self.assertEqual(result.returncode, 0, repr(result.stderr))
self.assertEqual(result.stderr, b'')
self.assertEqual(result.stdout, b'PACKAGE\n' if variant == 'shadow-package' else b'MODULE\n')
self.assertEqual((root / 'package.marker').exists(), variant == 'shadow-package')
self.assertEqual((tools / (module + '.py')).read_text(), module_body)


if __name__ == '__main__':
unittest.main()
Loading