Topic · orphan code

Orphan code

Gist

Orphan code is a production function with no live requirement annotation. Coverage then reports a smaller corpus than the tree. Proof runs proof lint --check orphan_code_clean. A dead-code finder is not that hop. Jama still authors.

proof lint --check orphan_code_clean

Keep go.dev deadcode if it already lists unreachable functions. Keep Jama if it already holds the shalls. Neither one fails the merge when a helper has no // Implements: line, or still names a retired id.

01 · The silent shrink

A helper with no Implements line is invisible to coverage.

You can add functions all week. coverage_met still reports the traced set. The new helper never entered the denominator.

The check is orphan_code_clean. It is implement-stage. Severity of a hygiene miss is warning, not fail. Under source_native (the default), every supported production function needs a // Implements: <REQ> annotation, or the triple form, pointing at a live requirement. Test symbols stay on orphan tests. This hop skips IsTest / IsTestFile rows.

A hit is a function with no requirement id, or an annotation that still names a retired or superseded id. Coverage checks (coverage_met, coverage_threshold, code_mcdc_coverage) run against the traced set. An unannotated function simply does not exist as far as those checks are concerned. The audit reports clean coverage of a corpus the team did not realise had shrunk.

// projectsActiveSpec returns the active spec set for the project.
func projectsActiveSpec(p *Project) []Spec {
    // ...
}
# proof lint --check orphan_code_clean
# [IMPLEMENTATION] orphan_code_clean -- pkg/repo/spec.go:projectsActiveSpec untraced
# silent shrink: the helper shipped. no shall owns it

Four legitimate resolutions, one per finding: write // Implements: to the requirement the function already satisfies; write the requirement first when nothing states that behavior; delete the code when it is dead; or exclude the subtree with lint.exclude when it is generated, vendored, or a fixture. Do not attach the nearest plausible id to make the count drop. That passes the audit while inflating a shall the function does not implement.

Inspect the untraced list before trusting a green summary. Then annotate, author, delete, or exclude. Do not mint a Jama note to carry the skip.

proof lint --check orphan_code_clean
proof lint --check orphan_code_clean pkg/repo/
proof trace autolink-code --dry-run
proof audit --scope baseline --verbose

02 · The exhibit

Same helper. A silent shrink, or this hop.

One production function. No Implements line. Coverage stayed green. Click the tabs.

The helper

  • Ask did go test still pass after the refactor
  • Stamp projectsActiveSpec shipped with no Implements line; coverage_met stayed green
  • Why an unannotated function never enters the traced set
Suite green

This hop

Nobody asked whether the helper still has a live requirement. A green coverage_met is not a reviewed tree. The finding kind is this hop.

Annotation unread

The helper

Keep the function. Keep the Jama shall. That is not this hop.

Keep the record

Proof

  • Ask does projectsActiveSpec still lack a live Implements line
  • Out pkg/repo/spec.go:projectsActiveSpec untraced
Silent shrink counted

Same helper. A silent shrink, or this hop. Click the tabs.

Surface What they do What Proof does What we lose
go.dev deadcode / CWE-561 Unreachable functions. Warn when a live production function has no live Implements:. We do not find dead functions. A reachable helper with no shall is this hop.
orphan tests A Test* with no live Verifies:. A production function with no live Implements:. Not the test hop. See orphan tests.
coverage threshold A percentage on the traced set. Whether this function entered that set at all. Not the percentage hop. See coverage threshold.
requirements traceability matrix Requirement ↔ test ↔ code, rebuilt from the graph. Whether this production symbol is on that graph. Not the matrix hop. See requirements traceability matrix.
Jama cell A shall, and a note if you type it. A warning the audit can name next to the untraced helper. Not Jama's V&V. Jama still authors. We have not run a frozen Jama pack.

The teaching graph is still one helper whose board called the refactor done and whose requirement was never named. Close it with an annotation, a new shall, a delete, or an exclude. Do not treat a Jama note as this hop. Do not treat a green coverage stamp as a reviewed tree.

// projectsActiveSpec returns the active spec set for the project.
//
// Implements: SYS-REQ-901
func projectsActiveSpec(p *Project) []Spec {
    // ...
}

The test hop stays on orphan tests. The percentage hop stays on coverage threshold. The matrix hop stays on requirements traceability matrix. Jama still authors. Proof vs Jama.

03 · The honest loss

Proof names the untraced helper. It does not write the requirement, and it does not prove the Go.

A quiet proof lint --check orphan_code_clean can still mean overlay_audit, or a traced-scope vacuous pass. Jama still authors.

Warning, not fail. Promote once the corpus is clean. Under overlay_audit both orphan checks pass wholesale, because upstream-owned functions are not required to carry in-source comments. orphan_scope: traced warns for breadth when unannotated files are skipped; it does not pass. Test functions are not this hop. Details cap at five unless --verbose. The hop does not write the annotation. It does not write the requirement. It does not prove the Go. It does not find unreachable functions. A parser mistake can make plain data look like code. Extensionless scripts with a recognised shebang are scanned like their extensioned counterparts. We have not scored this floor against a frozen Jama pack or a go.dev deadcode run. The loss is named, not scored.

The test hop stays on orphan tests. The engagement stays on software correctness audit. Jama still authors.

04 · Nearby questions

What people type next.

What is orphan code? Same question. Same URL.

Is this dead code? No. Dead code is unreachable functions (CWE-561, go.dev deadcode). This hop is a live production function with no live requirement.

Is this orphan tests? No. That hop is a Test* with no live Verifies:. This hop is a production function with no live Implements:. See orphan tests.

Is this a coverage threshold? No. That hop is a percentage on the traced set. An orphan never enters that denominator. See coverage threshold.

Is this a requirements traceability matrix? No. That hop rebuilds requirement ↔ test ↔ code. This hop asks whether this production symbol is on the graph. See requirements traceability matrix.

Does overlay_audit fail this hop? No. Overlay projects pass wholesale. The overlay is expected to close trace through implemented_by links, not source comments.

Does a green hop prove the Go? No. The hop observes that production functions still have a live annotation. It does not prove the function is correct.

Is Proof a Jama alternative for the shall? No. Jama still authors. Proof vs Jama.