|
| 1 | +# Native ImageJ point archive repair checkpoint |
| 2 | + |
| 3 | +Implemented native codec repair. Dependency integration and live viewer validation |
| 4 | +remain separate from native archive validation. |
| 5 | + |
| 6 | +Base and source audited: `0efe67fdd14985bf90cee6e0f0c4735d41d265d1`, |
| 7 | +OpenHCSDev/PolyStore main. Issue: OpenHCSDev/PolyStore#12. |
| 8 | +Dependent work: OpenHCSDev/openhcs#134 and draft OpenHCSDev/openhcs#153. |
| 9 | +Branch: `fix/native-imagej-point-roi-20260929`. |
| 10 | +Own worktree: `/home/ts/wt/polystore-point-roi-20260929`. |
| 11 | + |
| 12 | +## Current delivery decision |
| 13 | + |
| 14 | +The user explicitly authorized bounded Python inspection and the lightweight |
| 15 | +refactor-audit scripts so the FULL NRA memory defect does not block OpenHCS. |
| 16 | +Main owns this codec repair; the previous worker is no longer active. The |
| 17 | +existing archive reader and `ImageJROIShapeConverter` family are the bounded |
| 18 | +production corpus. All 53 original classes across these two modules were |
| 19 | +inspected through NRA's canonical syntax index and joined to its 53 eligible |
| 20 | +class-family projections. Declared local codec bases resolve to the existing |
| 21 | +family. External base execution/MRO proof and full global/R1 coverage remain |
| 22 | +OPEN and are not claimed. The bounded projection took 1.02 seconds and 63,800 KiB |
| 23 | +peak RSS. |
| 24 | + |
| 25 | +The admitted external-format obligation is POINT bytes to PointShape, preserving |
| 26 | +all XY coordinates and existing per-member metadata. Polygon/polyline/oval |
| 27 | +members must keep their own geometry, not use a silent polygon fallback. |
| 28 | +Extend the existing registered converter family with decoding behavior and |
| 29 | +derive native-kind lookup from its leaf declarations. The archive reader keeps |
| 30 | +ownership of ZIP bytes and metadata sidecar assembly. Delete its geometry |
| 31 | +switch. Unsupported native kinds must fail explicitly. This closes IMPL-4 and |
| 32 | +the concrete BOUND-2 bypass within this boundary; it is not a proof of global |
| 33 | +architecture or unrelated external ROI subtype support. |
| 34 | + |
| 35 | +Native encoding/decoding additions are behavior changes validated by actual |
| 36 | +roifile bytes and the disk entrypoint, not asserted equivalent from syntax. |
| 37 | +New geometry requires one codec declaration, not a ZIP-reader branch. Existing |
| 38 | +scientific archives and native Z/C/T metadata are not rewritten or guessed. |
| 39 | +Owned small test output/cache: `/home/ts/.cache/agent-scratch/openhcs-point-codec-20260929`. |
| 40 | + |
| 41 | +## Implemented behavior and validation |
| 42 | + |
| 43 | +- POINT encoding sets the actual native POINT kind. Decode retains every |
| 44 | + point, exact fractional YX, and existing logical metadata. |
| 45 | +- Polygon, polyline, and oval decoding belongs to their existing codec leaves. |
| 46 | + Oval writing now uses the native subpixel bounding rectangle rather than a |
| 47 | + two-point FREEHAND payload relabeled OVAL. Independent integer oval input is |
| 48 | + tested too. |
| 49 | +- Native kinds resolve from the existing registered leaf declarations. There |
| 50 | + is no added registry or archive-reader geometry switch. Unsupported kinds, |
| 51 | + specialized subtypes, malformed/empty/nonfinite coordinates, missing sidecar |
| 52 | + metadata, and mask encoding fail explicitly. |
| 53 | +- Old one-point FREEHAND archives stay invalid. No legacy reader is added and |
| 54 | + no frozen scientific archive is rewritten. |
| 55 | + |
| 56 | +The realistic disk save/load entrypoint, native roifile bytes, Napari projection, |
| 57 | +existing disk tests, and streaming identity/metadata tests passed together: |
| 58 | +114 passed in 0.88 seconds; 1.32 seconds wall time; peak RSS 104,084 KiB. |
| 59 | +Command: existing OpenHCS CPython 3.12 environment, this worktree's `src` first |
| 60 | +on `PYTHONPATH`, recorded parent dependency source roots, plugin autoload off, |
| 61 | +`python -m pytest -o addopts= -q tests/test_roi.py tests/test_disk_backend.py |
| 62 | +tests/test_disk_more.py tests/test_disk_coverage.py tests/test_streaming_metadata.py |
| 63 | +tests/test_streaming_identity.py`, bounded by a 60-second shell timeout. |
| 64 | +This is source-override native validation, not installed or rendered-viewer proof. |
| 65 | +An earlier tiny CPython 3.14 environment lacked portalocker during conftest |
| 66 | +import; that setup failure was retained separately and was not a codec test. |
| 67 | + |
| 68 | +Before-change lightweight census and overlay at committed HEAD took 0.48 and |
| 69 | +1.61 seconds respectively, with 21,776 and 39,628 KiB peak RSS. They read Git |
| 70 | +revisions, not uncommitted files. Candidate `7c7f681` versus the recorded main |
| 71 | +adds 80 production code lines, removes one None probe, and changes none of the |
| 72 | +other census debt counts. The native external-kind switch has been deleted, |
| 73 | +as independently confirmed in the combined source diff. Census: 0.14 seconds, |
| 74 | +20,212 KiB peak RSS. Candidate overlay: 1.59 seconds, 40,748 KiB peak RSS; its |
| 75 | +category totals match the baseline, with no parse warnings. Existing unrelated |
| 76 | +switches and record-shape leads remain, so neither metric is a claim of a clean |
| 77 | +package or completed global NRA coverage. |
| 78 | + |
| 79 | +## Native evidence |
| 80 | + |
| 81 | +The synthetic codec diagnostic imports only the worker's pinned dependency |
| 82 | +sources. The original completed run used CPython 3.14.6, NumPy 2.5.1, |
| 83 | +PolyStore 0.2.19, roifile 2026.2.10, ZMQRuntime 0.2.24, and numcodecs 0.17.0. |
| 84 | +Three cases: polygon control passed, two point cases failed. Runtime 0.39 s, |
| 85 | +peak RSS 53168 KiB. The canonical-metadata repeat had the same outcomes: |
| 86 | +0.28 s, peak RSS 51808 KiB. These are native codec diagnostics, not transport, |
| 87 | +installed OpenHCS, managed viewer or scientific acceptance. |
| 88 | + |
| 89 | +Receipt root: `/tmp/openhcs-pr153.LeLQct`. Original completed evidence: |
| 90 | +`scan-recovery-point-native-prerequisite-768.{json,stderr,guard}`. |
| 91 | +Canonical repeat: `scan-recovery-point-native-canonical-768.{json,stderr,guard}`. |
| 92 | +The earlier missing-numcodecs import failure remains separate and is not a |
| 93 | +codec failure. The canonical comparison derives logical metadata from public |
| 94 | +`roi_zip_metadata_payload` and JSON decoding; native coordinate checks are |
| 95 | +independent of tuple/list wire representation. |
| 96 | + |
| 97 | +- `PointImageJROIShapeConverter`, `src/polystore/roi_converters.py:547`, emits |
| 98 | + FREEHAND through `ImagejRoi.frompoints`, not POINT. The archive preserves |
| 99 | + exact XY `(3.5, 1.25)`, metadata label 7, object/source names, and zero-based |
| 100 | + `plane_indices=(2,)`. Native position/C/Z/T fields are all 0 (unset). |
| 101 | +- The writer's integer extents top/left/bottom/right are `(1,4,2,5)` while its |
| 102 | + subpixel XY coordinates remain exact. Do not treat rounded extents as loss |
| 103 | + of the subpixel coordinates or invent an image extent. |
| 104 | +- `load_rois_from_zip`, `src/polystore/roi.py:581`, maps non-POLYLINE shapes to |
| 105 | + PolygonShape. Both the production point archive and a standard synthetic |
| 106 | + POINT archive fail with `Polygon must have at least 3 vertices, got 1`. |
| 107 | +- The standard POINT fixture preserves exact XY and native one-based Z=3 |
| 108 | + (zero-based Z=2) through roifile before the PolyStore reader fails. |
| 109 | +- `DiskStorageBackend._save_rois`, `src/polystore/disk.py:814`, owns archive |
| 110 | + assembly and the existing per-member metadata. The polygon control passes |
| 111 | + exact native XY plus logical label/object/source/plane metadata identity. |
| 112 | + |
| 113 | +## Owner-level closure proposal |
| 114 | + |
| 115 | +Pattern leads: IMPL-4, an existing nominal family owns encoding while decoding |
| 116 | +is outside it; IMPL-2, external ROI enum cases are recovered in a consumer; |
| 117 | +BOUND-2, decoding should consume the existing shape/codec authority. These |
| 118 | +source-checked leads are not completed NRA claims. |
| 119 | + |
| 120 | +Extend the existing nominal ImageJ geometry/codec owners. Shared archive |
| 121 | +loading calls the owned decoding contract; leaf declarations own external |
| 122 | +ImageJ kind acceptance and geometry construction. Compose actual encode/decode |
| 123 | +capabilities through MI/MRO where needed. Derive any lookup from those |
| 124 | +declarations, never maintain a second shape roster, string dispatch ladder or |
| 125 | +OpenHCS-specific decoder. A typed carrier or relocation alone does not close |
| 126 | +the ownership gap. |
| 127 | + |
| 128 | +External ImageJ bytes and existing archive metadata remain the format |
| 129 | +authority. POINT encoding uses POINT, and decoding preserves exact YX and |
| 130 | +source/object/plane identity. Native Z/C/T projection requires declared axis |
| 131 | +meaning; generic leading plane indices are not automatically a Z axis. Reject |
| 132 | +ambiguous or malformed identity instead of guessing. Polygon, polyline and |
| 133 | +ellipse behaviour remain protected by the same family contract. |
| 134 | + |
| 135 | +Proposed production write scope: existing `src/polystore/roi.py`, |
| 136 | +`src/polystore/roi_converters.py`, and existing native codec tests. Change |
| 137 | +`src/polystore/disk.py` only if archive-owner closure genuinely requires it and |
| 138 | +coordinate the extension first. Production changes stay within the two recorded |
| 139 | +ROI owners; the disk/archive metadata owner is unchanged. |
| 140 | + |
| 141 | +New-case experiment: a supported geometry declares its own external kind and |
| 142 | +encode/decode behaviour once; neither the archive reader nor OpenHCS adds a |
| 143 | +dispatch branch. Guards exclude duplicate codec maps, silent polygon fallback, |
| 144 | +raw-string ladders and weakened validation. Unsupported geometry remains an |
| 145 | +explicit failure, not an alias. |
| 146 | + |
| 147 | +## Historical common audit gate and integration boundary |
| 148 | + |
| 149 | +The common complete-context audit retains OpenHCS plus all eight recorded |
| 150 | +dependency source roots and all 79 detectors. It is not complete. The first |
| 151 | +compact attempt exceeded 768 MiB; the all-root compact attempt stayed bounded |
| 152 | +but hit the 160-second deadline (`complete=false`). Required full/raw R1, |
| 153 | +omitted-detector coverage and source-export evidence remain unavailable. |
| 154 | +That earlier implementation hold is superseded by the user's delivery decision |
| 155 | +above; partial cache evidence is still not a complete global audit. |
| 156 | + |
| 157 | +The old complete-coverage hold no longer controls this native repair. No |
| 158 | +revision-checked NRA DSL transaction or completed behavior-equivalence proof |
| 159 | +is claimed for these authored codec additions. Native tests cover |
| 160 | +POINT/standard POINT, exact fractional YX, explicit native Z and sidecar plane |
| 161 | +identity, label/object/source, polygon/polyline/ellipse, malformed and unsupported |
| 162 | +types. Test shards are bounded to 60 seconds with CPU-only/offscreen settings |
| 163 | +where applicable and owned cache roots. |
| 164 | + |
| 165 | +This dependency worktree is independent of the common scan's pinned clone. |
| 166 | +The OpenHCS parent gitlink stays at the recorded base. Integration requires a |
| 167 | +validated/merged dependency PR and integration owner's recorded-SHA selection. |
| 168 | +User authorization permits locally validated checkpoints without waiting for |
| 169 | +optional hosted CI. Before claiming this fixes the blind-review workflow, |
| 170 | +integrate the dependency and verify the actual OpenHCS/MCP/viewer route on the |
| 171 | +isolated display. Counts and biological acceptance remain frozen/ambiguous. |
0 commit comments