Skip to content

Fix #446: [Model] PrimeAttributeName#683

Open
GiggleLiu wants to merge 4 commits intomainfrom
issue-446-prime-attribute-name
Open

Fix #446: [Model] PrimeAttributeName#683
GiggleLiu wants to merge 4 commits intomainfrom
issue-446-prime-attribute-name

Conversation

@GiggleLiu
Copy link
Contributor

Summary

Add PrimeAttributeName satisfaction problem — a classical NP-complete problem from relational database theory (Garey & Johnson A4 SR28). Given attributes, functional dependencies, and a query attribute, determines if the query belongs to any candidate key.

Fixes #446

@codecov
Copy link

codecov bot commented Mar 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.05%. Comparing base (dfcc313) to head (c14b1db).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #683      +/-   ##
==========================================
+ Coverage   97.04%   97.05%   +0.01%     
==========================================
  Files         284      286       +2     
  Lines       38037    38229     +192     
==========================================
+ Hits        36914    37105     +191     
- Misses       1123     1124       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@GiggleLiu
Copy link
Contributor Author

Implementation Summary

Changes

  • src/models/set/prime_attribute_name.rs — Full model implementation: struct, constructor with validation, closure algorithm, Problem trait (satisfaction), declare_variants!, ProblemSchemaEntry, canonical example
  • src/unit_tests/models/set/prime_attribute_name.rs — 15 unit tests: creation, evaluation (YES/NO), superkey not minimal, solver, serialization, closure computation, panic tests
  • src/models/set/mod.rs / src/models/mod.rs / src/lib.rs — Module registration and re-exports
  • problemreductions-cli/src/cli.rs — New --deps and --query CLI flags
  • problemreductions-cli/src/commands/create.rs — PrimeAttributeName creation handler with parse_deps() helper
  • src/example_db/fixtures/examples.json — Regenerated with new model example
  • docs/paper/reductions.typ — Problem definition entry with background, example, and CeTZ diagram

Deviations from Plan

  • None

Open Questions

  • None

Copy link

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

Adds the PrimeAttributeName satisfaction problem — a classical NP-complete problem from relational database theory (Garey & Johnson SR28). Given attributes, functional dependencies, and a query attribute, determines if the query belongs to any candidate key.

Changes:

  • New model PrimeAttributeName with closure computation, minimality checking, and full test suite
  • CLI integration with --deps and --query flags for creating instances
  • Documentation in the paper with a visual figure and mathematical description

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/models/set/prime_attribute_name.rs Core model: struct, constructor with validation, closure computation, evaluate, schema registration
src/unit_tests/models/set/prime_attribute_name.rs Comprehensive tests covering creation, evaluation, serialization, solver, and edge cases
src/models/set/mod.rs Module registration and re-export
src/models/mod.rs Public re-export
src/lib.rs Prelude export
src/example_db/fixtures/examples.json Canonical example fixture
problemreductions-cli/src/cli.rs New --deps and --query CLI flags
problemreductions-cli/src/commands/create.rs CLI create command handler with dependency parsing
docs/paper/reductions.typ Paper documentation with figure

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

@GiggleLiu
Copy link
Contributor Author

Review Pipeline Report

Check Result
Copilot comments 0 actionable
Issue/human comments 0 actionable
Structural review fixed 1 CLI help issue; targeted checks now pass
CI green
Agentic test passed after re-test
Needs human decision 2 item(s)
Board Review pool -> Under review -> Final review

Remaining issues for final review

  • Review worktrees do not reliably provide a branch-local target/debug/pred. This did not block the feature after building into /tmp, but deciding whether review worktrees should prebuild or document a build step is a maintainer workflow decision.
  • docs/src/cli.md still has no PrimeAttributeName walkthrough. The CLI is now discoverable from problem-specific help, but adding model-specific CLI docs is a maintainer documentation decision rather than a correctness blocker.

Notes

  • Fixed pred create PrimeAttributeName so the problem-specific help now advertises the real flags: --universe, --deps, and --query.
  • Strengthened tests to assert the exact satisfying key set and to cover transitive functional-dependency closure.
  • Verified locally with:
    • cargo test -p problemreductions-cli prime_attribute_name
    • cargo test -p problemreductions --features 'ilp-highs example-db' prime_attribute_name --lib
    • a branch-local CLI retest in /tmp covering create, evaluate, solve, and --example PrimeAttributeName
  • Remote CI for commit c14b1db0 is green: Test, Code Coverage, and Clippy all succeeded.

🤖 Generated by review-pipeline

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.

[Model] PrimeAttributeName

2 participants