// audit-coverage 生成全系统审计覆盖显式清单，生成结果必须经过业务、研发和安全评审。
package main

import (
	"fmt"
	"os"
	"path/filepath"

	"github.com/break/junhong_cmp_fiber/internal/governance/auditcoverage"
)

func main() {
	if err := run(); err != nil {
		_, _ = fmt.Fprintln(os.Stderr, "生成审计覆盖清单失败：", err)
		os.Exit(1)
	}
}

func run() error {
	root, err := os.Getwd()
	if err != nil {
		return err
	}
	entries, err := auditcoverage.Scan(root)
	if err != nil {
		return err
	}
	data, err := auditcoverage.MarshalManifest(entries)
	if err != nil {
		return err
	}
	path := filepath.Join(root, ".scratch/tech-global-audit/审计覆盖清单.json")
	if err := os.WriteFile(path, append(data, '\n'), 0o644); err != nil {
		return err
	}
	fmt.Printf("已生成 %d 条审计覆盖入口：%s\n", len(entries), path)
	return nil
}
