Repository navigation
Conversation
Owners add photos of the installation to a claim that sets station details, within the upload window after its proof. A photo is never approved automatically, whatever the switches say. - Server (read-only for SQLite, Kpa-clawbot#1283): POST /api/antenna-claims/requests/{requestId}/photo sniffs the type, refuses oversize bodies and headers that would decode too large before any decode, decodes in at most 2 slots, re-encodes without metadata and upright, and writes only station-photos/inbox/. Owner status, public photo route (immutable cache, one 404 for hidden, stale, pending and off), admin list, image and decisions; /station lists approved photos. - Ingestor: node_claim_photos (migration antenna_claim_photos_v1 with keep_photos), re-check of claim, files and caps, inbox move, approve with per-node eviction, reject, deletion on every claim transition, orphan sweep at every prune. - Operator config antennaClaims.photos.*, docs, OpenAPI. The read-only invariant forbids writes to node_claim_photos and pins the server's file writes to the inbox. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review — CS-Minimax PR#1100 — head bc66757Dom: REQUEST CHANGES This is an independent, read-only review. The design follows the revised M0 plan (§8, §10 M5 row) and the owner decisions (3 approved photos, photos on by default). The tests are thorough: my 5 mutants were all killed, and the real binaries pass 27/27 in my own end-to-end smoke. One finding breaks a security invariant the PR claims. It is a small fix, but it must come with a test, so the verdict is REQUEST CHANGES. Evidence labels: [T] I ran it. [K] I read it in the code, the docs or the issue. [A] I assume it and did not verify it. Findings
No other findings. Upload gates, stripping, orientation, traversal, never-auto-approve, the deletion triggers, the sweep, inbox-only writes, the read-only invariant, the identical 404, the immutable cache and the semaphore all check out (details below). Answers to the checklist
Tests and mutantsMerged tree:
Own mutants (each applied to a copy of head, then the PR's tests run, then restored and checked with
Red before, green after: every new test references code that does not exist on Hygiene: commit author is the required one (dborup) [T]; fork guards 9 in CI per job (run 46970174645, head bc66757)All jobs green [T]:
The known flakes (#256 Hash Stats sort, #267 backfill write-hold) did not occur. What I did not verify
|
Relates to #1017
Status: M5 (station photo backend) is complete and ready for review. Every requirement has a test that is green here, and 45 of 46 mutants are killed. The one survivor is equivalent; it is explained below. An end-to-end smoke with the real binaries passes 13/13. The Go suites are green, apart from wall-clock perf budgets that fail identically on
origin/masteron the test machine.Evidence labels: [T] I ran it here (test, benchmark or command). [K] I read it in the code, the docs or the issue. [A] It is assumed and not verified.
What this PR does (the M5 row of the revised M0 plan)
An owner can add photos of the installation to a claim that sets station details. Photos are never approved automatically: an administrator reviews every one, whatever the switches say. The server stays read-only for SQLite (Kpa-clawbot#1283). It writes files only under
station-photos/inbox/, and the ingestor owns the table, the caps, the moves and every deletion.photo-submit/photo-approve/photo-reject,PhotoFiles,ValidPhotoID(exactly 16 hex),PhotoLiveSQL/PhotoServableSQL/PhotoUploadSQL,PhotoConfigandPhotoLimits,Command.KeepPhotosinternal/channelregistry/antennaclaim/photo.go,antennaclaim.goantenna_claim_photos_v1, in the ingestor's Apply:node_claim_photos(CHECKs mirrorPhotoFiles.Valid, FKON DELETE CASCADE, 2 indexes) andnode_antenna_claims.keep_photos; anAssertReadyitem (transient while the ingestor migrates)internal/dbschema/dbschema.gocmd/server/station_photos.go,cmd/server/station_photo_image.gopending; approve with per-node eviction; reject; deletions on every claim transition; orphan sweep at every prunecmd/ingestor/station_photos.go,cmd/ingestor/antenna_claims.goGET /api/nodes/{pubkey}/photo/{id}.jpg?size=thumb|full(immutable cache) andphotoson/stationcmd/server/station_photos.go,cmd/server/antenna_claims.goPOST /api/antenna-claims/requests/{requestId}/photoandGET /api/antenna-claims/photos/{photoId};"photo": "keep"on a claimGET /api/admin/antenna-claims/photos,GET …/photos/{photoId}(the image, no-store, key in a header),POST …/photos/{photoId}/approve|rejectantennaClaims.photos.*(not the customizer, rule 8), docs, OpenAPIconfig.example.json,docs/user-guide/configuration.md,docs/user-guide/antenna-height-claims.md,docs/deployment.md,cmd/server/openapi.goThere is no frontend change. M6 builds the UI.
Decisions I made where the plan left a choice (smallest change that keeps existing behaviour)
NodeStationResponse.photos, not onStationDetails.StationDetailsis embedded inDetailsInput, so a field there would also become a claim input. [K]GET /api/antenna-claims/photos/{id}. [T]"photo": "keep"(open question 12) is stored askeep_photos. When the claim is approved, the replaced claim's photos (pending and approved) move to it. Without keep, they are deleted. [T]golang.org/x/image. Its kernel scalers allocate adw × sh × [4]float64temporary buffer: about 205 MB for a 16 MP source scaled to 1600 px. Instead, a small area-average resampler reads one source row at a time. Sogo.modis unchanged and nothing is added to the module graph. [K][T]eXIfchunk is ignored and stripped. [T]detailsEnabled(owner decision 16). Only a canonical"enabled": falseturns them off; a case variant is ignored, as for the other gates (Config: feature gates and the base-map token must only accept canonical key spellings #884). [T]Requirements, tests and mutants
Each mutant was applied to a copy of the tree, the named tests were run, and the source was restored. KILLED means the tests went red. The tests are green on the branch [T]. On
origin/masterevery new test fails to build, because the code they test does not exist there [K].Security first
TestStationPhoto1017M5_BombsRefusedBeforeDecode,…_ConfiguredPixelCapContent-Lengthover the cap gives 413 without reading the body; a chunked body gives 413 throughMaxBytesReader; neither reaches decodeTestStationPhotos1017M5_UploadRefusalsTestStationPhotos1017M5_UploadRefusals,TestStationPhoto1017M5_Sniffphoto_idshape;../,%2f,%5c, upper case,.png,inboxand another node's id never serve a file…_Public404Identical,TestPhoto1017M5_ValidPhotoID,TestAntennaClaimPhotos1017M5_ChecksValidPhotoIDaccepts longer ids; M37 bytes CHECK removedTestStationPhotos1017M5_Public404IdenticalnodePhotosTestPhoto1017M5_SubmitRefusalsM5 row of the plan
TestStationPhoto1017M5_StripsMetadataAndAppliesOrientation,…_PNGChunksStripped…_OrientAllEight,…_ExifOrientationParse…_TransparentPNGOnWhiteautoApproveProven×autoApproveDetailsTestPhoto1017M5_NeverAutoApprovedTestPhoto1017M5_DeletionTriggersphoto: "keep"moves the photos; the files stayTestPhoto1017M5_KeepMovesPhotos,TestStationPhotos1017M5_ClaimKeepPhotos.tmp-entries; it leaves foreign files alone; it drops photos of dead claimsTestPhoto1017M5_SweepHeals,…_SweepDropsPhotosOfDeadClaimsTestPhoto1017M5_Caps>=→>; M15 store cap removedTestPhoto1017M5_ApproveNeedsServableClaim,TestStationPhotos1017M5_AdminApproveNeedsServableClaimTestStationPhotos1017M5_UploadGatesinbox/: behaviour (the file tree diff after an upload and after a refused one, no row written, raw upload never on disk, mode 0700) and source (an AST scan: every file-writingoscall instation_photo*.gosits in the 3 inbox writers; no other file names the photo store)TestStationPhotos1017M5_UploadWritesOnlyTheInbox,…_QueueFullLeavesNothing,TestServerPhotoWritesOnlyInboxos.Chtimesin a readernode_claim_photosjoins the forbidden-write tablesTestServerHasNoPacketTableWrites,…IsSensitiveAssertReadytransient before and permanent afterinternal/dbschema/antenna_claim_photos_test.go(4 tests)mustTableremovedphoto_1017_m5_test.go(8 tests)TestStationPhotos1017M5_StatusTestStationPhotos1017M5_AdminRoutes/stationlists approved photos only, and only while photos are on and the station is not staleTestStationPhotos1017M5_StationPhotosGate,…_PublicServesImmutablenodePhotosSurvivors, and what they changed [T]:
nodePhotoschecks the switch again, so the route still answers 404. I kept the early check: it skips the node lookup while photos are off. M30b and M30c (the inner check removed, and both removed) are killed.removePhotoInbox) survived. It exposed that the full-queue branch was untested. I added…_QueueFullLeavesNothing, and the redefined M33 is killed.Perf (rule 0)
Retry-After: 5at once, never reaches the decoder and spends no per-IP budget; a freed slot is reusedTestStationPhotos1017M5_DecodeSemaphoreAtTwoTestStationPhoto1017M5_16MPPeakHeap(bound 1.5 × the 64 MB budget),BenchmarkStationPhoto16MPpublic, max-age=31536000, immutable,ETag, 304 onIf-None-Match,nosniffTestStationPhotos1017M5_PublicServesImmutableTestStationPhotos1017M5_UploadRefusalsMeasured on the test machine (4 vCPU, i7-1260P; [T]). The test machine is much slower than typical hardware: stdlib decode alone takes 3.5 s [A].
jpeg.DecodescaleDownto 1600 pxReadTimeout(30 s,cmd/server/main.go). [K]maxApprovedPerNode≤ 10), then one file open.Suites run here
cd internal/channelregistry && go test ./...cd internal/dbschema && go test ./...cd cmd/ingestor && go test -timeout 60m ./...-timeout 20m; the first run here hit the default 10 min on the test machine.cd cmd/server && go test -timeout 90m ./...TestAntennaClaims898_NoPerPartDecisionRoutepinned the routes under/api/admin/antenna-claims/. I updated it on purpose: it still pins exactly the 3 claim decision routes, and now also pins the 4 photo routes separately. It is green [T]. 5 failures are wall-clock perf budgets:TestAdvertIntervalAnalytics_AggregatePerf,TestDagiAreaStatsWithinBudget,TestProfileCard_Cost,TestCoverage941_PerfBudget,TestCoverage941M2_PerfBudget. They fail identically onorigin/masterb7db1738on the test machine, run isolated [T]. None of them touches photo code.node scripts/run-go-server-shard.js --validate4132 runnable entries … (15 / 15 / 4102); the new tests run in the catch-all shard [T]sh test-all.shtest-live-heard-filter.js,test-live-scope-color.js,test-issue-724/728/730/941-…,test-1055-live-dagi.js,test-1055-m3-area-rule.js,test-dagi-filter.js,test-issue-598-hop-path-inference.js), plustest-channel-proposals.js(51.2 ms against a 50 ms budget) andtest-backup-sqlite-safety.js, under load. Run alone, those last two pass. 9 of the remaining 10 fail the same way onorigin/master;test-dagi-filter.jspassed there once and failed here once, so it is unstable at its budget. This branch changes no file underpublic/and notest-*.js[T].node test-frontend-helpers.jsbash scripts/check-xss-sinks.sh --diff origin/masterpublic/changes [T]map[string]interface{}added outside testsdeploy.yml, 1 inrelease-fast-path.yml;.github/is not touched [T]e2e-fixture.dbtest-channel-proposals-e2e.js. The ingestor migrates the fixture (antenna_claim_photos_v1) and the server passesAssertReady.photosEnabledis true by default. The script inserts the node and an approved details claim as fixtures. Then: upload 202 → the ingestor moves inbox → store as pending → public 404 → the admin list requires the key and lists the photo; the image is served no-store → approve →/stationlists it → the public thumbnail answers 200 image/jpeg, immutable, nosniff, with no Exif and no tEXt → reject → row and files gone → public 404. Both processes were stopped afterwards.CI per job
What I expect per CI job:
origin/mastertoday. [A]public/changes. [A]Rest (follow-ups, not in M5)
configuration.mdand in the owner guide.eXIforientation is not applied (decision 8).🤖 Generated with Claude Code