Files
platforms/.superpowers/sdd/2026-07-27-safe-audit-model-prefix-rename/task-1-report.md

2.9 KiB

Task 1 Report: Safe and Audit Resource Rename Contracts

Scope

Added only RED contract tests. No production source, database table, or data migration code was changed.

Contract Coverage

  • Backend resource catalogue: safe_rule, safe_event, safe_inspection, and safe_event_disposal under safety; audit_operation_log, audit_export_log, and audit_approval under audit.
  • Backend routes: /safety/safe_*, the safe-event disposal action, /audit/audit_*, and the audit-approval action.
  • Frontend resource definitions: required safe_event and audit_approval resource/path declarations.

RED Evidence

Backend

Command run from backend/api:

$env:GIN_MODE='release'; go test ./internal/logic/platform ./internal/routers -run 'Test.*(Safe|Audit)' -v

Result: failed as expected (exit code 1).

  • TestSafeAndAuditResourceContracts reports the missing safety/safe_rule contract; the current catalogue still defines saf_rule (and the other historical saf_*/aud_* names).
  • TestPlatformDeviceSafetyCommerceAndDeliveryRoutesFollowTheirContracts reports unregistered /heqi/platform/v1/safety/safe_* routes and the safe_event disposal route.
  • TestPlatformFinanceContentAndAuditRoutesFollowTheirContracts reports unregistered /heqi/platform/v1/audit/audit_* routes and /audit/audit_approval/:identity/approve.

Frontend

Command run from frontend/platform_admin:

node --test scripts/audit-check.test.mjs

Result: failed as expected (exit code 1; 6 passing, 1 failing).

  • The new 资源定义使用 safe 和 audit 前缀 test fails because src/api/resources.ts currently defines saf_event at /safety/saf_event; it therefore does not match the required safe_event declaration. The required audit_approval declaration remains absent as well.

Handoff

The red baseline is intentional. The next task should rename production resource contracts, backend routes, and frontend definitions without preserving the historical public names.

Review Follow-up

The RED tests now also reject legacy saf_* and aud_* resource contracts, routes, and frontend definitions. This prevents a dual-registration implementation from satisfying only the new-name assertions. Frontend static coverage now checks all seven renamed resources, and the filtered route suite requires both GET and POST for the append-only safe-event disposal history endpoint.

Focused verification was rerun after these additions:

  • Backend: the filtered suite remains RED (exit code 1), reporting both absent safe_*/audit_* routes and currently registered legacy saf_*/aud_* routes.
  • Frontend: the focused suite remains RED (exit code 1; 6 passing, 1 failing), first reporting the missing define('safe_rule', '/safety/safe_rule'...) declaration. Once the new declarations exist, the anti-alias assertions will also reject any retained legacy definitions.