Support recursive design: additive multi-file MTHDS libraries#970
Support recursive design: additive multi-file MTHDS libraries#970lchoquel wants to merge 19 commits into
Conversation
…nd checkpoint protocol
…handling - Added `contract_equals` method to `PipeBlueprint` for contract comparison. - Introduced `duplicate_ref_msg` function for generating error messages on duplicate declarations. - Enhanced `LibraryCrateFactory` to reconcile pipe declarations and handle collisions. - Updated tests to cover new reconciliation logic and ensure correct behavior for signatures and concrete pipes.
…tion - Removed the local concept reference validation from PipelexBundleBlueprint, allowing bundles to construct even when referencing concepts declared in sibling files. - Added a new method in LibraryCrateFactory to validate concept references against the merged library after bundle construction. - Created a new test suite for validating concept references at the library level, ensuring that undeclared references are caught during the merge process. - Updated existing tests to reflect the new validation logic and removed obsolete tests related to local concept reference validation. - Introduced new test cases to verify cross-file concept reference resolution and error handling for undeclared concepts.
…idation - Changed `ConceptLibraryError` to inherit from `LibraryError` for better error categorization. - Introduced `validate_concept_references_in_blueprints` function to validate same-domain concept references across multiple blueprints. - Updated `LibraryCrateFactory` to remove in-factory concept reference validation, delegating it to the loader. - Enhanced `LibraryManager` to validate concept references against the live library during blueprint loading. - Added integration tests for cross-file and cross-batch concept reference resolution. - Created unit tests for `validate_concept_references_in_blueprints` to cover various scenarios including undeclared concepts and native concept allowances.
…nd finalize Phase 4 preparations
…ks and contract conformance
…natures and enhance validation output - Added `contracts_match` function to normalize and compare contracts between pipe signatures and their definitions. - Updated `ValidateBundleResult` to include `pending_signatures`, reflecting unsatisfied forward declarations. - Enhanced validation output to render pending signatures in markdown format. - Introduced tests for pending signatures in validation results and contract reconciliation across equivalent concept spellings.
…omain metadata across files
Update the recursive-design handoff trackers to reflect shipped work on feature/Support-recursive-design: - HANDOFF-recursive-followups.md: Task 1 (pending_signatures on a lenient validate) and Task 2 (normalized contract conformance) marked done, with as-built notes. - HANDOFF-domain-metadata-merge.md: order-independent, omission-quiet domain metadata merge marked done (shared merge_domain_metadata_field helper wired into both the crate factory and the runtime DomainLibrary). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Greptile SummaryThis PR adds additive multi-file
Confidence Score: 5/5This looks safe to merge.
Reviews (5): Last reviewed commit: "fix(library): use canonical native-conce..." | Re-trigger Greptile |
There was a problem hiding this comment.
No issues found across 28 files
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Re-trigger cubic
…ive-design # Conflicts: # CHANGELOG.md # pipelex/cli/agent_cli/CLAUDE.md
…, and concepts-only Three paths still did per-file / pre-merge work, breaking same-domain authoring the merged crate is meant to resolve: - Remove the obsolete per-file validate_local_pipe_references validator so qualified same-domain pipe refs (research.find_key_findings) resolve to a sibling-file declaration like bare refs do; missing refs are still caught post-merge by validate_pipe_library_with_libraries. - Run validate_concept_references_in_blueprints on the concepts-only loader so a dangling concept_ref / item_concept_ref is rejected (pipelex structures / load_concepts_only), matching the full load. - Route _load_single_dependency through LibraryCrateFactory so a multi-file dependency (PipeSignature header + concrete sibling) reconciles to the concrete instead of colliding in add_new_pipe and silently dropping a declaration; a genuine duplicate now raises. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ve-building follow-ups
load_libraries_concepts_only loaded each discovered .mthds file as its own one-file batch, so the cross-file concept-reference check ran before sibling concepts were present — a valid additive concepts library could fail based on directory load order. Batch all sibling files into a single load_concepts_only_from_blueprints call, mirroring load_concepts_only_from_directory, so same-domain references resolve against the merged set regardless of order. Adds an order-independence regression test (referencing file sorts before its declaration) and a CHANGELOG clause. Reported by greptile on PR #970. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace the phase/checkpoint planning narrative with a reviewer-facing description of the feature: the four merge-time changes (signature/concrete reconciliation, cross-file concept resolution, domain-metadata merge, pending_signatures), the file map, error-surfacing, test coverage, design decisions, and intentionally-deferred items. Points to wip/recursivity/ for the deeper records. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Review round 1 — addressedgreptile P1 ( cubic: no issues found — thanks. Also rewrote
@greptileai @cubic-dev-ai please re-review. |
@lchoquel I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
1 issue found across 32 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="pipelex/builder/operations/validate_ops.py">
<violation number="1" location="pipelex/builder/operations/validate_ops.py:72">
P2: validate_all is missing pending_signatures in its return dict, inconsistent with the other three validation surfaces that now include it. The CLI JSON envelope for --all won't report pending signatures.</violation>
</file>
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Re-trigger cubic
| "bundle_path": str(bundle_path), | ||
| "validated_pipes": build_validated_pipes(result.dry_run_result), | ||
| "total_pipes": len(result.dry_run_result), | ||
| "pending_signatures": result.pending_signatures, |
There was a problem hiding this comment.
P2: validate_all is missing pending_signatures in its return dict, inconsistent with the other three validation surfaces that now include it. The CLI JSON envelope for --all won't report pending signatures.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At pipelex/builder/operations/validate_ops.py, line 72:
<comment>validate_all is missing pending_signatures in its return dict, inconsistent with the other three validation surfaces that now include it. The CLI JSON envelope for --all won't report pending signatures.</comment>
<file context>
@@ -69,6 +69,7 @@ async def validate_bundle_file(
"bundle_path": str(bundle_path),
"validated_pipes": build_validated_pipes(result.dry_run_result),
"total_pipes": len(result.dry_run_result),
+ "pending_signatures": result.pending_signatures,
}
</file context>
pending_signatures is a per-bundle, top-down-build nudge surfaced only by `validate bundle` (as documented in agent_cli/CLAUDE.md). The validate-all sweep is a whole-library check, not a build step, and acquire_and_validate tears its library down before returning. Comment both validate-all surfaces so the intentional asymmetry is recorded locally. Addresses cubic P2 on PR #970 (intentional scoping, not a gap). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Review round 2 — addressedcubic P2 ( greptile: 5/5, no blocking issues — thanks. @greptileai @cubic-dev-ai please re-review. |
@lchoquel I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
1 issue found across 32 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="pipelex/builder/operations/validate_ops.py">
<violation number="1" location="pipelex/builder/operations/validate_ops.py:72">
P2: validate_all is missing pending_signatures in its return dict, inconsistent with the other three validation surfaces that now include it. The CLI JSON envelope for --all won't report pending signatures.</violation>
</file>
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Re-trigger cubic
…ation validate_concept_references_in_blueprints treated any concept ref whose local code matched a native name as native (`ref.local_code in native_codes`), so a same-domain qualified ref that merely shares a native local code (e.g. `my_domain.Text`) was skipped instead of validated — suppressing the undeclared-reference error even though that ref actually fails at resolution (ConceptLibrary.get_required_concept_from_concept_ref_or_code uses the canonical check). Switch to NativeConceptCode.is_native_concept_ref_or_code (bare `Text` or `native.Text` only), matching resolution and contract_match. Adds a regression test. Reported by cubic on PR #970. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Review round 3 — addressedcubic P1 ( Good catch. @greptileai @cubic-dev-ai please re-review. |
@lchoquel I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
No issues found across 32 files
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Re-trigger cubic
The pre-landing /review (independent adversarial + testing + maintainability reviewers) found no bugs and verdict ship. Record the P3 polish it surfaced (docstring accuracy, advisory-description silent-drop note, one low-confidence test-coverage gap) in wip/recursivity/review-followups.md so they aren't lost, and point TODOS.md at it. No production code change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Pre-landing review (gstack /review) — verdict: shipRan an independent, fresh-context review pass on top of the bot rounds: three reviewers (adversarial / chaos-engineer, test-coverage, maintainability) each read the full diff against Scope: CLEAN. Intent (additive multi-file libraries: reconciliation, cross-file concept resolution, domain-metadata merge, Correctness: no bugs found. The adversarial reviewer explicitly cleared the high-risk areas: the Tests: strong coverage. Reconciliation matrix, contract-match normalization (incl. the Maintainability: clean, no over-engineering. The new modules ( Only P3 polish surfaced (docstring accuracy, an advisory-description silent-drop note, one low-confidence test-coverage gap) — no bugs. Per "no over-engineering / defer doubts," these are recorded in PR is ready to land once CI is green on the latest commit. |
…signatures Add reference-level docs-site coverage for the additive multi-file capability shipped on this branch: a sibling-files note on signature-pipes.md (a header file forward-declares signatures, definition files supply the concrete pipes; they reconcile when contracts match), and the new pending_signatures validate output on validate.md and agent-cli.md. The full top-down multi-file walkthrough is deferred until the recursive orchestrator (mthds-plugins) lands and pins the real workflow; tracked as documentation debt on the PR. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Summary
Adds support for recursive / additive multi-file MTHDS library construction: a same-domain library can now be authored as separate, additive
.mthdsfiles (forward-declared headers + separate definitions) instead of one monolithic file. This unblocks parallel, top-down method construction.Merge-time rules
PipeSignature(forward declaration / "header") and a concrete pipe with the same code reconcile — the concrete satisfies the signature instead of raising a duplicate-code error. Contracts are compared by normalized concept identity (bare ≡ domain-qualified,Text≡native.Text, structural multiplicity), replacing the old raw-stringcontract_equals. Two concrete pipes, or genuinely different contracts, still error.ConceptLibraryError; an unresolvable reference now surfaces as a structured validation error instead of a raw traceback.description/system_promptnow merge order-independently across same-domain files: a membership-only file that omits them defers to whichever file declares them, instead of warning and racing on filesystem load order. The root header always wins over siblings that carry onlydomain = "...". Two files declaring different non-empty values still keep the first and warn. Implemented as a sharedmerge_domain_metadata_fieldhelper wired into both the crate factory and the runtimeDomainLibrary.Validate surface
pending_signatureson a successful lenient validate. A successfulvalidate bundle(notably--allow-signatures) now reports the library-wide set of pipes still declared asPipeSignature— surfaced as apending_signaturesarray in the agent-CLI / builder JSON envelope and a "Pending signatures" markdown section, so a top-down build sees exactly what remains.Test plan
make agent-check— clean (ruff, plxt, pyright, mypy).make agent-test— full suite green.tests/unit/pipelex/libraries/for signature/concrete reconciliation, normalized contract conformance, cross-file concept references, and the domain-metadata merge matrix (both load orders, same-value, conflict; acrossdescription+system_prompt, warnings asserted viacaplog).Documentation
Docs-site coverage added this cycle (reference level — the full top-down walkthrough is deferred, see Documentation Debt):
docs/building-methods/pipes/signature-pipes.md— new note: a signature and its concrete definition can live in separate sibling files of the same domain; loading merges them and they reconcile when contracts match. Points to the validate output.docs/tools/cli/validate.md— new "Pending signatures" tip under Validate Bundle: a successful run reportspending_signatures(library-wide list of still-unimplementedPipeSignatureheaders), most useful on--allow-signatures.docs/tools/cli/agent-cli.md— extended the signature note with thepending_signaturesenvelope field (JSON array + markdown section).CHANGELOG.md[Unreleased]already carries the full feature entry (additive construction, reconciliation, cross-file concept resolution, domain-metadata merge,pending_signatures).pipelex/cli/agent_cli/CLAUDE.mddocuments thepending_signaturesenvelope field. Design records live inwip/recursivity/.Documentation Debt
mthds-vibe/mthds-signature-expanderinmthds-plugins) is not built yet, so a detailed walkthrough now would risk drifting from the real flow. Write it once that orchestrator lands. Suggest adocs-debtlabel.wip/recursivity/but have no dedicated how-to. Same trigger to expand: when the orchestrator ships.🤖 Generated with Claude Code
Summary by cubic
Adds recursive, additive multi-file
.mthdslibraries for the same domain. Signatures reconcile with concretes, cross-file refs resolve across files/batches, andvalidate bundlereturnspending_signatures(intentionally omitted byvalidate-all); works for dependencies and the concepts-only loader.New Features
Text≡native.Text, multiplicity). Conflicting concretes or mismatched contracts still error.descriptionandsystem_prompt. Membership-only files defer; conflicting non-empty values keep the first and warn.validate bundlereturnspending_signaturesin JSON and renders a "Pending signatures" section;validate-allomits it by design.Bug Fixes
.mthdsfiles so same-domain refs resolve regardless of filename order.LibraryCrateFactory, reconciling multi-filePipeSignature+ concrete packages; genuine duplicates raise.Textornative.Textonly), fixing false skips for qualified refs likemy_domain.Text.wip/recursivity/review-followups.md(docs only).Written for commit b77726b. Summary will update on new commits.