Skip to content

derive doc/design-doc signals from docscan output to resolve ambiguous classification (external analyzers) #285

Closed

Description

@jflowers

Problem

External-analyzer projects (e.g. Python via snake-eyes) report a large share of their side effects as ambiguous. For snake-eyes, the latest report classifies 56.7% of detected effects (1186/2091) as ambiguous — the same 1186 figure surfaced in the classification_counts verified in #278.

The repository's own spec/design docs already encode the missing intent: the container-mutation design docs explicitly mark 10 ContainerMutation effects as observable/contractual and 14 as internal bookkeeping/incidental. gaze docscan already finds and reads those documents (74 for snake-eyes), but that output is consumed only by the AI report pipeline — it never reaches classification. So documented contracts and documented internal bookkeeping stay ambiguous.

Findings (why this is small, not an architecture change)

  • The scoring engine is source-agnostic. classify.ComputeScore (internal/classify/score.go) sums every Signal.Weight regardless of Source; adapter.mergeClassifications (internal/adapter/classify.go) copies external-analyzer signals' Source/Weight/Reasoning verbatim into ComputeScore. A new doc-derived source would flow through with no protocol surgery.
  • The source vocabulary already anticipates it: taxonomy.Signal.Source (internal/taxonomy/types.go:152-153) lists "readme" and "architecture_doc" as examples, but no extractor produces them.
  • The only doc-derived weight convention today is Go-native: internal/classify/godoc.go (maxGodocWeight=15 contractual, -15 incidental, reducedGodocWeight=5 indirect), called only from the goprovider path.
  • internal/docscan/* is consumed only by internal/aireport/runner_steps.go; ClassificationConfig.DocScan is include/exclude/timeout config for docscan.Scan. There is no doc → signal → ComputeScore path.

Proposed change

Derive doc/design-doc signals from the docs docscan already reads and inject them into classification for external-analyzer effects, instead of having each analyzer re-scan its own docs.

  1. Define a doc-derived signal source (e.g. architecture_doc, or reuse the anticipated readme/architecture_doc names already in the Signal.Source comment) and its weights — a gate value, most naturally mirroring the godoc 15/-15/5 convention.
  2. Add a doc → signal derivation step that maps documented public-API contracts → positive signal and documented internal bookkeeping → negative signal, keyed to (package, function, side_effect_type) so it can be merged in mergeClassifications.
  3. Keep this scoped to external analyzers (Go already has godoc + native extractors); do not change the godoc native path.

Open design questions

  • Where should the free-form Markdown → (file, line, effect_type) mapping live? Docs are natural-language prose, not machine-parseable effect identities. A deterministic annotation grammar (or a machine-readable sidecar) is needed so the derivation is reproducible rather than NLP-based.
  • Effect-type names are language-specific (snake-eyes emits ContainerMutation, etc.); the doc grammar must reference analyzer-emitted type names, so the derivation may need the analyzer's own taxonomy mapping.

Related

Activity

  1. added
    enhancement
    on Sep 28, 2026
  2. fullsend-ai-triage commented on Sep 28, 2026

    @fullsend-ai-triage

    🤖 Finished Triage · ✅ Success · Started 9:41 PM UTC · Completed 9:45 PM UTC

    Commit: 18aa40c · View workflow run →

    Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $1.01

  3. fullsend-ai-triage commented on Sep 28, 2026

    @fullsend-ai-triage

    Triage Assessment

    Severity: medium — The 56.7% ambiguous rate significantly reduces the utility of contract coverage metrics for external-analyzer users, but the tool remains functional and the AI report pipeline partially compensates.

    Design Considerations

    The two open design questions are the critical path for implementation:

    1. Annotation grammar: Free-form Markdown docs cannot be deterministically mapped to (package, function, effect_type) triples without a structured format. A machine-readable sidecar (e.g., YAML alongside design docs) or a structured annotation syntax within Markdown (e.g., fenced blocks with a specific tag) would make the derivation reproducible. This is a spec-worthy design decision.

    2. Language-specific type names: The grammar must reference analyzer-emitted type names (e.g., ContainerMutation). The taxonomy.ValidTypes set and taxonomy.IsKnownType function already exist for validation — the derivation step can use these to reject unknown type names at parse time.

    Proposed Test Case

    func TestDocSignalDerivation_ContractualAnnotation(t *testing.T) {
        // Given: a doc annotation marking ContainerMutation as contractual
        // for package "mymod/store", function "Cache.Set"
        // When: doc signals are derived and merged into classification
        // Then: the effect's classification changes from "ambiguous" to "contractual"
        // And: the Signal has Source "architecture_doc" and Weight 15
    }
    
    func TestDocSignalDerivation_IncidentalAnnotation(t *testing.T) {
        // Given: a doc annotation marking ContainerMutation as incidental
        // When: doc signals are derived and merged
        // Then: classification changes from "ambiguous" to "incidental"
        // And: Signal has Weight -15
    }
    
    func TestDocSignalDerivation_GoPathUnaffected(t *testing.T) {
        // Given: Go-native analysis results with godoc signals
        // When: doc signal derivation runs
        // Then: no doc-derived signals are produced (scoped to external only)
    }

    Related Work

    This should go through the spec-first pipeline given the annotation grammar design decision.


    Next steps:

    • /fs-code — agent creates a PR to implement this issue
    • /fs-code <your instruction> — agent implements with your specific guidance
  4. added a commit that references this issue on Sep 29, 2026
    9d8af6e
  5. added 2 commits that reference this issue on Oct 1, 2026
    4513aea
    2daa51f
  6. added a commit that references this issue on Oct 1, 2026
    a7f37e7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementfeaturetriaged

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions