Skip to content

fix: Align ScopeAssessmentSettings with ScopeAssessmentConfig for custom thresholds #249

Closed

Description

@admarble

Summary

The scope assessment feature (merged in #247) has a type mismatch between the settings schema and the config used by the scope module. This prevents users from configuring custom thresholds via .sequant/settings.json.

Problem

Type Mismatch

ScopeAssessmentSettings (in src/lib/settings.ts) is missing fields that ScopeAssessmentConfig (in src/lib/scope/types.ts) requires:

Field Settings Config
trivialThresholds.maxACItems ❌ Missing ✅ Has
trivialThresholds.maxDirectories ❌ Missing ✅ Has
thresholds.directorySpread ❌ Missing ✅ Has

No Integration

performScopeAssessment() accepts a config parameter but:

  1. No code reads getSettings().scopeAssessment
  2. No converter function exists to transform settings → config
  3. SKILL.md just uses DEFAULT_SCOPE_CONFIG

Proposed Solution

Option A: Align Settings Schema (Recommended)

Add missing fields to ScopeAssessmentSettings:

export interface ScopeAssessmentSettings {
  enabled: boolean;
  skipIfSimple: boolean;
  trivialThresholds: {           // ADD
    maxACItems: number;          // ADD (default: 3)
    maxDirectories: number;      // ADD (default: 1)
  };
  thresholds: {
    featureCount: ScopeThreshold;
    acItems: ScopeThreshold;
    fileEstimate: ScopeThreshold;
    directorySpread: ScopeThreshold;  // ADD
  };
}

Option B: Create Converter Function

Add convertSettingsToConfig() that:

  1. Takes ScopeAssessmentSettings
  2. Merges with defaults for missing fields
  3. Returns ScopeAssessmentConfig

Acceptance Criteria

  • AC-1: ScopeAssessmentSettings includes all fields from ScopeAssessmentConfig
  • AC-2: Custom thresholds in .sequant/settings.json are used by scope assessment
  • AC-3: SKILL.md updated to read settings before calling performScopeAssessment
  • AC-4: Unit tests verify settings → config flow
  • AC-5: Default values documented

Impact

  • Current: Feature works with defaults only
  • After: Users can customize scope thresholds per project

Related


Follow-up from QA review of #239

Activity

  1. added
    auto-ready
    on Feb 16, 2026
  2. admarble commented on Feb 20, 2026

    @admarble
    ContributorAuthor

    Spec Review: #249 - Align ScopeAssessmentSettings with ScopeAssessmentConfig

    AC Quality Check

    ✅ All 5 acceptance criteria are clear and testable.


    Scope Assessment

    Non-Goals (Required)

    ⚠️ Non-Goals section not found. Consider adding scope boundaries.

    Suggested Non-Goals:

    • Creating a migration path for existing settings files (users can manually update)
    • Adding CLI flags for scope thresholds (config-file only for now)
    • Changing the scope assessment algorithm itself

    Scope Metrics

    Metric Value Status
    Feature count 1 ✅
    AC items 5 ✅
    Directory spread 2 ✅

    Scope Verdict

    ⚠️ SCOPE_WARNING - Consider narrowing scope: Non-Goals section missing.


    Acceptance Criteria with Verification

    AC-1: ScopeAssessmentSettings includes all fields from ScopeAssessmentConfig

    Verification Method: Unit Test

    Test Scenario:

    • Given: The ScopeAssessmentSettings interface in src/lib/settings.ts
    • When: Comparing its fields to ScopeAssessmentConfig in src/lib/scope/types.ts
    • Then: All fields from ScopeAssessmentConfig exist in ScopeAssessmentSettings (or defaults are merged)

    Implementation:

    • Add trivialThresholds: { maxACItems: number; maxDirectories: number } to ScopeAssessmentSettings
    • Add directorySpread: ScopeThreshold to thresholds
    • Update DEFAULT_SCOPE_ASSESSMENT_SETTINGS with default values

    AC-2: Custom thresholds in .sequant/settings.json are used by scope assessment

    Verification Method: Integration Test

    Test Scenario:

    • Given: A .sequant/settings.json file with custom thresholds (e.g., acItems.yellow: 4)
    • When: Running scope assessment via performScopeAssessment()
    • Then: The custom thresholds are applied (AC=5 triggers yellow instead of green)

    Implementation:

    • Create convertSettingsToConfig() function that merges settings with defaults
    • Export from src/lib/scope/index.ts

    AC-3: SKILL.md updated to read settings before calling performScopeAssessment

    Verification Method: Manual Test

    Test Scenario:

    • Given: SKILL.md contains scope assessment instructions
    • When: Reviewing the code block for scope assessment
    • Then: It calls getSettings().scopeAssessment and passes to performScopeAssessment()

    Implementation:

    • Update .claude/skills/spec/SKILL.md scope assessment section
    • Add getSettings() call and pass settings to converter function

    AC-4: Unit tests verify settings → config flow

    Verification Method: Unit Test

    Test Scenario:

    • Given: convertSettingsToConfig() function exists
    • When: Calling with partial settings (e.g., missing trivialThresholds)
    • Then: Defaults are merged correctly, producing valid ScopeAssessmentConfig

    Implementation:

    • Add test file src/lib/scope/settings-converter.test.ts
    • Test cases: full settings, partial settings, empty settings, edge values

    AC-5: Default values documented

    Verification Method: Manual Test

    Test Scenario:

    • Given: Default values exist in code
    • When: Checking inline documentation/comments
    • Then: All default values have comments explaining their purpose

    Implementation:

    • Add JSDoc comments to DEFAULT_SCOPE_ASSESSMENT_SETTINGS
    • Document trivialThresholds defaults (maxACItems: 3, maxDirectories: 1)
    • Document directorySpread defaults (yellow: 3, red: 5)

    Implementation Plan

    Phase 1: Align Type Schema

    1. Update ScopeAssessmentSettings interface in src/lib/settings.ts:113-127

      • Add trivialThresholds: { maxACItems: number; maxDirectories: number }
      • Add directorySpread: ScopeThreshold to thresholds
    2. Update DEFAULT_SCOPE_ASSESSMENT_SETTINGS in src/lib/settings.ts:163-171

      • Add default values matching DEFAULT_SCOPE_CONFIG
    3. Update nested merge logic in getSettings() at src/lib/settings.ts:220-227

      • Ensure trivialThresholds is deeply merged

    Phase 2: Create Converter Function

    1. Create convertSettingsToConfig() in new file src/lib/scope/settings-converter.ts

      • Takes ScopeAssessmentSettings, returns ScopeAssessmentConfig
      • Merges with DEFAULT_SCOPE_CONFIG for any missing fields
      • Export from src/lib/scope/index.ts
    2. Add unit tests in src/lib/scope/settings-converter.test.ts

      • Test full settings conversion
      • Test partial settings with defaults
      • Test empty/undefined handling

    Phase 3: Integration

    1. Update SKILL.md in .claude/skills/spec/SKILL.md:199-213

      • Import getSettings from settings module
      • Import convertSettingsToConfig from scope module
      • Update code block to read settings and convert before calling performScopeAssessment
    2. Add documentation to default values with JSDoc comments


    Feature Quality Planning

    Completeness Check

    • All AC items have corresponding implementation steps
    • Integration points identified (settings.ts ↔ scope/types.ts ↔ SKILL.md)
    • No partial implementations planned
    • Data flow complete: settings.json → getSettings() → convertSettingsToConfig() → performScopeAssessment()

    Error Handling

    • Invalid input: Converter merges with defaults for missing fields
    • Type mismatches: TypeScript catches at compile time
    • Edge cases: Empty settings returns DEFAULT_SCOPE_CONFIG

    Code Quality

    • Types fully defined (no any)
    • Follows existing patterns in codebase (deep merge in getSettings)
    • No magic strings/numbers (use DEFAULT_SCOPE_CONFIG)

    Test Coverage Plan

    • Unit tests for converter function
    • Integration: Settings → Config flow
    • Edge cases: Partial settings, empty settings

    Best Practices

    • Documentation updated (JSDoc comments)
    • Consistent with existing settings patterns

    Open Questions

    1. Type Alignment Approach

      • Question: Should we use Option A (align schema directly) or Option B (converter function)?
      • Recommendation: Hybrid approach - align schema AND add converter for flexibility
      • Impact: Pure schema alignment is simpler but less flexible for future divergence
    2. Backward Compatibility

      • Question: What happens to existing .sequant/settings.json files without new fields?
      • Recommendation: Deep merge with defaults ensures missing fields are filled
      • Impact: No breaking change - existing configs continue to work

    Recommended Workflow

    Phases: spec → exec → qa
    Quality Loop: enabled (auto-enabled due to scope concerns - missing Non-Goals)
    Reasoning: This is a focused refactoring issue with clear AC. Quality loop enabled due to missing non-goals section in original issue.


    Label Review

    Current: auto-ready
    Recommended: auto-ready, refactor
    Reason: Implementation involves restructuring type definitions across modules
    Quality Loop: Will auto-enable due to refactor label

    → gh issue edit 249 --add-label refactor


  3. added
    planned
    on Feb 20, 2026
  4. added a commit that references this issue on Feb 20, 2026
  5. admarble commented on Feb 20, 2026

    @admarble
    ContributorAuthor

    Exec Phase Complete

    AC Coverage Summary

    AC Description Status Evidence
    AC-1 ScopeAssessmentSettings includes all fields from ScopeAssessmentConfig ✅ Implemented src/lib/settings.ts:113-146
    AC-2 Custom thresholds in .sequant/settings.json are used by scope assessment ✅ Implemented convertSettingsToConfig() + SKILL.md update
    AC-3 SKILL.md updated to read settings before calling performScopeAssessment ✅ Implemented .claude/skills/spec/SKILL.md:203-218
    AC-4 Unit tests verify settings → config flow ✅ Implemented settings-converter.test.ts (9 tests)
    AC-5 Default values documented ✅ Implemented JSDoc comments on all defaults

    Files Changed

    • src/lib/settings.ts - Added TrivialThresholds interface, updated ScopeAssessmentSettings, added DEFAULT_TRIVIAL_THRESHOLDS
    • src/lib/scope/settings-converter.ts - New converter function with default merging
    • src/lib/scope/settings-converter.test.ts - 9 unit tests covering conversion scenarios
    • src/lib/scope/index.ts - Export the converter function
    • .claude/skills/spec/SKILL.md - Updated scope assessment code block to use settings

    Quality Results

    Check Status
    TypeScript Build ✅ Pass
    ESLint ✅ Pass
    Scope Module Tests ✅ 49/49 pass
    New Converter Tests ✅ 9/9 pass

    PR Status

    ✅ Created: #302

    Quality Plan Alignment

    Quality Dimension Items Addressed Notes
    Error Handling ✅ Converter handles undefined, null, partial settings gracefully
    Test Coverage ✅ Full, partial, empty, edge cases tested
    Code Quality ✅ Types aligned, no any, follows existing patterns
    Best Practices ✅ JSDoc on all exports, deep merge for nested objects

  6. admarble commented on Feb 20, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #249

    AC Coverage

    AC Source Description Status Notes
    AC-1 Original ScopeAssessmentSettings includes all fields from ScopeAssessmentConfig ✅ MET Settings interface now includes trivialThresholds.maxACItems, trivialThresholds.maxDirectories, and thresholds.directorySpread (src/lib/settings.ts:103-156)
    AC-2 Original Custom thresholds in .sequant/settings.json are used by scope assessment ✅ MET convertSettingsToConfig() merges user settings with defaults; getSettings() deeply merges partial settings (settings.ts:275-286)
    AC-3 Original SKILL.md updated to read settings before calling performScopeAssessment ✅ MET SKILL.md now imports convertSettingsToConfig and getSettings, calls them before performScopeAssessment
    AC-4 Original Unit tests verify settings → config flow ✅ MET settings-converter.test.ts has 9 comprehensive tests covering undefined handling, full conversion, partial merging, edge values, and type safety
    AC-5 Original Default values documented ✅ MET DEFAULT_TRIVIAL_THRESHOLDS and DEFAULT_SCOPE_ASSESSMENT_SETTINGS are documented with JSDoc comments (settings.ts:190-226)

    Coverage: 5/5 AC items fully met


    CI Status

    Check State Impact
    build (18.x) SUCCESS ✅ MET
    build (20.x) SUCCESS ✅ MET
    build (22.x) SUCCESS ✅ MET
    validate-skills SUCCESS ✅ MET
    typecheck SUCCESS ✅ MET
    validate-plugin SUCCESS ✅ MET

    CI Summary: 6 passed, 0 pending, 0 failed


    Quality Metrics

    Metric Value Status
    Type issues (any) 0 ✅ OK
    Deleted tests 0 ✅ OK
    Files changed 5 ✅ OK
    Lines added +334 -
    Lines deleted -4 -

    Code Review

    Strengths:

    • Clean implementation following existing codebase patterns
    • Excellent type safety: ScopeAssessmentSettings now mirrors ScopeAssessmentConfig exactly
    • Thorough test coverage with edge cases (zero values, large values, partial settings)
    • Good defensive programming: convertSettingsToConfig() handles undefined/partial inputs gracefully
    • JSDoc documentation on all public interfaces

    Issues: None blocking


    Verdict: READY_FOR_MERGE ✅

    All 5 acceptance criteria are met. Implementation is clean, focused, well-tested, and CI passes.

    Next Steps

    1. Merge PR fix(#249): Align ScopeAssessmentSettings with ScopeAssessmentConfig #302 to main

  7. added
    ready-for-review
    on Feb 20, 2026
  8. admarble commented on Feb 20, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #249

    AC Coverage

    AC Source Description Status Notes
    AC-1 Original ScopeAssessmentSettings includes all fields from ScopeAssessmentConfig ✅ MET Added TrivialThresholds interface with maxACItems/maxDirectories, added directorySpread: ScopeThreshold to thresholds (settings.ts:113-156)
    AC-2 Original Custom thresholds in .sequant/settings.json are used by scope assessment ✅ MET convertSettingsToConfig() merges user settings with DEFAULT_SCOPE_CONFIG; getSettings() deeply merges trivialThresholds and thresholds (settings.ts:275-286)
    AC-3 Original SKILL.md updated to read settings before calling performScopeAssessment ✅ MET Both code blocks now import convertSettingsToConfig/getSettings and pass config to performScopeAssessment
    AC-4 Original Unit tests verify settings → config flow ✅ MET 9 tests in settings-converter.test.ts: undefined, empty, full, partial trivialThresholds, partial thresholds, zero values, large values, type safety
    AC-5 Original Default values documented ✅ MET JSDoc on DEFAULT_TRIVIAL_THRESHOLDS, DEFAULT_SCOPE_ASSESSMENT_SETTINGS, TrivialThresholds interface, and all threshold fields with default values

    Coverage: 5/5 AC items fully met


    Quality Plan Verification

    Quality Plan found: Yes (from spec comment)

    Dimension Items Planned Items Addressed Status
    Completeness 4 4 ✅ Complete
    Error Handling 3 3 ✅ Complete
    Code Quality 3 3 ✅ Complete
    Test Coverage 3 3 ✅ Complete
    Best Practices 2 2 ✅ Complete
    Polish N/A N/A - (not UI feature)

    Derived ACs: None found in spec
    Quality Plan Status: Complete


    CI Status

    Check State Bucket Impact
    build (18.x) SUCCESS pass ✅ MET
    build (20.x) SUCCESS pass ✅ MET
    build (22.x) SUCCESS pass ✅ MET
    validate-skills SUCCESS pass ✅ MET
    typecheck SUCCESS pass ✅ MET
    validate-plugin SUCCESS pass ✅ MET

    CI Summary: 6 passed, 0 pending, 0 failed


    Quality Metrics

    Metric Value Status
    Type issues (any) 0 ✅ OK
    Deleted tests 0 ✅ OK
    Files changed 5 ✅ OK
    Lines added +334 -
    Lines deleted -4 -
    Directory spread 3 (src/lib, src/lib/scope, .claude/skills/spec) ✅ OK

    Cache Status

    N/A - Caching disabled (fresh run)


    Build Verification

    N/A - Build passed (TypeScript compiles clean, all CI checks green)


    Test Coverage Analysis

    Changed File Tier Has Tests? Test File
    src/lib/scope/settings-converter.ts Standard ✅ Yes src/lib/scope/settings-converter.test.ts (9 tests)
    src/lib/settings.ts Standard ⚠️ No dedicated test Covered indirectly via converter tests
    src/lib/scope/index.ts Standard ✅ Yes src/lib/scope/scope.test.ts (40 tests)
    .claude/skills/spec/SKILL.md Optional N/A Template code, not executable

    Coverage: 2/3 changed source files have direct tests
    Critical paths without tests: None (no auth/security/admin files modified)
    Test results: 49/49 passed in scope module


    Code Review

    Strengths:

    • Clean type alignment: ScopeAssessmentSettings now structurally mirrors ScopeAssessmentConfig field-for-field
    • Robust converter: convertSettingsToConfig() handles undefined, null, partial settings with nullish coalescing
    • Zero values treated correctly (not falsy) — verified by dedicated test
    • Good separation: new TrivialThresholds interface in settings.ts parallels the inline type in types.ts
    • Deep merge in getSettings() properly handles nested trivialThresholds and thresholds
    • JSDoc comments are thorough with default values documented inline

    Issues: None blocking

    Suggestions:

    • Minor: ScopeThreshold (settings.ts) and MetricThreshold (types.ts) are structurally identical ({ yellow: number; red: number }). Could consider re-exporting one from the other to avoid duplication, but this is cosmetic and both serve different semantic contexts

    Test Quality Review

    Category Status Notes
    Behavior vs Implementation ✅ OK Tests assert on output values, not internals
    Coverage Depth ✅ OK Covers undefined, empty, full, partial, edge (zero, large), type safety
    Mock Hygiene ✅ OK No mocks needed — pure function tests
    Test Reliability ✅ OK Deterministic, no timing/external dependencies

    Anti-Pattern Detection

    Dependency Audit

    N/A - No dependency changes

    Code Patterns

    File:Line Category Pattern Finding
    src/lib/scope/index.ts:14 Console console.log ✅ In JSDoc example, not production code

    Critical Issues: 0
    Warnings: 0


    Execution Evidence

    N/A - No executable script/CLI changes. SKILL.md changes are template code; the converter is a library function verified by unit tests.


    Skill Command Verification

    Skill files changed: 1 (.claude/skills/spec/SKILL.md)

    File Commands Found Verification Status
    .claude/skills/spec/SKILL.md 2 npx tsx -e blocks ⚠️ Skipped (inline script templates with placeholders)

    Commands Verified:

    • Import paths ./src/lib/scope/index.js and ./src/lib/settings.js → ✅ Modules exist and export expected functions
    • convertSettingsToConfig → ✅ Exported from src/lib/scope/index.ts:80
    • getSettings → ✅ Exported from src/lib/settings.ts:255

    Verification Status: Passed (imports and exports verified)


    Skill Change Review

    • Command verified: Import paths and function exports verified against source
    • Fields verified: settings.scopeAssessment matches the ScopeAssessmentSettings interface
    • Patterns complete: Both SKILL.md code blocks (assessment + state storage) updated consistently
    • Dependencies explicit: Requires src/lib/scope/index.js and src/lib/settings.js (internal modules)

    Self-Evaluation

    • Verified working: Yes — ran npx vitest run src/lib/scope/ in the feature worktree, 49/49 tests pass including 9 new converter tests. TypeScript compiles clean.
    • Test efficacy: High — converter tests cover all input shapes (undefined, empty, full, partial nested, zero values, large values) and assert on both output structure and values.
    • Likely failure mode: A user providing deeply nested partial thresholds (e.g., { thresholds: { acItems: { yellow: 10 } } }) — getSettings() shallow-merges at the threshold object level, so acItems.red would be undefined at runtime. However, convertSettingsToConfig() handles this via mergeThreshold() with nullish coalescing, so the flow is safe as long as the converter is used.
    • Verdict confidence: High — focused refactoring with clear types, comprehensive tests, and clean CI.

    Verdict: READY_FOR_MERGE ✅

    All 5 acceptance criteria are fully met. Implementation is clean, focused, well-tested (49/49 pass), and CI is green across all 6 checks. The converter function robustly handles partial settings, and the SKILL.md integration is complete. Quality plan dimensions are all addressed.

    Documentation

    • N/A - No documentation needed (internal refactor aligning existing types)

    Next Steps

    1. Merge PR fix(#249): Align ScopeAssessmentSettings with ScopeAssessmentConfig #302 to main

  9. added a commit that references this issue on Feb 20, 2026
  10. admarble commented on Feb 20, 2026

    @admarble
    ContributorAuthor

    Documentation Generated

    File: docs/features/scope-assessment-settings.md

    Sections Included:

    • Quick Start — what it does and why
    • How It Works — metrics table with defaults
    • Usage — customizing, disabling, adjusting trivial detection
    • Options & Settings — full reference table (12 options)
    • Common Workflows — large project tuning, strict mode, partial config
    • Troubleshooting — thresholds not taking effect, unexpected skipping, invalid JSON

    Next Steps:

    1. Review generated documentation for accuracy
    2. Merge PR fix(#249): Align ScopeAssessmentSettings with ScopeAssessmentConfig #302 to deploy

    Ready to merge!

  11. added a commit that references this issue on Feb 20, 2026
  12. added 4 commits that reference this issue on Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    auto-readyplannedready-for-review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions