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, andsafe_event_disposalundersafety;audit_operation_log,audit_export_log, andaudit_approvalunderaudit. - Backend routes:
/safety/safe_*, the safe-event disposal action,/audit/audit_*, and the audit-approval action. - Frontend resource definitions: required
safe_eventandaudit_approvalresource/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).
TestSafeAndAuditResourceContractsreports the missingsafety/safe_rulecontract; the current catalogue still definessaf_rule(and the other historicalsaf_*/aud_*names).TestPlatformDeviceSafetyCommerceAndDeliveryRoutesFollowTheirContractsreports unregistered/heqi/platform/v1/safety/safe_*routes and thesafe_eventdisposal route.TestPlatformFinanceContentAndAuditRoutesFollowTheirContractsreports 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 becausesrc/api/resources.tscurrently definessaf_eventat/safety/saf_event; it therefore does not match the requiredsafe_eventdeclaration. The requiredaudit_approvaldeclaration 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 legacysaf_*/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.