Skip to content

feat: Phase 4 complete - Contract generation and density scoring (v0.8.0)#30

Merged
djm81 merged 14 commits intomainfrom
dev
Nov 24, 2025
Merged

feat: Phase 4 complete - Contract generation and density scoring (v0.8.0)#30
djm81 merged 14 commits intomainfrom
dev

Conversation

@djm81
Copy link
Copy Markdown
Collaborator

@djm81 djm81 commented Nov 24, 2025

Phase 4: Contract Generation from SDD - ✅ COMPLETE

This PR completes Phase 4 of the SDD Feature Parity Implementation Plan, adding contract generation and density scoring capabilities.

🎯 What's New

Contract Density Scoring

  • New module: src/specfact_cli/validators/contract_validator.py
    • ContractDensityMetrics class for tracking contract density metrics
    • calculate_contract_density() function calculates contracts per story, invariants per feature, and architecture facets
    • validate_contract_density() function validates metrics against SDD coverage thresholds
  • Integration: Contract density validation integrated into specfact enforce sdd and specfact plan review commands
  • Display: Contract density metrics now displayed in plan review output when SDD manifest is present

Bug Fixes

  • Plan bundle hash persistence: Fixed bug where plan harden calculated hash but didn't save plan bundle to disk
    • Plan bundle now correctly saved with updated summary metadata containing hash
    • Prevents hash mismatch errors when running specfact generate contracts after plan harden
    • Added integration test test_plan_harden_persists_hash_to_disk to prevent regression

📚 Documentation Updates

  • End-user docs: Updated docs/reference/commands.md with:
    • plan harden command documentation
    • enforce sdd command documentation with contract density validation
    • generate contracts command documentation
    • SDD integration section in plan review documentation

🧪 Testing

  • Unit tests: 10 comprehensive tests for contract density calculation and validation
  • Integration tests: Enhanced test_plan_harden suite with hash persistence verification
  • All tests passing: Contract validator tests + integration tests

📦 Version

  • Version bump: 0.7.1 → 0.8.0
  • CHANGELOG: Updated with Phase 4 completion details

✅ Phase 4 Status

  • 4.1 Contract Stub Generator: Complete (already implemented)
  • 4.2 Contract Density Scoring: Complete (newly implemented)

🔗 Related

cursoragent and others added 13 commits November 18, 2025 13:31
Co-authored-by: dominikus.nold <dominikus.nold@web.de>
- Add --batch-updates option to plan update-feature command
- Add --batch-updates option to plan update-story command
- Add --list-findings option to plan review command with structured output
- Refactor review function to reduce complexity
- Add comprehensive e2e tests for batch updates
- Update documentation and prompts to prefer batch updates
- Update version to 0.7.0
…itioning

- Updated all examples and guides with CLI-first messaging
- Added Integration Showcases references throughout documentation
- Emphasized integration diversity (VS Code, Cursor, GitHub Actions, pre-commit)
- Updated brownfield showcase examples with integration workflow sections
- Updated platform-frontend CMS to link to Integration Showcases README
- Reviewed and aligned all brownfield documentation for CLI-first approach
- Updated version to 0.7.1

Files updated:
- All docs/examples/ files (6 files)
- All docs/guides/ files (6 files)
- docs/reference/directory-structure.md
- platform-frontend/iac/scripts/payload-content-helper.js
- Version files: pyproject.toml, setup.py, src/__init__.py, src/specfact_cli/__init__.py
- CHANGELOG.md with comprehensive 0.7.1 entry
- Fixed basedpyright warnings for repo_path.exists() in contract decorators
- Added isinstance() type guard to properly narrow Path | None types
- Updated Example 3 validation status to FULLY VALIDATED (CI/CD workflow verified in production)
- Updated documentation to reflect Example 3 is validated in specfact-cli repository CI/CD

Fixes type checking errors reported in GitHub Actions workflow:
- constitution_evidence_extractor.py:65:53 - Type of "exists" is unknown
- Fixed in all three methods: extract_article_vii_evidence, extract_article_viii_evidence, extract_article_ix_evidence

Example 3 Status Update:
- Changed from "COMMANDS VERIFIED" to "FULLY VALIDATED"
- Validated in production CI/CD (specfact-cli PR #28)
- Workflow successfully runs specfact repro and blocks PRs when validation fails
- Add contract density validator (contract_validator.py) with metrics calculation
- Integrate contract density into enforce sdd and plan review commands
- Add contract density metrics display in plan review output
- Fix plan bundle hash persistence in plan harden command
- Add integration test for plan bundle hash persistence
- Update version to 0.8.0
- Update CHANGELOG.md with Phase 4 completion details
- Update end-user documentation with new commands (plan harden, enforce sdd, generate contracts)

Phase 4 Status: ✅ COMPLETE (2025-11-24)
- 4.1 Contract Stub Generator: ✅ Complete
- 4.2 Contract Density Scoring: ✅ Complete (10 unit tests passing)

Test Coverage:
- 10 unit tests for contract density validation
- 1 integration test for hash persistence
- All tests passing
@github-actions
Copy link
Copy Markdown
Contributor

SpecFact CLI Validation Report

All validations passed!
Duration: 27.83s
Checks: 4 total (3 passed) (1 skipped)

@djm81 djm81 merged commit a9167a1 into main Nov 24, 2025
3 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

SpecFact CLI Validation Report

All validations passed!
Duration: 27.32s
Checks: 4 total (3 passed) (1 skipped)

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.

2 participants