Repository navigation
feat(spec-002): mechanical contractual classification engine - #1
Merged
Merged
Conversation
…pec commit gate - Mark all 42 Spec 001 tasks as complete in tasks.md - Add Spec 002 clarifications, plan, and task breakdown (56 tasks) - Add spec commit gate and task bookkeeping conventions to AGENTS.md - Resolve analysis findings: threshold alignment, base-50 scoring, OpenCode agent integration details, JSON verbosity strategy
…, verbose output, schema extension - internal/docscan: Scan() walks repo for .md files with priority ordering (same-package > module root > other); Filter() applies .gaze.yaml exclude/include glob patterns; full test suite - .opencode/agents/doc-classifier.md: read-only agent for document-enhanced classification with FR-005/FR-006 signal extraction and base-50 scoring - .opencode/command/classify-docs.md: orchestration command (build → classify → docscan → agent) for document-enhanced classification pipeline - cmd/gaze: add --classify, --verbose, --config, --contractual-threshold, --incidental-threshold flags to analyze; add docscan subcommand; runClassify() wires loader → analyzer → classifier → formatter with graceful degradation warning (FR-010) - internal/report: extend text formatter with CLASSIFICATION column and verbose signal breakdown; extend JSON schema with Classification/Signal $defs; add classification label styling (green/dim/yellow) - tasks.md: mark T027-T056 complete
…ended
Blockers:
- callers.go: use string-based funcKey() to match functions across
separate packages.Load universes (pointer identity was always false)
- scanner.go: enforce DocScan.Timeout via context.WithTimeout in Scan()
- contracts fixture: expand from 8 to 30+ symbols covering all 5 signal
types; add TestSC001_MechanicalContractualAccuracy (>= 90% TP rate)
Required:
- classify.go: key methods by TypeName.MethodName in buildFuncObjMap to
avoid silent overwrite when two types share a method name; add
lookupFuncObj() for receiver-qualified resolution
- classify.go + interface.go: pre-compute collectInterfaces once per
Classify() call, eliminating O(n²) collection across side effects
- main.go + main_test.go: fix threshold guard from > 0 to >= 0 with
-1 sentinel for 'not set'; add TestLoadConfig_* tests for overrides
Recommended:
- classify.go: move package-level doc comment from naming.go
- visibility.go: use utf8.DecodeRuneInString for Unicode-safe isExported
- score.go: return []Signal{} instead of nil to marshal as [] not null
- classify_test.go: add TestSC002–SC006 acceptance tests matching spec
success criteria naming convention
- bench_test.go: raise race-mode threshold from 2s to 5s to prevent
flake under parallel ./... load on CI
Blockers (Adversary): - callers.go: include receiver type in funcKey() to avoid method name collision (FileStore.Write vs MemStore.Write produce distinct keys) - main.go: validate threshold flags in [1,99] range and require contractual > incidental; add TestLoadConfig_Zero/InvertedRejected Blockers (Architect + Guard): - scanner.go: remove dead scanTimeout() helper — never called, incorrectly labeled 'Exported for testing', violates Zero-Waste Required (Architect): - interface.go: rename AnalyzeInterfaceSignal → analyzeInterfaceSignal (phantom export: exported name took unexported parameter type) - classify.go: fix misleading comment 'may be overwritten' → 'first method with this name wins' in buildFuncObjMap Required (Guard): - naming.go: add sentinelNamingWeight=30 so Err* sentinels score 50+30=80 and reach the contractual threshold without the ambiguous conf>=60 workaround; restore SC-001 test criterion to conf>60 - main.go: normalize contractualThresh/incidentalThresh=0 to -1 in runAnalyze and runDocscan to preserve struct zero-value semantics Agent config: - .opencode/agents: fix model IDs to opencode/claude-sonnet-4-6 - .opencode/agents/doc-classifier.md: fix tools from array to record format (was causing opencode config validation error)
Required (Architect): - main.go: improve loadConfig coherence-check error message to attribute whether bad thresholds came from CLI flags or the config file - main_test.go: add TestLoadConfig_YAMLInvertedThresholdsRejected using a temp .gaze.yaml fixture with contractual=50/incidental=60 to cover the YAML-path of the coherence check (previously untested) - tasks.md:127: update stale AnalyzeInterfaceSignal → analyzeInterfaceSignal reference per Speckit bookkeeping rules Required (Guard): - spec.md FR-004: document Err* sentinel exception with +30 weight and rationale (only naming signal available for package-level var; 50+30=80 reaches default contractual threshold) Recommended: - callers.go: add comment explaining the *types.TypeParam fallthrough in funcKey() — known limitation for generic code, non-generic Go unaffected - naming.go: add comment explaining sentinelNamingWeight intentionally exceeds maxNamingWeight and why sentinels are a special sub-case
❌MegaLinter analysis: Error
Detailed Issues❌ GO / golangci-lint - 1 error❌ GO / revive - 1 error
|
jflowers
added a commit
that referenced
this pull request
Aug 13, 2026
- Fix skipped test data missing from report pipeline quality JSON: BuildPackageSummary only aggregates report-level data, so SkippedTests/SkippedTestNames are now set post-hoc in runQualityStep and propagated through ReportSummary (#2, #5) - Add combined threshold test for --min-contract-coverage + --max-over-specification both set on empty results (#1) - Add divergence edge case test: SkippedTests > len(SkippedTestNames) verifies defensive guard prevents out-of-bounds (#3) - Extract shared MaxSkippedTestDisplay constant from quality package, replacing duplicate magic 20 in main.go and report.go (#6) - Move totalTestFuncs computation inside text format branch where it is actually used (#8) - Wrap WriteJSON/WriteText errors with context per CS-006 (#9) - Filed follow-up issue #219 for multi-package mixed BDD+normal scenario test (#4)
em-redhat
pushed a commit
to em-redhat/gaze
that referenced
this pull request
Sep 1, 2026
- Fix skipped test data missing from report pipeline quality JSON: BuildPackageSummary only aggregates report-level data, so SkippedTests/SkippedTestNames are now set post-hoc in runQualityStep and propagated through ReportSummary (unbound-force#2, unbound-force#5) - Add combined threshold test for --min-contract-coverage + --max-over-specification both set on empty results (unbound-force#1) - Add divergence edge case test: SkippedTests > len(SkippedTestNames) verifies defensive guard prevents out-of-bounds (unbound-force#3) - Extract shared MaxSkippedTestDisplay constant from quality package, replacing duplicate magic 20 in main.go and report.go (unbound-force#6) - Move totalTestFuncs computation inside text format branch where it is actually used (unbound-force#8) - Wrap WriteJSON/WriteText errors with context per CS-006 (unbound-force#9) - Filed follow-up issue unbound-force#219 for multi-package mixed BDD+normal scenario test (unbound-force#4)
jflowers
added a commit
that referenced
this pull request
Oct 2, 2026
Pass the cognitive complexity threshold into buildSummary and increment CognitiveComplexityExceeded when a function's score exceeds it, instead of leaving the aggregate permanently zero. Addresses PR #294 review feedback from @jflowers (finding #1). Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
gaze classifyCLI subcommand with JSON and text output, YAML config support, and configurable confidence thresholds.gaze docscanCLI subcommand for scanning repository documentation to surface contractual intent from markdown files.What changed
New packages
internal/classify/— core classification engine (naming, godoc, interface, callers, score, visibility)internal/docscan/— repository documentation scanner with timeout enforcementinternal/config/—GazeConfigwith YAML loading and threshold validationinternal/loader/— thingo/packageswrapperCLI extensions (
cmd/gaze/main.go)classifysubcommand with--threshold,--contractual-threshold,--incidental-threshold,--format,--verboseflagsdocscansubcommand with--timeout,--formatflagsloadConfigvalidates thresholds in[1,99]with coherence check (contractual > incidental) and clear attribution in error messagesReport/taxonomy extensions
internal/taxonomy/types.go—ContractQuadrant,Signal,ClassifyResulttypesinternal/report/— text formatter updated for classify output; JSON schema extendedTest coverage
classify_test.gowith acceptance testsTestSC001–TestSC006testdata/src/contracts/contracts.goTestLoadConfig_*covering threshold validation, YAML loading, inverted-threshold rejectionscanner_test.goReview council
Three rounds of review council (Adversary, Architect, Guard) — all returned APPROVE on commit
c5a3f82.Key issues addressed across rounds:
funcKey()cross-universe pointer identity bug → string-basedpkg.Path + "TypeName.MethodName"keyDocScan.Timeoutnot enforced →context.WithTimeoutinScan()--contractual-threshold=0degenerate state →[1,99]validation + coherence checkAnalyzeInterfaceSignalphantom export → renamedanalyzeInterfaceSignal(unexported)sentinelNamingWeightraised from +10 to +30 soErr*sentinels reliably score as contractualChecklist
go test -race -count=1 ./...golangci-lint runtasks.mdcheckboxes up to date