feat(v2): add safe runtime configuration

This commit is contained in:
ila
2026-07-22 21:13:03 +08:00
parent 8aa36c508a
commit 70d9c5c73e
7 changed files with 457 additions and 5 deletions
@@ -41,7 +41,7 @@
- Create: `v2/assets/runtime-manifest.example.json`
- Modify: `docs/api.md`
- [ ] **Step 1: Write failing configuration tests**
- [x] **Step 1: Write failing configuration tests**
```go
func TestLoadResolvesOnlyNamedEnvironmentURL(t *testing.T) {
@@ -56,12 +56,12 @@ func TestLoadRejectsEmbeddedRTSPURL(t *testing.T) {
}
```
- [ ] **Step 2: Run the focused test and verify the missing package fails**
- [x] **Step 2: Run the focused test and verify the missing package fails**
Run: `Set-Location v2; go test ./internal/config -run TestLoad -v`
Expected: FAIL because `internal/config` does not exist.
- [ ] **Step 3: Implement the minimal public contract**
- [x] **Step 3: Implement the minimal public contract**
```go
type Config struct {
@@ -79,12 +79,12 @@ func Load(path string) (Config, error) {
Validate all required files and 64-hex model hash before monitoring starts. Return generic path/configuration errors; do not include the resolved URL in errors. Document the V2 field meanings and unchanged `FallEvent` fields in `docs/api.md`.
- [ ] **Step 4: Re-run focused and package tests**
- [x] **Step 4: Re-run focused and package tests**
Run: `Set-Location v2; go test ./internal/config -v`
Expected: PASS, including missing environment, embedded URL, invalid hash and version-redaction cases.
- [ ] **Step 5: Commit the configuration slice**
- [x] **Step 5: Commit the configuration slice**
```powershell
git add v2/config.example.json v2/internal/config v2/assets/runtime-manifest.example.json docs/api.md