Skip to content

fix: taxonomy cleanup and extraction bug fixes#39

Merged
darko-mijic merged 1 commit intomainfrom
fix/issues-with-tutorial-repo
Apr 1, 2026
Merged

fix: taxonomy cleanup and extraction bug fixes#39
darko-mijic merged 1 commit intomainfrom
fix/issues-with-tutorial-repo

Conversation

@darko-mijic
Copy link
Copy Markdown
Contributor

@darko-mijic darko-mijic commented Mar 29, 2026

Summary

  • Remove @architect-brief tag — dead relic from early development (zero production consumers)
  • Remove @architect-core flag — eliminate flag/category dual-registration; core is now a category only
  • Fix hardcoded 'ddd' category fallback — use registry-based default from active preset
  • Fix tag name leaking into category — validate inferCategory fallback against registry
  • Filter shape directives at scanner level — prevent @architect-shape from creating false lint violations

14 files changed, 45 insertions, 106 deletions. Net -61 lines.

Approach: Root Cause Fixes Over Symptom Patches

Hard rule for this package: Prefer structural, root-cause fixes over minimal patches — even when they introduce breaking changes.

This PR was triggered by 6 bugs found during tutorial review. The minimal fix would have been 6 individual patches (adding guards to lint rules, patching flag processing, updating metadata text). Instead, this PR addresses classes of issues through removals and structural changes:

Bug Minimal Fix Actual Fix Why
Linter errors on @architect-shape Add isShape check to 3 lint rules Filter shapes at scanner level Every future lint rule would need the same check. Scanner filtering prevents the class.
@architect-core sets flag not category in Gherkin Add category after flag processing Remove core from metadata flags entirely isCore had zero production consumers. Removal eliminates the flag/category collision class.
@architect-brief wrong metadata Update purpose/example text Remove @architect-brief from taxonomy Dead tag with zero consumers. Violates "code is the single source of truth."
Hardcoded 'ddd' fallback Change string to 'core' Use config.tagRegistry?.categories[0]?.tag Registry-derived fallback works across all presets without hardcoding.
Tag name leaks into category Add status to exclude list Validate against priorityMap (registry categories) Validates against the authoritative category set rather than maintaining an exclusion list.

This approach should be the standard for all work in this package. The package is mission-critical infrastructure for a consumer monorepo (~600 files, 45K+ lines). A bug here means incorrect documentation/validation across ALL platform packages. Quality over convenience, always.

Why this matters for the product

From the product vision: "Architect provides the missing infrastructure: structured specifications that evolve into production code, a single source of truth."

A taxonomy system with dead tags, dual registrations, and hardcoded fallbacks undermines the "single source of truth" principle at the infrastructure level. If the tool that enforces architectural discipline has undisciplined internals, the entire value proposition is weakened. This PR aligns package internals with the product principle.

Implications for Consumer Repos

Breaking changes requiring action

Change Impact Migration
@architect-brief removed Any file using this annotation will get an unknown tag warning during extraction Remove @architect-brief annotations — the description belongs inline in the @architect JSDoc block or in the Feature description
isCore field removed from ExtractedPattern and DocDirective Any code accessing .isCore will get a TypeScript error Replace pattern.isCore with pattern.category === 'core'
@architect-core is now category-only In Gherkin: now correctly sets category: "core" (was silently ignored for category). In TypeScript: unchanged behavior. No action needed — this fixes incorrect behavior
Default category fallback changed Gherkin features without a category tag now get the first preset category (core for libar-generic) instead of ddd Verify any queries filtering by category === 'ddd' — they may need updating if that category came from the fallback

Tutorial repo (delivery-process-tutorials)

  • Remove all @architect-brief annotations from TypeScript source files
  • Re-run npx architect-lint-patterns to verify 0 errors, 0 warnings

Consumer monorepo (libar-platform)

  • Search for @architect-brief in all packages — remove annotations
  • Search for .isCore in any custom tooling — replace with category check
  • After updating the package version: pnpm architect:query -- overview to verify no regressions

Deeper Refactoring Opportunities

During exploration, I noticed these opportunities that follow the same "root cause over patch" approach:

  1. sequence-error is the only remaining flag tag. The flag metadata format exists solely for this one tag. Consider whether sequence-error should instead be an enum value on a sequence-role tag (alongside sequence-orchestrator, sequence-step, sequence-module), which would allow removing the flag format entirely from the registry schema.

  2. Gherkin extractPatternTags() uses a module-level TAG_LOOKUP built from buildRegistry() (line 88 of gherkin-ast-parser.ts). This always uses the full DDD_ES_CQRS registry regardless of the active preset. It works because the scanner's job is to extract all possible metadata, but threading the actual registry through would be more precise and enable preset-specific validation at scan time.

  3. The inferCategory fallback chain in doc-extractor.ts (lines 457-518) has multiple fallback layers: priority-based matching → subsequence matching → first-tag extraction → 'uncategorized'. The subsequence matching (checking all contiguous subsequences of hyphenated tag parts) is complex and could potentially match unintended categories. A simpler approach: exact match only, then 'uncategorized'.

  4. The ProcessMetadataSchema in dual-source.ts still has several fields that may be dead or underused (similar to how brief was). A usage audit of quarter, effort, effortActual, risk, workflow, and priority would identify candidates for the same treatment.

Test plan

  • pnpm typecheck — passes clean
  • pnpm lint — passes clean
  • pnpm test — 8712 tests pass, 141 test files
  • Pre-commit hooks pass (lint-staged + process guard)
  • Pre-push hooks pass (full test suite + CLI integration)
  • Tutorial repo: npx architect-lint-patterns — 0 errors after removing @architect-brief
  • Tutorial repo: npx architect list --fields patternName,category — correct categories

Summary by CodeRabbit

Release Notes

  • Removals

    • Removed @architect-core metadata flag from pattern directives
    • Removed @architect-brief metadata tag from pattern directives
  • Improvements

    • Updated category inference logic to derive defaults from configured tag registry instead of hardcoded values
    • Enhanced directive parsing to properly identify and skip shape-only directives

…shape directives

Remove @architect-brief (dead relic) and @architect-core flag (zero consumers),
fix hardcoded 'ddd' category fallback in Gherkin extractor, validate category
inference against registry, and filter shape-only directives at scanner level.

BREAKING CHANGE: @architect-brief tag removed, isCore field removed from schemas
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 29, 2026

📝 Walkthrough

Walkthrough

This PR removes support for the @architect-core flag tag and @architect-brief value tag from pattern metadata extraction, validation, and parsing across the system. Changes eliminate these fields from schema definitions, extractors, registries, and all related tests while refining category inference logic in extraction flows.

Changes

Cohort / File(s) Summary
Schema Definitions
src/validation-schemas/doc-directive.ts, src/validation-schemas/extracted-pattern.ts, src/validation-schemas/dual-source.ts
Removed optional isCore and brief fields from validation schemas and their inferred types.
Extractors & Parsers
src/extractor/doc-extractor.ts, src/extractor/gherkin-extractor.ts, src/extractor/dual-source-extractor.ts, src/scanner/ast-parser.ts
Removed isCore and brief field extraction and emission from pattern metadata. Updated category inference in gherkin extractors to derive defaults from config.tagRegistry. Added isShapeOnlyDirective function to skip shape-only directives in AST parser.
Registry Builder
src/taxonomy/registry-builder.ts
Removed core (flag) and brief (value) metadata tag definitions from registry and updated METADATA_TAGS_BY_GROUP.core group membership.
Behavior Test Features
tests/features/behavior/pattern-tag-extraction.feature
Removed brief extraction coverage and updated category assertions to check metadata.categories contains "core" instead of metadata.core boolean flag.
Type Registry Test Feature
tests/features/types/tag-registry-builder.feature
Removed core metadata tag from expected registry output.
Test Fixtures & Factories
tests/fixtures/pattern-factories.ts, tests/fixtures/scanner-fixtures.ts
Removed isCore and brief options from TestPatternOptions and GherkinContentOptions interfaces; eliminated conditional emissions of these fields.
Test Steps & Assertions
tests/steps/behavior/pattern-tag-extraction.steps.ts, tests/support/helpers/assertions.ts
Removed brief extraction step coverage and updated category assertions to use metadata.categories containment checks. Removed isCore from assertion helper function signature.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Core and brief tags, now deprecated,
Removed with care and checks well-met.
Categories rise, simpler ways,
Metadata flows through cleaner days!
Registry rebuilt, schemas anew,
One less complexity for me and you. 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: taxonomy cleanup and extraction bug fixes' directly summarizes the main changes: removing taxonomy entries and fixing related extraction logic across multiple files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issues-with-tutorial-repo

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
src/extractor/doc-extractor.ts (1)

3-3: ⚠️ Potential issue | 🟡 Minor

Self-referential use of removed @architect-core tag.

This file's JSDoc uses @architect-core @architect-extractor`` at line 3. The @architect-core tag is removed by this PR.

📝 Proposed fix
 * `@architect`
- * `@architect-core` `@architect-extractor`
+ * `@architect-extractor`
 * `@architect-pattern` Document Extractor
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/extractor/doc-extractor.ts` at line 3, Update the JSDoc in
src/extractor/doc-extractor.ts to stop referencing the removed tag: remove the
obsolete "@architect-core" token from the top-level comment so it only contains
"@architect-extractor" (or other remaining valid tags); locate the JSDoc block
at the top of doc-extractor.ts and edit that comment to delete "@architect-core"
wherever it appears.
src/scanner/ast-parser.ts (1)

3-3: ⚠️ Potential issue | 🟡 Minor

Self-referential use of removed @architect-core tag.

Similar to registry-builder.ts, this file's JSDoc uses @architect-core @architect-scanner`` at line 3. The @architect-core portion will produce an unknown-tag warning after this PR.

📝 Proposed fix
 * `@architect`
- * `@architect-core` `@architect-scanner`
+ * `@architect-scanner`
 * `@architect-pattern` TypeScript AST Parser
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/scanner/ast-parser.ts` at line 3, Remove the obsolete JSDoc tag from the
file's header by editing the doc comment that currently contains
"@architect-core `@architect-scanner`" in src/scanner/ast-parser.ts so it only
includes the valid "@architect-scanner" tag; locate the JSDoc block at the top
of the file (the same pattern used in registry-builder.ts) and delete the
"@architect-core" token to avoid the unknown-tag warning.
src/taxonomy/registry-builder.ts (2)

110-110: ⚠️ Potential issue | 🟡 Minor

Stale documentation: comment still references removed tags.

The JSDoc comment at line 110 says core: Essential pattern identification (pattern, status, core, usecase, brief) but the actual array at line 123 is now ['pattern', 'status', 'usecase']. Update the comment to reflect the removal of core and brief.

📝 Proposed fix
- * - core: Essential pattern identification (pattern, status, core, usecase, brief)
+ * - core: Essential pattern identification (pattern, status, usecase)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/taxonomy/registry-builder.ts` at line 110, Update the JSDoc comment that
still mentions "core" and "brief" so it matches the actual tags array (now
['pattern', 'status', 'usecase']); remove references to core and brief and
change the example/comment text to "pattern: Essential pattern identification
(pattern, status, usecase)" or similar to reflect only pattern, status, and
usecase in the JSDoc block above the tags array.

3-3: ⚠️ Potential issue | 🟡 Minor

Self-referential use of removed @architect-core tag.

This file's own JSDoc annotation uses @architect-core at line 3, which is the very tag being removed by this PR. This will likely cause an "unknown-tag" warning when the scanner processes this file.

📝 Proposed fix: remove the deprecated tag
 * `@architect`
- * `@architect-core`
 * `@architect-pattern` TagRegistryBuilder
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/taxonomy/registry-builder.ts` at line 3, Remove the deprecated JSDoc tag
`@architect-core` from the top-of-file JSDoc in registry-builder.ts (the
self-referential tag at the file header); edit the file header comment to delete
the "@architect-core" token so the scanner no longer emits an "unknown-tag"
warning while leaving the rest of the JSDoc intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/extractor/doc-extractor.ts`:
- Line 3: Update the JSDoc in src/extractor/doc-extractor.ts to stop referencing
the removed tag: remove the obsolete "@architect-core" token from the top-level
comment so it only contains "@architect-extractor" (or other remaining valid
tags); locate the JSDoc block at the top of doc-extractor.ts and edit that
comment to delete "@architect-core" wherever it appears.

In `@src/scanner/ast-parser.ts`:
- Line 3: Remove the obsolete JSDoc tag from the file's header by editing the
doc comment that currently contains "@architect-core `@architect-scanner`" in
src/scanner/ast-parser.ts so it only includes the valid "@architect-scanner"
tag; locate the JSDoc block at the top of the file (the same pattern used in
registry-builder.ts) and delete the "@architect-core" token to avoid the
unknown-tag warning.

In `@src/taxonomy/registry-builder.ts`:
- Line 110: Update the JSDoc comment that still mentions "core" and "brief" so
it matches the actual tags array (now ['pattern', 'status', 'usecase']); remove
references to core and brief and change the example/comment text to "pattern:
Essential pattern identification (pattern, status, usecase)" or similar to
reflect only pattern, status, and usecase in the JSDoc block above the tags
array.
- Line 3: Remove the deprecated JSDoc tag `@architect-core` from the top-of-file
JSDoc in registry-builder.ts (the self-referential tag at the file header); edit
the file header comment to delete the "@architect-core" token so the scanner no
longer emits an "unknown-tag" warning while leaving the rest of the JSDoc
intact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: eaad54ac-0aa7-4bea-bdbb-936052b4fab6

📥 Commits

Reviewing files that changed from the base of the PR and between e979c1a and 74b09bd.

📒 Files selected for processing (14)
  • src/extractor/doc-extractor.ts
  • src/extractor/dual-source-extractor.ts
  • src/extractor/gherkin-extractor.ts
  • src/scanner/ast-parser.ts
  • src/taxonomy/registry-builder.ts
  • src/validation-schemas/doc-directive.ts
  • src/validation-schemas/dual-source.ts
  • src/validation-schemas/extracted-pattern.ts
  • tests/features/behavior/pattern-tag-extraction.feature
  • tests/features/types/tag-registry-builder.feature
  • tests/fixtures/pattern-factories.ts
  • tests/fixtures/scanner-fixtures.ts
  • tests/steps/behavior/pattern-tag-extraction.steps.ts
  • tests/support/helpers/assertions.ts
💤 Files with no reviewable changes (8)
  • tests/features/types/tag-registry-builder.feature
  • src/extractor/dual-source-extractor.ts
  • src/validation-schemas/dual-source.ts
  • src/validation-schemas/extracted-pattern.ts
  • tests/fixtures/scanner-fixtures.ts
  • tests/fixtures/pattern-factories.ts
  • tests/support/helpers/assertions.ts
  • src/validation-schemas/doc-directive.ts

@darko-mijic darko-mijic merged commit 74b09bd into main Apr 1, 2026
4 checks passed
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