Skip to content

feat: Milestone 0 — project foundation and package skeleton (v0.1.0)#3

Merged
shaypal5 merged 4 commits intomainfrom
feat/milestone-0-foundation
Apr 18, 2026
Merged

feat: Milestone 0 — project foundation and package skeleton (v0.1.0)#3
shaypal5 merged 4 commits intomainfrom
feat/milestone-0-foundation

Conversation

@shaypal5
Copy link
Copy Markdown
Contributor

Summary

Bootstraps the leadforge codebase from empty to a fully installable, lint-clean, tested package skeleton. This is the complete Milestone 0 delivery.

All acceptance criteria pass:

  • pip install -e .
  • leadforge --help shows all four commands ✓
  • leadforge list-recipes returns b2b_saas_procurement_v1
  • 20 tests passing ✓
  • ruff + mypy clean ✓
  • CI configured ✓

What's included

Package scaffold

  • pyproject.toml — setuptools build, Typer + PyYAML runtime, ruff/mypy/pytest dev deps, leadforge CLI entry point
  • Full subpackage skeleton (api, cli, core, narrative, schema, structure, mechanisms, simulation, render, exposure, validation, recipes) with __init__.py stubs
  • README.md — install, CLI quickstart, Python API snippet, doc links
  • .pre-commit-config.yaml — ruff (lint + format) + pre-commit-hooks

Core primitives (leadforge/core/)

  • enums.pyExposureMode + DifficultyProfile as StrEnum
  • exceptions.pyLeadforgeError base + 6 typed subclasses
  • models.pyGenerationConfig, WorldSpec, WorldBundle dataclass stubs
  • rng.py, ids.py — documented stubs (implemented in M1)

Recipe system (leadforge/recipes/)

  • registry.pylist_recipes() + load_recipe() reading YAML files
  • b2b_saas_procurement_v1/recipe.yaml — id, title, primary task, modes, difficulty levels

CLI (leadforge/cli/)

  • main.py — Typer app with --version and four registered commands
  • list-recipes — fully implemented with Rich table output
  • generate — stub with full option spec per architecture doc; exits 1 with "coming in v0.2.0"
  • inspect, validate — stubs with correct argument spec

CI (.github/workflows/ci.yml)

  • Three jobs: lint (ruff check + format), typecheck (mypy), test matrix (Python 3.11 + 3.12)
  • Coverage artifacts uploaded under pr-agent-context-coverage-py* prefix for pr-agent-context integration

Tests (20 passing)

  • tests/test_cli.py — help, version, list-recipes content, stub exit codes
  • tests/core/test_enums.py — values + string construction
  • tests/core/test_exceptions.py — hierarchy + message preservation
  • tests/recipes/test_registry.py — list/load, required fields, error case

Test plan

  • CI passes (lint, typecheck, test matrix)
  • leadforge --help shows all four commands
  • leadforge list-recipes shows b2b_saas_procurement_v1
  • leadforge --version prints leadforge 0.1.0

🤖 Generated with Claude Code

Bootstraps the leadforge codebase from empty to a fully installable,
testable, lint-clean package skeleton. All Milestone 0 acceptance
criteria pass: `pip install -e .` works, `leadforge --help` shows all
four commands, `leadforge list-recipes` returns the v1 recipe, and CI
is configured.

Package scaffold
- pyproject.toml: setuptools build, Typer+PyYAML runtime deps, ruff/mypy/
  pytest dev deps, `leadforge` CLI entry point
- Full subpackage skeleton with __init__.py stubs for every module in the
  canonical layout (api, cli, core, narrative, schema, structure,
  mechanisms, simulation, render, exposure, validation, recipes)
- leadforge/version.py: __version__ = "0.1.0"
- README.md: install, quickstart, API snippet, doc links
- .pre-commit-config.yaml: ruff (lint+format) + pre-commit-hooks

Core primitives (leadforge/core/)
- enums.py: ExposureMode (StrEnum), DifficultyProfile (StrEnum)
- exceptions.py: LeadforgeError base + 6 typed subclasses
- models.py: GenerationConfig, WorldSpec, WorldBundle dataclass stubs
- rng.py, ids.py: documented stubs for Milestone 1

Recipe system (leadforge/recipes/)
- registry.py: list_recipes() + load_recipe() reading from YAML files
- b2b_saas_procurement_v1/recipe.yaml: id, title, primary_task,
  supported_modes, supported_difficulty, default_population

CLI (leadforge/cli/)
- main.py: Typer app with --version flag and four registered commands
- commands/list_recipes.py: fully implemented with Rich table output
- commands/generate.py: stub with full option spec (--recipe, --seed,
  --mode, --out, --difficulty, --n-accounts, --n-contacts, --n-leads,
  --horizon-days, --override); exits 1 with "coming in v0.2.0"
- commands/inspect.py, validate.py: stubs with correct argument spec

CI (.github/workflows/ci.yml)
- Three jobs: lint (ruff check+format), typecheck (mypy), test matrix
  (Python 3.11 + 3.12 with pytest-cov + coverage artifact upload for
  pr-agent-context integration)

Tests (20 passing)
- tests/test_cli.py: help, version, list-recipes output, stub exit codes
- tests/core/test_enums.py: values and string construction
- tests/core/test_exceptions.py: hierarchy and message preservation
- tests/recipes/test_registry.py: list/load, required fields, error case

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@shaypal5 shaypal5 added type: feature New capability layer: core core/ primitives (RNG, IDs, models, exceptions) layer: cli cli/ command-line interface layer: recipes recipes/ recipe assets and registry labels Apr 18, 2026
Copilot AI review requested due to automatic review settings April 18, 2026 08:34
@shaypal5 shaypal5 added type: feature New capability layer: core core/ primitives (RNG, IDs, models, exceptions) layer: cli cli/ command-line interface layer: recipes recipes/ recipe assets and registry labels Apr 18, 2026
@github-actions

This comment has been minimized.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Bootstraps the leadforge repository into an installable Python package with a Typer-based CLI, an initial YAML-backed recipe registry, CI/tooling configuration, and a baseline test suite to support future milestones.

Changes:

  • Added project packaging/tooling (pyproject.toml, pre-commit, CI) and a full package/module skeleton.
  • Implemented a first working CLI command (list-recipes) plus stubs for generate, inspect, validate.
  • Added a YAML recipe registry + an initial b2b_saas_procurement_v1 recipe and accompanying tests.

Reviewed changes

Copilot reviewed 23 out of 44 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/test_cli.py CLI smoke tests for help/version and command stubs
tests/recipes/test_registry.py Tests for recipe listing/loading and error case
tests/recipes/init.py Test package marker
tests/core/test_exceptions.py Exception hierarchy tests
tests/core/test_enums.py Enum value/from-string tests
tests/core/init.py Test package marker
tests/init.py Test package marker
pyproject.toml Packaging metadata, deps, ruff/mypy/pytest configuration
leadforge/version.py Defines __version__
leadforge/validation/init.py Subpackage stub
leadforge/structure/init.py Subpackage stub
leadforge/simulation/init.py Subpackage stub
leadforge/schema/init.py Subpackage stub
leadforge/sample_data/public/.gitkeep Placeholder for sample data
leadforge/sample_data/instructor/.gitkeep Placeholder for sample data
leadforge/render/init.py Subpackage stub
leadforge/recipes/registry.py Implements recipe discovery/loading from YAML
leadforge/recipes/b2b_saas_procurement_v1/recipe.yaml Adds initial recipe metadata YAML
leadforge/recipes/b2b_saas_procurement_v1/init.py Subpackage stub
leadforge/recipes/init.py Subpackage stub
leadforge/narrative/init.py Subpackage stub
leadforge/mechanisms/init.py Subpackage stub
leadforge/exposure/init.py Subpackage stub
leadforge/examples/notebooks/.gitkeep Placeholder for examples
leadforge/examples/configs/.gitkeep Placeholder for examples
leadforge/core/rng.py RNG utilities stub docstring
leadforge/core/models.py Dataclass stubs for config/spec/bundle
leadforge/core/ids.py ID scheme stub docstring
leadforge/core/exceptions.py Defines project exception hierarchy
leadforge/core/enums.py Defines ExposureMode / DifficultyProfile
leadforge/core/init.py Core subpackage stub
leadforge/cli/main.py Typer app entrypoint + command registration
leadforge/cli/commands/validate.py validate command stub
leadforge/cli/commands/list_recipes.py list-recipes command implementation (Rich table)
leadforge/cli/commands/inspect.py inspect command stub
leadforge/cli/commands/generate.py generate command stub + option surface
leadforge/cli/commands/init.py Commands subpackage stub
leadforge/cli/init.py CLI subpackage stub
leadforge/api/init.py API subpackage stub
leadforge/init.py Package init exporting __version__
README.md Project README with install/quickstart/docs links
.pre-commit-config.yaml Pre-commit hooks (ruff, formatting, basic checks)
.github/workflows/ci.yml CI for lint/typecheck/tests with coverage artifacts
.agent-plan.md Updates project plan to mark M0 complete / M1 next

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md
Comment thread leadforge/recipes/registry.py Outdated
Comment thread leadforge/recipes/registry.py Outdated
Comment thread leadforge/recipes/registry.py Outdated
Comment thread README.md Outdated
@github-actions

This comment has been minimized.

@shaypal5 shaypal5 self-assigned this Apr 18, 2026
COPILOT-1 — Add Generator stub to leadforge/api
- leadforge/api/generator.py: Generator class with from_recipe() and
  generate() raising NotImplementedError with "coming in v0.2.0" messages
- leadforge/api/__init__.py: export Generator so `from leadforge.api
  import Generator` resolves correctly

COPILOT-2 — Sort list_recipes() by recipe id field, not path
- return sorted(recipes, key=lambda r: r["id"]) instead of relying on
  filesystem iteration order

COPILOT-3 — Validate yaml.safe_load() result in registry
- Extract _parse_and_validate() helper; raises InvalidRecipeError if the
  parsed value is not a dict or is missing the required 'id' key; used
  by both list_recipes() and load_recipe()

COPILOT-4 — Guard load_recipe() against path traversal
- Resolve the candidate path and verify it stays within _RECIPES_DIR
  before checking existence or opening; raises InvalidRecipeError for
  any recipe_id that would escape the recipes directory

COPILOT-5 — Comment out unimplemented CLI commands in README
- Quickstart now shows generate/inspect/validate as commented-out
  examples with "Coming in v0.x.0" labels; only `list-recipes` is shown
  as immediately runnable
- Python API snippet annotated with "(coming in v0.2.0)"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

This comment has been minimized.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 25 out of 45 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread leadforge/recipes/registry.py Outdated
Comment thread pyproject.toml Outdated
…mits

Documents the mandatory step of resolving GitHub review threads via
GraphQL after addressing PR comments, so the omission from PR #3
does not recur.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

This comment has been minimized.

- registry.py: replace string-prefix path traversal guard with
  Path.is_relative_to() (Python 3.11+), closing the prefix-collision
  bypass (e.g. recipes_evil alongside recipes)
- pyproject.toml: add "S" (bandit) ruleset to ruff select so security
  checks are active on non-test code; widen per-file-ignores glob from
  tests/* to tests/**/* to cover subdirectories; add S108 to test
  ignores to suppress the /tmp false-positive in test CLI invocations

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 18, 2026 14:07
@github-actions
Copy link
Copy Markdown

pr-agent-context report:

This run includes unresolved review comments on PR #3.

For each unresolved review comment, recommend one of: resolve as irrelevant, accept and implement
the recommended solution, open a separate issue and resolve as out-of-scope for this PR, accept and
implement a different solution, or resolve as already treated by the code.

After I reply with my decision per item, implement the accepted actions, resolve the corresponding
PR comments, and push all of these changes in a single commit.

# Copilot Comments

## COPILOT-1
Location: leadforge/recipes/registry.py
URL: https://github.com/leadforge-dev/leadforge/pull/3#discussion_r3105050071
Status: outdated
Root author: copilot-pull-request-reviewer

Comment:
    The path traversal guard is bypassable because it uses a string prefix check. For example, a resolved path like `/.../recipes_evil` will still start with `/.../recipes`, so `recipe_id='../recipes_evil'` can incorrectly pass this check. Use `Path.is_relative_to()` (Py3.11+) or `recipe_dir.relative_to(base_dir)` in a try/except to ensure the resolved path is actually within `_RECIPES_DIR`.
    ~~~suggestion
        base_dir = _RECIPES_DIR.resolve()
        recipe_dir = (base_dir / recipe_id).resolve()
        try:
            recipe_dir.relative_to(base_dir)
        except ValueError:
    ~~~

## COPILOT-2
Location: pyproject.toml
URL: https://github.com/leadforge-dev/leadforge/pull/3#discussion_r3105050075
Status: outdated
Root author: copilot-pull-request-reviewer

Comment:
    The Ruff per-file-ignores glob `tests/*` only matches files directly under `tests/` and won’t apply to tests in subdirectories like `tests/core/...` or `tests/recipes/...`. If the intent is to ignore rules across the whole test tree, use `tests/**` (or similar). Also, `S101` is currently a no-op unless the `S` ruleset is enabled in `select`.

Run metadata:

Tool ref: v4
Tool version: 4.0.18
Trigger: commit pushed
Workflow run: 24606387604 attempt 1
Comment timestamp: 2026-04-18T14:07:41.401806+00:00
PR head commit: ac22ad52c0c25ff581cb8af14d2a97de9b664c63

@shaypal5 shaypal5 merged commit da98878 into main Apr 18, 2026
9 checks passed
@shaypal5 shaypal5 deleted the feat/milestone-0-foundation branch April 18, 2026 14:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 26 out of 46 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread leadforge/recipes/registry.py
Comment thread tests/test_cli.py
Comment thread tests/test_cli.py
shaypal5 added a commit that referenced this pull request May 1, 2026
Review feedback addressed:

- Remove primary_task/label_window_days as explicit kwargs from
  resolve_config() and Generator.from_recipe() — these fields are
  resolved from recipe YAML and override dict only, not casually
  overridable, since the generation pipeline doesn't yet support
  arbitrary task types (Copilot-1, Copilot-3, shaypal5 #1, #2)
- Add label_window_days <= horizon_days validation in
  GenerationConfig.__post_init__ (Copilot-2, shaypal5 #3)
- Add tests for invalid primary_task on GenerationConfig: empty
  string, non-string type (shaypal5 #6, pr-agent-context)
- Add tests for invalid label_window_days on Recipe.from_dict: bool,
  non-positive, float (shaypal5 #7, pr-agent-context)
- Add test for label_window_days > horizon_days rejection
- Fix existing test using horizon_days=30 (now conflicts with default
  label_window_days=90)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
shaypal5 added a commit that referenced this pull request May 1, 2026
* feat: carry primary_task and label_window_days into WorldSpec for dataset card

Add `primary_task` and `label_window_days` fields to `GenerationConfig`
(with defaults preserving current behavior). Propagate through
`Recipe.from_dict()`, `resolve_config()`, and `Generator.from_recipe()`
so recipe YAML can override them. Update `render_dataset_card()` to read
from `world_spec.config` instead of hard-coded string literals.

Closes #6

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: update .agent-plan.md for WorldSpec task fields (PR #36)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: address review feedback — tighten scope, add validation + tests

Review feedback addressed:

- Remove primary_task/label_window_days as explicit kwargs from
  resolve_config() and Generator.from_recipe() — these fields are
  resolved from recipe YAML and override dict only, not casually
  overridable, since the generation pipeline doesn't yet support
  arbitrary task types (Copilot-1, Copilot-3, shaypal5 #1, #2)
- Add label_window_days <= horizon_days validation in
  GenerationConfig.__post_init__ (Copilot-2, shaypal5 #3)
- Add tests for invalid primary_task on GenerationConfig: empty
  string, non-string type (shaypal5 #6, pr-agent-context)
- Add tests for invalid label_window_days on Recipe.from_dict: bool,
  non-positive, float (shaypal5 #7, pr-agent-context)
- Add test for label_window_days > horizon_days rejection
- Fix existing test using horizon_days=30 (now conflicts with default
  label_window_days=90)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

layer: cli cli/ command-line interface layer: core core/ primitives (RNG, IDs, models, exceptions) layer: recipes recipes/ recipe assets and registry type: feature New capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants