fix: complete shadow v3 operations safeguards

This commit is contained in:
zgw
2026-09-03 17:37:58 +08:00
parent 22cf1f9a03
commit 81888f5150
3 changed files with 122 additions and 67 deletions

View File

@@ -1,64 +0,0 @@
# Task 8 Report
## Status
GREEN, pending independent review.
## RED Evidence
- The plan's single-module command first failed dependency resolution because sibling reactor artifacts are not installed in this clean worktree.
- The ledger-approved reactor-aware command was then run: `mvn -pl ruoyi-admin -am -Dtest=ShadowV3OperationsPackageTest -Dsurefire.failIfNoSpecifiedTests=false test`.
- Result before implementation: 4 tests, 1 failure and 3 errors. All failures were caused by the missing v3 CMD, SQL, and server-AI prompt files.
## Implementation
- Added fail-fast CMD-only preflight, install/upgrade, confirmed uninstall, and read-only export scripts.
- Preflight verifies the exact branch/commit, clean worktree, required main ancestry, at most one WMS JVM, SQL connectivity, recognized v2/v3 manifest, and snapshot state.
- Installer accepts only `upgrade` or `clean`; the field runbook requires `upgrade` for the current v2 site.
- Uninstaller requires the literal `CONFIRM_UNINSTALL` and warns to export evidence and restore stable service first.
- Exporter writes deployment, process, environment-name-only, SQL diagnostics, comparison, metrics, inventory parity, and structured warning files.
- Export SQL contains SELECT-only diagnostics over the requested warehouse/start time and uses SQL Server 2016-compatible constructs.
- Replaced the outdated v2 runbook with the exact v3 deployment, seven-day observation, disable/restart rollback, and optional uninstall order.
- Added a self-contained prompt for the server AI that authorizes export only and forbids deployment/database changes.
## GREEN Evidence
- Reactor-aware operations command: 5 tests, 0 failures, 0 errors, `BUILD SUCCESS`.
- Plan-mandated no-argument CMD parser checks passed for preflight and uninstall.
- Additional no-argument checks passed for install and export.
- Invalid-mode/confirmation/path protection checks passed for all four scripts without SQL execution.
## Files Changed
- `scripts/shadow-v3-preflight.cmd`
- `scripts/shadow-v3-install.cmd`
- `scripts/shadow-v3-uninstall.cmd`
- `scripts/shadow-v3-export.cmd`
- `scripts/shadow-v3-export.sql`
- `doc/algorithm-shadow/README.md`
- `doc/algorithm-shadow/SHADOW_V3_SERVER_AI_EXPORT_PROMPT.md`
- `ruoyi-admin/src/test/java/com/ruoyi/algorithm/shadow/ShadowV3OperationsPackageTest.java`
## Concerns
- The SQL package was not executed against a live production or disposable SQL Server; production execution remains explicitly out of scope.
- Existing unrelated Lombok superclass and JVM class-data-sharing warnings remain unchanged.
## Fix Round 1
### RED Evidence
Independent review reproduced six gaps: v3 snapshot state was display-only; repeat exports could overwrite evidence; environment capture did not validate its output; log collection conflated no matches with source failures; tests lacked executable CMD failure coverage; and JVM matching did not explicitly handle no-match status.
### Changed Behavior
- Preflight preserves clean-install and v2 eligibility, while v3 requires a published warehouse `01` snapshot with positive generation, synchronization/signature, no error, and no recent heartbeat/claim.
- Export refuses an existing non-empty output directory before writing, validates environment evidence, requires a log candidate, and treats `findstr` code 1 as an empty valid warning file while failing on code 2+.
### Verification
`D:/BDevTools/maven/apache-maven-3.9.11/bin/mvn.cmd -pl ruoyi-admin -am -Dtest=ShadowV3OperationsPackageTest '-Dsurefire.failIfNoSpecifiedTests=false' test` -> `BUILD SUCCESS`, 5 tests, 0 failures, 0 errors.
### Concerns
Executable CMD integration tests with stub SQL/JVM tools remain limited by the current Java test harness; live SQL Server 2016 validation remains out of scope.