Skip to content

feat(twin): require the base-artifact type at the repository's own constructor - #56

Open
nilsonfh wants to merge 1 commit into
mainfrom
fix/type-the-workflow-base-dirs
Open

nilsonfh wants to merge 1 commit into
mainfrom
fix/type-the-workflow-base-dirs

Conversation

@nilsonfh

@nilsonfh nilsonfh commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Summary

The next phase of bd 6ns.1: NetworkModelRepository.from_parquet now requires BaseArtifactDir.

#54 typed the producer (ArtifactLayout.base), the repository field, the readers and the argparse boundaries, but its own commit message said plainly what it did not cover: from_parquet still accepted any path-like, so from_parquet(script.root) type-checked — at the constructor most callers use, and exactly the swap bd 7rt made. This closes it.

Why it waited

Narrowing alone raised the gridalyn ratchet 116 → 119 when measured during #54, because three workflow functions declared base_dir: Path and passed it straight in. So they come first:

  • generate_ev_scenarios, generate_flexibility_provider_artifacts, generate_semantic_graph now take BaseArtifactDir.
  • generate_semantic_graph re-wraps after base_dir.resolve(), which returns a plain Path.
  • from_parquet's body still passes the value through Path(), so a caller holding a str or a Path keeps working at run time; only what mypy accepts changes.
  • All three functions gained the docstring they never had, documenting every parameter, base_dir included — the condition agreed with the twin's owner for anything this work annotates.

Verification

  • Simulated first on a throwaway worktree of main, mypy A/B per (file, message): 0 new errors in all three targets. A positive control confirmed a plain Path into from_parquet is now rejected, so mypy was reading the patched tree.
  • On this branch: pinned black/isort/flake8 clean; touched modules import at run time; ratchets 116 / 846 / 12, identical to main; 57 targeted tests pass; full suite 2260 passed / 0 failed.

What is still untyped, stated rather than implied

  • argparse hands these scripts an Any, so the boundary is held by the type= converters added in feat(foundation): type the canonical base-artifact directory of an instance #54, not by these signatures. Measured on this branch, the value still arrives at from_parquet unchecked at generate_digital_twin_dashboard_catalog.py:104 (args.base_dir) and at tools/r7_twin_consumer_identity.py:167 (tools/ carries no ratchet).
  • Tests pass bare Paths at 46 call sites (counted, not estimated). No ratchet type-checks tests, and run time still accepts them, because the body converts.
  • So "typed" here means typed where mypy looks. The claim is kept the size of the evidence (raised in review).

🤖 Generated with Claude Code

…nstructor

Closes the gap the previous phase named rather than implied away (bd 6ns.1).
39df523 typed the layout, the repository field, the readers and the argparse
boundaries, but NetworkModelRepository.from_parquet still accepted any
path-like, so `from_parquet(script.root)` type-checked -- at the entry point
most callers use, and exactly the swap bd 7rt made.

Narrowing it needed the three workflow signatures first, which is why it waited:
generate_ev_scenarios, generate_flexibility_provider_artifacts and
generate_semantic_graph declared base_dir: Path and passed it straight in, so
narrowing alone raised the gridalyn ratchet 116 -> 119 when measured last time.

- The three signatures take BaseArtifactDir. generate_semantic_graph re-wraps
  after base_dir.resolve(), which returns a plain Path.
- from_parquet's annotation is BaseArtifactDir. Its body still passes the value
  through Path(), so a caller holding a str or a Path keeps working at run
  time; what changes is that mypy now rejects the wrong root there.
- All three functions gained the docstring they never had, each documenting
  every parameter, base_dir included -- the condition agreed with the twin's
  owner for anything this work annotates.

Measured, not assumed. Simulated first on a throwaway worktree of main: 0 new
errors in gridalyn, projects and gridalyn/twin, and a positive control confirmed
a plain Path into from_parquet is now rejected. On this branch: pinned
black/isort/flake8 clean, the touched modules import at run time, the three
ratchets read 116 / 846 / 12 (identical to main), 57 targeted tests pass, and
the full suite is 2260 passed / 0 failed.

What remains untyped is stated rather than implied: argparse hands the scripts
an Any, so the boundary is held by the type= converters added in 39df523, and
tests pass bare Paths, which no ratchet type-checks and run time still accepts.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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