Skip to content

034 graph classifier#61

Merged
akollegger merged 7 commits intomainfrom
034-graph-classifier
Feb 20, 2026
Merged

034 graph classifier#61
akollegger merged 7 commits intomainfrom
034-graph-classifier

Conversation

@akollegger
Copy link
Copy Markdown
Contributor

This pull request introduces a new, extensible graph classification system for pattern graphs, refactoring the core graph logic to use a pluggable GraphClassifier and updating related APIs and tests. The changes enable more flexible and canonical graph element categorization, improve compatibility, and simplify classification logic across the codebase.

Graph classification refactor

  • Introduced the new Pattern.Graph.GraphClassifier module, which defines the GraphClass type and pluggable GraphClassifier record, as well as canonical and shape-based classification logic. (libs/pattern/src/Pattern/Graph/GraphClassifier.hs)
  • Refactored PatternGraph and related functions to use the new GraphClassifier, updating the data structure to store "other" elements and removing legacy classification logic. (libs/pattern/src/Pattern/PatternGraph.hs) [1] [2] [3] [4]
  • Updated Pattern.Graph to use the new classifier, including adding the mkGraphLens constructor for backward compatibility and rewiring node, relationship, and walk detection to use classification results. (libs/pattern/src/Pattern/Graph.hs) [1] [2] [3] [4] [5] [6]

Test and build system updates

  • Updated tests to use the canonical classifier when constructing pattern graphs, ensuring round-trip correctness and canonical structure. (libs/gram/tests/Spec/Gram/RoundtripSpec.hs) [1] [2] [3]
  • Registered new modules and test suites in the package build configuration. (libs/pattern/pattern.cabal) [1] [2]

Documentation and rule specification

  • Added rule and documentation entries for the new graph classifier feature, including its ecosystem and usage. (.cursor/rules/specify-rules.mdc) [1] [2]

Copy link
Copy Markdown
Contributor

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

Introduces a new, pluggable GraphClassifier vocabulary (GraphClass + GraphClassifier) and refactors PatternGraph / GraphLens to use classifier-driven categorization, updating tests and build metadata to support canonical + custom classification and improved walk validation.

Changes:

  • Added Pattern.Graph.GraphClassifier with canonical shape-based classification (including walk chain validation).
  • Refactored Pattern.PatternGraph to be parameterized by extra, store non-canonical elements in pgOther, and require a GraphClassifier for construction/merge.
  • Reworked Pattern.Graph (GraphLens) to be backed by a classifier and added mkGraphLens; updated affected tests and cabal module lists.

Reviewed changes

Copilot reviewed 24 out of 26 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
specs/034-graph-classifier/tasks.md Task breakdown for implementing/refactoring graph classification.
specs/034-graph-classifier/spec.md Feature spec describing goals, scenarios, and requirements for graph classification.
specs/034-graph-classifier/research.md Design decisions for pgOther, GraphLens re-derivation, and walk validation.
specs/034-graph-classifier/quickstart.md Usage examples for canonical and custom classifiers + legacy lens usage.
specs/034-graph-classifier/plan.md Implementation plan artifact (currently template-like).
specs/034-graph-classifier/data-model.md Data model definitions for GraphClass, GraphClassifier, and updated PatternGraph.
specs/034-graph-classifier/contracts/GraphClassifier.hs Contract stub for the classifier API.
specs/034-graph-classifier/checklists/requirements.md Spec-quality checklist for the feature.
proposals/pipeline-scenarios.md Adds motivating scenarios for graph pipelines using GraphClassifier/GraphView concepts.
proposals/graph-transform.md Design-only proposal building on GraphClassifier (introduces GraphView, transforms).
proposals/graph-query.md Design-only proposal updated to reference follow-on proposals and context helpers.
proposals/graph-mutation.md Design-only proposal updated to depend on GraphTransform and use GraphView.
proposals/graph-classifier.md Design-only proposal updated with implementation ordering notes.
proposals/files.zip Adds a zip archive containing proposal markdown files.
libs/pattern/tests/Test.hs Registers new GraphClassifierSpec in the pattern test suite.
libs/pattern/tests/Spec/Pattern/PatternGraphSpec.hs Updates PatternGraph tests to use canonicalClassifier and validates pgOther + custom classifier behavior.
libs/pattern/tests/Spec/Pattern/PatternGraphProperties.hs Updates property tests to pass canonicalClassifier into merges/builds.
libs/pattern/tests/Spec/Pattern/GraphSpec.hs Updates GraphLens tests to construct lenses via mkGraphLens.
libs/pattern/tests/Spec/Pattern/Graph/GraphClassifierSpec.hs New unit tests for classifyByShape walk validation and canonical behavior.
libs/pattern/src/Pattern/PatternGraph.hs Refactors PatternGraph to use GraphClassifier, adds pgOther, and updates merge/build APIs.
libs/pattern/src/Pattern/Graph/GraphClassifier.hs New classifier module with GraphClass, GraphClassifier, shape classification, and walk validation.
libs/pattern/src/Pattern/Graph.hs Re-derives GraphLens around a classifier, adds mkGraphLens, rewires node/rel/walk detection.
libs/pattern/pattern.cabal Exposes the new classifier module and adds the new spec module to test suite modules.
libs/gram/tests/Spec/Gram/RoundtripSpec.hs Updates roundtrip tests to build graphs using canonicalClassifier.
.gitignore Adds ignores for Thumbs.db and *.tmp.
.cursor/rules/specify-rules.mdc Documents the new feature in the Cursor/specify rules index.

Comment thread specs/034-graph-classifier/contracts/GraphClassifier.hs
Comment thread libs/pattern/src/Pattern/PatternGraph.hs
Comment thread libs/pattern/src/Pattern/PatternGraph.hs Outdated
Comment thread libs/pattern/src/Pattern/Graph.hs
Comment thread libs/pattern/src/Pattern/Graph.hs Outdated
Comment thread libs/pattern/src/Pattern/Graph/GraphClassifier.hs
Comment thread specs/034-graph-classifier/plan.md Outdated
Comment thread libs/pattern/src/Pattern/PatternGraph.hs Outdated
Comment thread libs/pattern/src/Pattern/Graph.hs Outdated
Comment thread specs/034-graph-classifier/quickstart.md Outdated
akollegger and others added 4 commits February 20, 2026 14:49
The documentation originally described `canonicalClassifier` as using
`GraphClassifier Void ...` to make `GOther` unreachable. However, the
implementation actually uses `()` because `canonicalClassifier` must be
able to classify structurally invalid shapes (like non-chaining "star
patterns" or broken walks) as `GOther ()` so they can be stored in
`pgOther` without data loss.

This updates the feature docs and proposals to align with the `()`
design, explaining that `GOther ()` is an intentional bucket for these
fallback cases.

Co-authored-by: Cursor <cursoragent@cursor.com>
Replaces placeholder tokens ([FEATURE], [###-feature-name], [DATE], [link])
with actual metadata for the GraphClassifier feature, so the documentation
appears complete rather than generated from a template.

Co-authored-by: Cursor <cursoragent@cursor.com>
@akollegger akollegger merged commit fdf5036 into main Feb 20, 2026
1 check passed
@akollegger akollegger deleted the 034-graph-classifier branch February 20, 2026 16:27
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