package workflow import ( "fmt" "sort" ) // commentHygiene is a read-only gate: it scans every text file in the // working tree (skipping .git and the gitignored workspace) for an // AI-attribution fingerprint and fails if any shippable file carries // one. It writes nothing and needs no external tool, so it is never // blocked. type commentHygiene struct{} func (commentHygiene) Name() string { return "comment-hygiene" } func (commentHygiene) Summary() string { return "scan source and docs for AI-attribution fingerprints (read-only)" } func (commentHygiene) Run(env Env) (Result, error) { cfg := env.Config det, err := NewDetector(cfg.AttributionPatterns) if err != nil { return Result{}, err } var findings []Finding err = walkText(cfg.RepoRoot, cfg.WorkspaceName, func(rel, content string) error { findings = append(findings, det.Scan(rel, content)...) return nil }) if err != nil { return Result{}, fmt.Errorf("comment-hygiene: walk: %w", err) } if len(findings) == 0 { return Result{Code: CodeClean, Summary: "no attribution fingerprints found"}, nil } sort.Slice(findings, func(i, j int) bool { if findings[i].Path != findings[j].Path { return findings[i].Path < findings[j].Path } return findings[i].Line < findings[j].Line }) return Result{ Code: CodeFinding, Summary: fmt.Sprintf("%d attribution fingerprint(s) in tracked tree", len(findings)), Findings: findings, }, nil }