Skip to content

#109 feat: name pre-ship's import targets in .skills/import-targets - #123

Merged
gregoryfoster merged 8 commits into
mainfrom
109-import-targets
Nov 16, 2026
Merged

gregoryfoster merged 8 commits into
mainfrom
109-import-targets

Conversation

@gregoryfoster

@gregoryfoster gregoryfoster commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Closes #109

What

.skills/import-targets, the knob shipping-work's pre-ship.sh reads for its import check. Until now pre-ship guessed co_status from the [project] name, found no such package and skipped the check on every run.

The target set, and why

Every module a unit's launcher hands to Python, and nothing else:

Target Launched by
src.api.main serve.sh, dev_server.sh (uvicorn src.api.main:app)
src.core.db_safety dev_server.sh, sweep.sh (python -m)
src.core.schema_state dev_server.sh (python -m)
scripts.sweep_monitors sweep.sh (python scripts/sweep_monitors.py)
scripts.check_drift drift.sh (python scripts/check_drift.py)

The brief suggested src.api.main, src.core.sweep, src.core.drift. Measured in a bare environment, both sets import the same src modules (everything but src.core.importer and src.core.tenants, which no unit runs). The difference is the scripts' own imports. Break one name check_drift.py imports from src.core.drift and import src.core.drift still passes, but the drift unit dies on start. With the scripts as targets, the test fails on that edit (mutation 1 below). db_safety and schema_state are already inside src.api.main's closure. They're listed anyway so the rule stays mechanical: the test can derive the whole set from the launchers.

Test: tests/ci/test_import_targets.py

  • the knob is a regular file and has at least one target, parsed with detect-import-targets.sh's grammar;
  • its set equals what the units launch: every Exec*= line in deploy/*.service (arguments allowed), each scripts/*.sh one starts, and each script those name in turn (tailnet_bind.sh), read for uvicorn M:app, python[3[.x]] -m M and python scripts/X.py, every occurrence on a line. Any other non-comment python/uvicorn line fails the test, so a new invocation form can't slip past the parser. A mismatch names what to add and drop;
  • each target imports in a fresh interpreter, cwd at the repo root, env={"PATH": "/usr/bin:/bin"}, i.e. no DATABASE_URL or TEST_DATABASE_URL.

Red first: 3 failed with no file, then 3 passed. Mutations, each restored afterwards:

Mutation Result
1. check_drift.py imports a name src.core.drift lacks import test fails
2. a target dropped from the knob set test fails
3. drift.sh gains python -m src.core.importer set test fails
4. knob removed all 3 fail
5. src/core/build.py reads DATABASE_URL at import import test fails

Review (CR, applied)

Six findings, all in the pin's parser, one commit each: every Exec*= line read, arguments too (1); python3/python3.12 (2); every invocation on a line (3); helpers a launcher runs (4); all four launchers held (5); a mismatch says what to change (6). Each has a synthetic-input test that failed first, except 5 and 6, which were checked by breaking a unit file and the knob on purpose.

pre-ship.sh from the worktree (rc 0)

pre-ship prints its === Import check === header only when it skips. When it runs, each target gets its own section, and a section with nothing under it passed:

Detected: toolchain uv, framework fastapi
gate-workers: auto: 2 core(s), so serial

=== Lint (ruff) ===
All checks passed!

=== Format check (ruff) ===
118 files already formatted

=== Import src.api.main ===

=== Import src.core.db_safety ===

=== Import src.core.schema_state ===

=== Import scripts.sweep_monitors ===

=== Import scripts.check_drift ===

=== Tests (pytest) ===
...
================= 1920 passed, 6 skipped in 171.92s (0:02:51) ==================

Pre-ship checks passed.

No "Skipping" anywhere in the log.

Deploy

None needed: drift.counts() ignores .skills/ and tests/.

🤖 Generated with Claude Code

gregoryfoster and others added 8 commits November 16, 2026 21:43
pre-ship.sh guessed `co_status` from the [project] name, found no such
package and skipped its import check on every run. The knob names every
module a unit's launcher hands to Python: src.api.main, src.core.db_safety,
src.core.schema_state, scripts.sweep_monitors, scripts.check_drift.

tests/ci/test_import_targets.py holds the file, pins its set to what
deploy/*.service's launchers run, and imports each target in a fresh
interpreter with a scrubbed environment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gregoryfoster
gregoryfoster merged commit f44ea87 into main Nov 16, 2026
3 checks passed
@gregoryfoster
gregoryfoster deleted the 109-import-targets branch November 16, 2026 22:30
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.

.skills/import-targets: pre-ship's import check has never run here

1 participant