Skip to content

fix: validate fork boundary indices before output creation - #306

Draft
panshularora wants to merge 1 commit into
AOSSIE-Org:mainfrom
panshularora:fix/fork-boundary-validation
Draft

panshularora wants to merge 1 commit into
AOSSIE-Org:mainfrom
panshularora:fix/fork-boundary-validation

Conversation

@panshularora

Copy link
Copy Markdown
Contributor

Summary

Closes #304.

Reject fork --at values outside 0 <= K < len(chain) immediately after reading the source chain, before indexing, reading prepared documents, or creating output. The error includes the valid range.

Valid boundary handling, checkpoints, source chain prefixes and exclusion rules are unchanged. Document the argument contract in simple/README.md.

Verification

  • Test-first: negative, chain-length and oversized inputs failed on unchanged upstream with raw IndexError/FileNotFoundError; after the guard they reject cleanly and leave no output.
  • Full Python 3.12 CPU suite: 73 passed, 9 subtests passed.
  • ruff check simple tests and git diff --check: passed.
  • Existing CLI reproduction rerun: valid index succeeds; negative/chain-length inputs reject without partial output.
  • Tests cover both first/last eligible boundaries, exact prefix/checkpoint preservation, and existing non-Wikipedia/already-forked rejection.

Limits / review focus

Synthetic CPU chain/checkpoint fixtures, not published trained weights or RTX 5090 replay. This fixes invalid argument handling, not atomic cleanup for other failures (e.g. a missing checkpoint at a valid index). No digest, RNG, optimizer, recipe or training arithmetic changes.

@coderabbitai

coderabbitai Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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.

[BUG] fork --at accepts negative indices and leaves a partial output directory

1 participant