AgentSkillsCN

Speckit Architecture Check

Speckit架构检查

SKILL.md

SpecKit Architecture Check Skill

Technology boundary and layer compliance validation.

When to Use

  • When modifying files in core packages
  • When adding cross-package imports
  • Before creating a PR
  • When the architecture-drift hook detects warnings

Architecture Rules

Technology Ownership (NON-NEGOTIABLE)

TechnologyOwnsPython Code MUST NOT
dbtSQL compilation, dialect translationParse, validate, or transform SQL
DagsterOrchestration, assets, schedulesExecute SQL directly
IcebergStorage format, ACID, time travelDefine orchestration
PolarisCatalog, namespace managementWrite to storage directly
CubeSemantic layer, consumption APIsExecute SQL, orchestrate

Four-Layer Model

code
Layer 1: FOUNDATION     → PyPI packages, plugin interfaces
Layer 2: CONFIGURATION  → OCI artifacts (manifest.yaml)
Layer 3: SERVICES       → K8s Deployments (Dagster, Polaris, Cube)
Layer 4: DATA           → K8s Jobs (dbt run, dlt ingestion)

Rule: Configuration flows DOWNWARD ONLY (1→2→3→4) FORBIDDEN: Layer 4 modifying Layer 2 configuration

Contract Boundaries

CompiledArtifacts is the SOLE contract between packages

python
# CORRECT - floe-core produces
artifacts = compile_spec(spec)
artifacts.to_json_file("target/compiled_artifacts.json")

# CORRECT - other packages consume
artifacts = CompiledArtifacts.from_json_file("target/compiled_artifacts.json")

# FORBIDDEN - passing FloeSpec across packages
def create_assets(spec: FloeSpec):  # NO!
    ...

Execution Protocol

Step 1: Identify Changed Packages

bash
# Find which packages have changes
git diff --name-only HEAD~1..HEAD | grep -E '^packages/|^plugins/' | cut -d/ -f1-2 | sort -u

Step 2: Check Technology Ownership

For each Python file, verify:

bash
# Check for SQL parsing in non-dbt packages
rg "(sqlparse|sql.*parse|parse.*sql)" {file}

# Check for direct SQL execution in Dagster
rg "(cursor\.execute|connection\.execute)" packages/floe-dagster/

Step 3: Check Layer Boundaries

bash
# Check for Layer 4 modifying Layer 2
rg "(manifest\.yaml|write.*manifest)" packages/*/jobs/
rg "(manifest\.yaml|write.*manifest)" charts/floe-jobs/

Step 4: Check Contract Usage

bash
# Find direct FloeSpec usage outside floe-core
rg "from floe_core.* import.*FloeSpec" packages/ --ignore packages/floe-core/
rg "FloeSpec\(" packages/ --ignore packages/floe-core/

Step 5: Run Architecture Drift Script

bash
./scripts/check-architecture-drift

Compliance Matrix

CheckCommandBlocking?
SQL parsing outside dbtrg "sqlparse" packages/YES
Layer 4→2 modificationcheck-architecture-driftYES
Direct FloeSpec usagerg "FloeSpec\(" --ignore floe-coreYES
Plugin hardcoded secretsrg "password\s*=" plugins/YES
Missing entry pointsCheck pyproject.tomlNO
Cross-package test in packageCheck importsNO

Output Format

markdown
## Architecture Check: {scope}

### Status: COMPLIANT | VIOLATION | WARNING

### Technology Ownership
- dbt boundary: PASS/FAIL
- Dagster boundary: PASS/FAIL
- Iceberg boundary: PASS/FAIL

### Layer Compliance
- Layer 4→2 check: PASS/FAIL
- Configuration flow: PASS/FAIL

### Contract Compliance
- CompiledArtifacts usage: PASS/FAIL
- FloeSpec isolation: PASS/FAIL

### Violations (MUST FIX)
1. {file}:{line} - {violation description}

### Warnings (SHOULD FIX)
1. {file}:{line} - {warning description}

### Recommendations
1. {improvement suggestion}

Integration Points

Hook: PostToolUse

Architecture drift is checked automatically on Edit/Write via hook:

json
{
  "matcher": "Write|Edit",
  "command": "./scripts/check-architecture-drift \"$FILE_PATH\""
}

Skill: speckit-test-review

Invokes architecture-compliance agent for deep analysis.

Pre-PR Gate

Must pass before gh pr create is allowed.