[AZ-511] classColors carve-out to src/class-colors/ (closes F3)

Move src/features/annotations/classColors.ts to its own component directory
src/class-colors/ with a proper barrel; update the 4 consumer imports to go
through the barrel; remove the F3-pending exemption from STC-ARCH-01 and from
the architecture test fixture; clean up the 5 coupled doc/script touchpoints.
Closes baseline finding F3 and retires the 5-coupled-places carry-over surface
logged in LESSONS.md 2026-05-12.

- Add `class-colors` to scripts/check-arch-imports.mjs COMPONENT_DIRS so deep
  imports past the new barrel are caught symmetric to every other component.
- Replace the architecture test "exemption WORKS" fixture with the stronger
  "deep import into class-colors NOW FAILS" assertion (Risk 4 mitigation).
- module-layout.md: Layout Rules + Per-Component Mapping (11_class-colors,
  06_annotations, 03_shared-ui) + Verification Needed #1 + shared/class-colors
  block all updated to reflect the new home.
- 11_class-colors/description.md: Caveats §7 + Module Inventory updated.
- architecture_compliance_baseline.md: F3 marked CLOSED with full pre-resolution
  context preserved (mirrors AZ-485/F4 + AZ-486/F7 pattern); F4 carry-forward
  exemption note retired.
- 04_verification_log.md: open questions #1 + #8 marked RESOLVED.
- Build passes with no circular-import warnings (AC-4); fast suite 231/13
  skipped green (AC-5); static profile green (AC-3 — zero exemptions remain).

Batch report: _docs/03_implementation/batch_14_cycle3_report.md

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-05-13 03:08:36 +03:00
parent 70fb452805
commit c368f60853
19 changed files with 228 additions and 69 deletions
+18 -8
View File
@@ -6,7 +6,11 @@ import { join, resolve } from 'node:path'
// AZ-485 / F4 — verifies the STC-ARCH-01 static gate (scripts/check-arch-imports.mjs):
// - AC-5 : passes on the migrated codebase as-is
// - AC-4 : fails when a synthetic cross-component deep import is added
// - AC-4 : ignores the F3-pending exemption (features/annotations/classColors)
// - AC-4 : deep import into class-colors is NOT exempt (regression guard for
// AZ-511 — the F3 carry-over exemption was removed when classColors
// moved to src/class-colors/ with its own barrel; any consumer that
// bypasses the barrel must now fail STC-ARCH-01 like every other
// component)
// - AC-4 : ignores deep imports written inside // line comments
//
// AZ-486 / F7 — verifies the STC-ARCH-02 static gate (same script,
@@ -35,7 +39,7 @@ const API_FIXTURE_DIR = join(REPO_ROOT, 'src', '_arch_fixtures')
const FROM = 'fr' + 'om'
const UP2 = '..' + '/..'
const DEEP_API = `${UP2}/src/api/cl` + 'ient'
const DEEP_CLASSCOLORS = `${UP2}/src/features/annotations/classCo` + 'lors'
const DEEP_CLASSCOLORS_NEW = `${UP2}/src/class-colors/classCo` + 'lors'
// Build synthetic API path strings by concatenation so this test file itself
// never matches the api-literal regex when scanned. Quote characters are
@@ -84,17 +88,23 @@ describe('AZ-485 STC-ARCH-01 — no cross-component deep imports', () => {
expect(stderr).toMatch(/src\/api\/client/)
})
it('AC-4: still PASSES when only the classColors F3-pending exemption is used', () => {
// Arrange
it('AC-4: FAILS when a deep import bypasses the class-colors barrel (AZ-511 regression guard)', () => {
// Arrange — F3 was closed by AZ-511; class-colors now has a proper barrel
// at src/class-colors/index.ts, so reaching past it into the file directly
// must trip STC-ARCH-01 like every other component. The previous fixture
// asserted the exemption WORKED; this replacement asserts no exemption
// remains for class-colors at all.
const body =
`import { FALLBACK_CLASS_NAMES } ${FROM} '${DEEP_CLASSCOLORS}'\n` +
`import { FALLBACK_CLASS_NAMES } ${FROM} '${DEEP_CLASSCOLORS_NEW}'\n` +
`export const _force = FALLBACK_CLASS_NAMES\n`
writeFixture(ARCH_FIXTURE_DIR, 'classcolors_exemption.ts', body)
writeFixture(ARCH_FIXTURE_DIR, 'synthetic_classcolors_deep_import.ts', body)
// Act
const { status, stderr } = runCheck('arch-imports')
// Assert
expect(stderr, stderr).toBe('')
expect(status).toBe(0)
expect(status).not.toBe(0)
expect(stderr).toMatch(/STC-ARCH-01/)
expect(stderr).toMatch(/synthetic_classcolors_deep_import\.ts/)
expect(stderr).toMatch(/src\/class-colors\/classColors/)
})
it('AC-4: deep imports inside line comments do not trip the gate', () => {
+1 -4
View File
@@ -6,10 +6,7 @@ import { renderWithProviders, screen, fireEvent, waitFor, userEvent, act } from
import { seedBearer, clearBearer } from './helpers/auth'
import { seedClasses } from './fixtures/seed_classes'
import { DetectionClasses } from '../src/components'
// F3-pending exemption: classColors symbols live under 06_annotations until
// F3 moves the file. The 06_annotations barrel does not re-export them to
// avoid a circular import (see src/features/annotations/index.ts).
import { FALLBACK_CLASS_NAMES } from '../src/features/annotations/classColors'
import { FALLBACK_CLASS_NAMES } from '../src/class-colors'
import type { DetectionClass } from '../src/types'
// AZ-472 — DetectionClasses load + 1-9 hotkeys + click path + empty/5xx fallback.