Skip to content

fix: v0.34.0 — docs/safety/ scaffold-path fallback + requirement registry sync - #46

Merged
SoundMatt merged 2 commits into
mainfrom
fix/docs-safety-scaffold-paths
Jul 27, 2026
Merged

fix: v0.34.0 — docs/safety/ scaffold-path fallback + requirement registry sync#46
SoundMatt merged 2 commits into
mainfrom
fix/docs-safety-scaffold-paths

Conversation

@SoundMatt

Copy link
Copy Markdown
Owner

Summary

  • iso26262.Assess, iec61508.Assess, do178.Assess, sci.Build, and sas.Build only checked SAFETY_PLAN.md/SVP.md/SCMP.md/SQAP.md at the bare project root, so a project scaffolded via gofusa init/gofusa template (which default to docs/safety/) immediately reported false gaps against its own freshly-generated docs.
  • Added fusa.ResolveDoc(projectRoot, name string) string, mirroring the multi-candidate-path handling iec62443.go already had for SECURITY.md/INCIDENT-RESPONSE.md, and wired it into all five builders.
  • While verifying the fix, gofusa trace surfaced a pre-existing 142-ID / 727-occurrence orphan-tag gap: entire subsystems (sas, sci, hara, gapreport, badge, metrics, disposition, impact, coupling, several analyze rules, and ~40 CLI-subcommand tags) carried real //fusa:req///fusa:test annotations that were never registered in .fusa-reqs.json. Registered all 142 (title/text/standard derived from each implementation's doc comment or --help usage text), fixed a handful of ID mismatches/duplicates found along the way, and closed the test-tag gaps that became visible once those requirements entered the coverage gate.
  • .fusa-reqs.json: 233 → 363 requirements. gofusa trace: 0 orphans, 0 untested (down from 142 orphans / 568 TRACE009 warnings).

Closes #45

Test plan

  • go build ./... — clean
  • go vet ./... — clean
  • go test ./... — all packages pass
  • go test ./... -cover — every package at or above the 80% gate
  • gofusa trace --dir . — 0 orphan tags, 0 untested requirements (previously 142 orphans / 568 TRACE009 warnings)
  • gofusa check --dir . — 0 ERROR findings, warning count dropped from 1007 to 437 (entirely from TRACE009 clearing)
  • Manually verified: a project with SAFETY_PLAN.md/SVP.md/SCMP.md/SQAP.md under docs/safety/ (matching gofusa init defaults) no longer reports those as gaps in iso26262/iec61508/do178/sci/sas

…stry sync

iso26262.Assess, iec61508.Assess, do178.Assess, sci.Build, and sas.Build
only checked SAFETY_PLAN.md/SVP.md/SCMP.md/SQAP.md at the bare project
root, so a project scaffolded via `gofusa init`/`gofusa template`
(which default to docs/safety/) immediately reported false gaps.
Fixed by adding fusa.ResolveDoc, mirroring the multi-candidate-path
handling iec62443.go already had for SECURITY.md/INCIDENT-RESPONSE.md.

Also closed a 142-ID / 727-occurrence orphan-tag gap found while
verifying the fix: entire subsystems (sas, sci, hara, gapreport, badge,
metrics, disposition, impact, coupling, several analyze rules, and
~40 CLI-subcommand tags) carried real annotations never registered in
.fusa-reqs.json. Registered all 142, fixed the handful of ID
mismatches/duplicates found along the way, and added the test tags
that became visible once those requirements entered the coverage gate.

Closes #45

Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com>
CI's doc-version-check gate requires README.md's Docker published-tags
line and docs/tool-safety-manual.md's version header to reference the
current fusa.Version.

Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com>
Comment thread sci/sci_test.go
if err := os.MkdirAll(filepath.Join(dir, "docs", "safety"), 0o755); err != nil {
t.Fatalf("mkdir: %v", err)
}
if err := os.WriteFile(filepath.Join(dir, "docs", "safety", "SAFETY_PLAN.md"), []byte("x"), 0o644); err != nil {
Comment thread sci/sci_test.go
//fusa:test REQ-DOC001
func TestBuild_DocsSafetyScaffoldPath(t *testing.T) {
dir := t.TempDir()
if err := os.MkdirAll(filepath.Join(dir, "docs", "safety"), 0o755); err != nil {
Comment thread sas/sas_test.go
t.Fatalf("mkdir: %v", err)
}
for _, f := range []string{"SAFETY_PLAN.md", "SVP.md", "SCMP.md", "SQAP.md"} {
if err := os.WriteFile(filepath.Join(dir, "docs", "safety", f), []byte("x"), 0o644); err != nil {
Comment thread sas/sas_test.go
//fusa:test REQ-DOC001
func TestBuild_DocsSafetyScaffoldPath(t *testing.T) {
dir := t.TempDir()
if err := os.MkdirAll(filepath.Join(dir, "docs", "safety"), 0o755); err != nil {
Comment thread iso26262/iso26262_test.go
if err := os.MkdirAll(filepath.Join(dir, "docs", "safety"), 0o755); err != nil {
t.Fatalf("mkdir: %v", err)
}
if err := os.WriteFile(filepath.Join(dir, "docs", "safety", "SAFETY_PLAN.md"), []byte("x"), 0o644); err != nil {
Comment thread fusa.go
}
if docScaffoldFiles[name] {
alt := filepath.Join(projectRoot, "docs", "safety", filepath.FromSlash(name))
if _, err := os.Stat(alt); err == nil {
Comment thread fusa.go
//fusa:req REQ-DOC001
func ResolveDoc(projectRoot, name string) string {
root := filepath.Join(projectRoot, filepath.FromSlash(name))
if _, err := os.Stat(root); err == nil {
Comment thread do178/do178_test.go
t.Fatalf("mkdir: %v", err)
}
for _, f := range []string{"SAFETY_PLAN.md", "SVP.md", "SCMP.md", "SQAP.md"} {
if err := os.WriteFile(filepath.Join(dir, "docs", "safety", f), []byte("x"), 0o644); err != nil {
Comment thread do178/do178_test.go
//fusa:test REQ-DOC001
func TestAssess_DocsSafetyScaffoldPath(t *testing.T) {
dir := t.TempDir()
if err := os.MkdirAll(filepath.Join(dir, "docs", "safety"), 0o755); err != nil {
Comment thread fusa.go
// builders that check for these same files on disk also check
// docs/safety/<name> as a fallback to the bare project-root path, so a
// freshly-scaffolded project doesn't immediately report false gaps (#45).
var docScaffoldFiles = map[string]bool{
@SoundMatt
SoundMatt merged commit ff0b32f into main Jul 27, 2026
16 checks passed
@SoundMatt
SoundMatt deleted the fix/docs-safety-scaffold-paths branch July 27, 2026 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

assess commands (iso26262/iec61508/do178/sci/sas) hardcode root-only doc paths, while template/init default to docs/safety/

2 participants