Skip to content

refactor: split the single-file CLI behind a package facade + enforced size lint + retry re-invocations (L4#10 SB, L4#25 share) - #44

Merged
simongonzalezdc merged 1 commit into
mainfrom
feat/split-facade-l4-10
Oct 27, 2026
Merged

simongonzalezdc merged 1 commit into
mainfrom
feat/split-facade-l4-10

Conversation

@simongonzalezdc

@simongonzalezdc simongonzalezdc commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Closes the L4#10 ship-blocker (ranked gate #2) and the checkyourself share of L4#25 from the teknium-bar audit.

What changed

The 1-file dump is gone. tools/checkyourself.py (5,519 lines, 156 top-level defs+classes) is now the tools/checkyourself/ package:

  • 22 engine modules split by verb: constants, errors, models, util, config, challenge_config, challenge_run, scanning, detectors, scan, report, coverage, receipts, jsonlite, validation, scoring, planning, describe, output, project, cli, mcp — largest is 624 lines.
  • Re-export-only facade __init__.py (573 lines) exposing the complete original top-level surface (all 254 names, underscore helpers included).
  • 24-line compatibility launcher kept at tools/checkyourself.py so every documented invocation — python3 tools/checkyourself.py <verb>, the npm bin wrapper, CI smoke steps, and file-path module loaders (spec_from_file_location) — works verbatim.
  • The split was performed mechanically (AST statement spans moved verbatim, imports derived from free-name analysis), not retyped.

Enforced size discipline (kinocut standard):

  • ruff.toml: line-length 120 now enforced (E5 added to select); W added; ruff pinned to 0.16.5 in CI so runner and local agree.
  • CI lint step: ruff check tools tests + ruff format --check + python tools/lint_sizes.py.
  • tools/lint_sizes.py (stdlib-only): facade <= 600 lines, module <= 1,000 lines, function <= 250 lines, across all production Python.
  • mcp_tools was split into 11 per-tool builders and build_findings's env-file block extracted into a helper so the tree passes those gates.

Retry re-invocations on every user-facing error path (kinocut errors.py::retry_message pattern):

  • errors.py maps each verb/tool to a concrete MCP tools/call and CLI command.
  • CLI CliError: retry: line on stderr + retry key in the JSON error object; argparse usage errors append a retry line (CheckYourselfParser).
  • MCP: every mcp_error (-32700/-32600/-32602 x4/-32601) and tool-call error results carry the concrete re-invocation.

npm packaging ships tools/checkyourself/ alongside the launcher. The 1.8.0 release note is staged under Unreleased in CHANGELOG.md; npm publish has NOT been done (external publish act, CEO-gated).

Behavior receipts (all reproduced on this branch)

Check Result
Full suite before (main 51c05f8) 152 tests + 88 subtests, exit 0
Full suite after (this branch) 152 tests + 88 subtests, exit 0
MCP tools/list vs main byte-identical JSON, 11 tools, same names
npx handshake on registry 1.7.0 vs packed tarball of this branch identical 11 tool names
validate_public.py pass
Retry receipt (15 error paths exercised) every path carries a retry
import tools.checkyourself + path-loader parity all 254 original names present, zero type drift
Size gates facade 573 <= 600; max module 624 <= 1,000; max function <= 250

The 11-tool MCP surface names: describe, scan, coverage_emit, coverage_check, receipt_issue, score, backlog, next, diff, validate, schema.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

… lint + retry re-invocations (L4#10, L4#25)

- tools/checkyourself.py (5,519 lines, 156 top-level defs/classes) becomes the
  tools/checkyourself/ package: 22 engine modules split by verb + a
  re-export-only facade (__init__.py) + a 24-line compatibility launcher at
  tools/checkyourself.py so every documented invocation keeps working.
- Enforced size discipline: ruff.toml selects E5 (line-length 120 enforced),
  CI runs ruff check + format --check (ruff pinned 0.16.5) and the new
  tools/lint_sizes.py (facade <=600, module <=1,000, function <=250 lines).
- Retry re-invocations on every user-facing error path (kinocut
  errors.py::retry_message pattern): errors.py maps each verb to concrete
  MCP tools/call + CLI commands; CLI stderr/JSON, argparse usage errors, and
  all MCP JSON-RPC errors + tool error results carry them.
- npm files list ships tools/checkyourself/ alongside the launcher.
- 1.8.0 release note staged in CHANGELOG (Unreleased); npm publish NOT done.

Behavior receipts: suite 152 tests + 88 subtests green before and after;
MCP tools/list byte-identical (11 tools); npx-packed bin handshake serves the
same 11 tool names; validate_public green; every error path carries a retry.
@simongonzalezdc
simongonzalezdc merged commit 2822013 into main Oct 27, 2026
2 checks passed
@simongonzalezdc
simongonzalezdc deleted the feat/split-facade-l4-10 branch October 27, 2026 02:37
simongonzalezdc added a commit that referenced this pull request Oct 27, 2026
…3/25) (#45)

Follow-up to #44 (L4#10 split). The Unreleased 1.8.0 entry cited
mid-iteration numbers: facade 404 lines / 24-line launcher. Merged
reality at 2822013 is facade `__init__.py` = 573 lines, launcher = 25
lines (wc -l). Docs-truth only — no code change. Verified: ruff check
rc=0, validate_public rc=0, full suite 152 tests + 88 subtests green.

<!-- codesmith:footer -->
---
<a
href="https://app.blacksmith.sh/KyaniteLabs/codesmith/checkyourself/pr/45?autoLogin=true&ref=codesmith_pr_footer"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v3.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-light-v3.svg"><img
alt="View with [code]smith"
src="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v3-3x.png"
width="162" height="28"></picture></a> <a
href="https://backend.blacksmith.sh/track/enable-autofix?expires=1795661627&installation_model_id=20207&pr_number=45&ref=codesmith_pr_footer&repository=KyaniteLabs%2Fcheckyourself&return_to=https%3A%2F%2Fgithub.com%2FKyaniteLabs%2Fcheckyourself%2Fpull%2F45&signature=c8fd23cb2d7bb279c7121bdd9410fd465a73a598299e3c23ddf1304a7488ce70"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img
alt="Autofix with [code]smith"
src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png"
width="190" height="28"></picture></a>
<sup>Need help on this PR? Tag <code>@codesmith-bot</code> with what you
need.</sup>

<!-- codesmith:autofix:disabled -->
<!-- /codesmith:footer -->
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.

1 participant