Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .agents/skills/oscar-contributor-scale-guardrails/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Use this skill before proposing, implementing, or reviewing changes in [`ORNL/os
- Never persist unbounded `>= 1 Hz` telemetry (`gammaCounts`, `neutronCounts`, `LiveDriverLocationOutput`, RS-350/D5 `ForegroundOutput` / `BackgroundOutput`, `connectionStatus`) permanently in `ONLY oscar.obs`.
- If adding a new datastream, verify `OscarTieredObsStore` (`osh-addons`), `DatabasePurger` (`osh-oakridge-modules`), and `dist/config/standard/config.json` (`archive.outputNames`, if cold-archived) in lockstep.
- Never add growing B-tree/GIN SQL indexes or raw `?` JSONB operators in JDBC `PreparedStatement` queries (`use jsonb_typeof(col->'key')`).
- **CQL <-> Summary Counter Lockstep (`StatisticsOutput` / `ReportDataAggregator`):** Every CQL predicate queried over high-volume telemetry (`gammaCounts`, `neutronCounts`, `occupancyStatus`, `alarm`) must resolve to an exact `JsonCqlEvaluator.SummaryCounterSpec` backed by `oscar_archive_schema` (`26` counters) and `ArchiveCompactionManager.StreamStatsAccumulator`, locked by `TestArchiveLifecycleInvariants.statisticsAndReportCqlQueriesMapToExactSummaryCountersAndV2Masks`. Any newly added nullable summary column must use `COALESCE(s.<col>, COALESCE(s.row_count, 0))` for `upperBoundExpr` (preventing false zero-match pruning before backfill), guard `exactReadyExpr` with `IS NOT NULL`, zero-fill ineligible streams via `oscar_archive_schema_blob` subqueries, backfill eligible files via background DuckDB `read_parquet(..., filename=true, union_by_name=true)` registered in `DuckDbResourcePolicy.AdmissionController.isBackgroundCountOperation`, and version new `base_summary_mask` bits behind `JsonCqlEvaluator.BIT_MASK_V2`.
- **Split-at-Export, 10-Year Catalog Pruning & Bounded DuckDB Writes:** Route only the 9 searchable event/summary streams to `RAW_EVENTS` / `DAILY_EVENTS` / `MONTHLY_EVENTS` (never compact high-rate `RAW_TELEMETRY`, and keep `ocr_bloom = NULL` on `RAW_TELEMETRY`). Always keep `s.generation_id = ANY (?::uuid[])` chunked at `2,048` UUIDs in `ArchiveCatalog` summary queries (never omit `generation_id` filtering when `candidates.size() > 64`), prune pure event-stream queries via `EVENT_QUERY_PROFILES` (`oscar_archive_generation_time_idx`), slice plain unfiltered `?limit=N` queries by `row_count`, and keep `oscar_archive_schema` nightly reindex bloat-gated (`< 256 MiB` OR `>= 50,000` dead tuples OR `>= 10%` dead ratio). Always use `DuckDbResourcePolicy.openFileBacked(...)` + native `DuckDBAppender` for large writes, `union_by_name=true` for multi-generation reads, and `ArchiveExporter.stageToLocalDirectory` (16 KiB bounded reads) whenever `ParquetArchiveReader.isPathOn9pMount(...)` is true on Windows 11 + WSL 2 `9p` mounts so DuckDB never hits `ENOMEM`.
- **Graceful Durable-Publish Teardown (`SlidingOccupancyQuery`):** Never call `shutdownNow()` while a retention worker is inside NIO `FileChannel.lock()`/`force()` durable media publication; signal `stopRequested = true` + `stopping.shutdown()` during `inDurableAction` and wait a bounded grace window in `awaitStop(...)` before forcing interruption.
2. **DuckDB `2`-Session Cap, Mandatory `try-with-resources` Stream Closure & Time-Bounded ConSys Queries:**
- Never trigger background timers or per-lane `searchObservations` fan-out that scan cold Parquet generations.
- Always wrap every Java `IObsStore.select(...)`, `selectKeys(...)`, and `selectEntries(...)` (plus `ISystemDescStore.select*`) stream in `try-with-resources`, and pass `.withLimit(1)` on single-record `ObsFilter.Builder` lookups (`findFirst()`, `withLatestResult()`, exact-timestamp correlation).
Expand All @@ -31,10 +34,12 @@ Use this skill before proposing, implementing, or reviewing changes in [`ORNL/os
- Store and cancel all `EventBus` `Subscription` handles in `doStop()`, and start `initAsync = true` (`INITIALIZING -> INITIALIZED`) occupancy modules off the EventBus thread via `OccupancyProcessStarter`.

## Step 3 — Verify Viewer Safety, Routes & Localization
1. Keep all 8 canonical routes (`/`, `/map`, `/event-log`, `/lane-view`, `/report-view`, `/health`, `/servers`, `/users`) and `data-testid` attributes intact; propagate `?view=<scope>` via `scopedHref`.
1. Keep all 8 canonical routes (`/`, `/map/`, `/event-log/`, `/lane-view/`, `/report/`, `/health/`, `/servers/`, `/users/`) and `data-testid` attributes intact; propagate `?view=<scope>` and trailing slashes (`trailingSlash: true`) via `scopedHref` / `ensureTrailingSlashRoute` so Next.js static RSC navigation (`<route>/index.txt`) never triggers MPA document reloads.
2. Keep `<AlarmAudio />` mounted once in `web/oscar-viewer/src/app/Providers.tsx` (never per-widget).
3. Maintain 4-locale parity (`en`, `es`, `fr`, `el`) across `ConfigMessages*.properties`, `README{,_es,_fr,_el}.md`, and `web/oscar-viewer/src/locales/*.json`.
4. Scrub all private RFC1918 IPs, internal `.local` hostnames, `.DS_Store`, and credentials.
4. Never list raw Redux `laneMap` (`selectLaneMap`) directly in the dependency array of a React `useEffect` that issues HTTP `fetch` / ConSys / `vehicle-search` requests; on 50-lane portals `laneMap` is cloned dozens of times during datastream/schema hydration, causing `HTTP 499` abort storms and cold-archive permit contention. Store `laneMap` in a `useRef` (`laneMapRef.current = laneMap`) and depend on a memoized scalar topology or stream-ID key instead.
5. Never add unbounded full-table `UPDATE oscar_archive_schema` or multi-generation DuckDB scans synchronously inside `ArchiveCatalog.migrate()` or `OscarTieredObsStore` startup (`ModuleRegistry.loadAllModules` enforces a hard `60 s` datastore startup timeout); gate inline backfills to `<= 64` generations and drain larger upgrades newest-first in bounded committed batches on `oscar-base-summary-backfill` (`backfillPendingSchemaUpgradeColumnsBatch`).
6. Scrub all private RFC1918 IPs, internal `.local` hostnames, `.DS_Store`, and credentials.

## Step 4 — Run Mandatory Local Checks & Full Release Regression Gate
```bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'v*'

env:
RELEASE_VERSION: '3.11.15'
RELEASE_VERSION: '3.12.0'
JAVA_VERSION: '21'
NODE_VERSION: '22'
OSCAR_DIR: 'web/oscar-viewer'
Expand Down
15 changes: 9 additions & 6 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Workspace skills for AI agents are also checked into [`.agents/skills/`](.agents
| [`ORNL/osh-oakridge-modules`](https://github.com/ORNL/osh-oakridge-modules) | `include/osh-oakridge-modules` | `main` | `LaneSystem`, Rapiscan/Aspect/RS-350/D5 drivers, EML, OCR, Cargo UFF, BasicSession auth, Vaadin Admin | [`include/osh-oakridge-modules/AGENTS.md`](https://github.com/ORNL/osh-oakridge-modules/blob/main/AGENTS.md) |
| [`ORNL/oscar-viewer`](https://github.com/ORNL/oscar-viewer) | `web/oscar-viewer` | `main` | Next.js / React / TypeScript operator console (`/` Dashboard, `/event-log`, `/lane-view`, `/map`, `/health`, `/report-view`, `/servers`, `/users`) | [`web/oscar-viewer/AGENTS.md`](https://github.com/ORNL/oscar-viewer/blob/main/AGENTS.md) |
| [`ORNL/osh-js`](https://github.com/ORNL/osh-js) | *(npm dependency in `web/oscar-viewer`)* | `add-consys` | Connected Systems REST / MQTT / WebSocket client SDK | — |
| [`ORNL/oscar-video-guides`](https://github.com/ORNL/oscar-video-guides) | *(bundled at build time into `/video-guides/`)* | `main` | `29` localized (`en`, `es`, `fr`, `el`) `< 2 min` MP4 workflow guides + WebVTT/SRT captions | — |
| [`ORNL/oscar-regression`](https://github.com/ORNL/oscar-regression) | *(standalone Playwright + TypeScript E2E suite)* | `main` | `25` end-to-end functional, storage-lifecycle, fault/alarm injection, OCR, UFF, and sandbox scenarios | — |
| [`ORNL/oscar-video-guides`](https://github.com/ORNL/oscar-video-guides) | *(bundled at build time into `/video-guides/`)* | `main` | `33` localized (`en`, `es`, `fr`, `el`) `< 2 min` MP4 workflow guides + WebVTT/SRT captions | — |
| [`ORNL/oscar-regression`](https://github.com/ORNL/oscar-regression) | *(standalone Playwright + TypeScript E2E suite)* | `main` | `27` end-to-end functional, storage-lifecycle, fault/alarm injection, OCR, UFF, sandbox, and multi-node federation scenarios | — |
| [`ORNL/oscar-federation-hub`](https://github.com/ORNL/oscar-federation-hub) | *(standalone hub deployment)* | `main` | Multi-site Zero-Trust federation & tunnel gateway | — |

---
Expand Down Expand Up @@ -54,11 +54,14 @@ Workspace skills for AI agents are also checked into [`.agents/skills/`](.agents

OSCAR is certified for **continuous 24/7 multi-year operation at 50-lane scale** (`50` RPMs + `50–100` RTSP cameras + continuous EML/OCR/UFF activity). Every change **must** uphold all 8 invariants below:

1. **Constant Hot PostgreSQL Footprint (`PARQUET_PRIMARY`) & Zero Growing SQL Indexes:**
- All 22 operational and evidentiary datastreams (`gammaCounts`, `gammaThreshold`, `neutronCounts`, `setupGamma`, `setupNeutron`, `speed`, `backgroundReport`, `foregroundReport`, `status`, `emlContextual`, `emlScanContextual`, `emlAnalysis`, `dailyFile`, `connectionStatus`, `occupancyStatus`, `tamper`, `occupancy`, `adjudication`, `report`, `siteStatistics`, `nationalSummary`, `vehicleOcr`) route into 30-minute PostgreSQL stage partitions (`osg_*`) that retire to Zstandard Parquet after SHA-256 parity (`ONLY oscar.obs` stays permanently near-empty at `~52` static singleton rows).
1. **Constant Hot PostgreSQL Footprint (`PARQUET_PRIMARY`), Split-at-Export + Event-Only Multi-Tier Parquet V2 Compaction & Zero Growing SQL Indexes:**
- All 26 operational, mobile, and evidentiary datastreams (`gammaCounts`, `gammaThreshold`, `neutronCounts`, `setupGamma`, `setupNeutron`, `speed`, `backgroundReport`, `foregroundReport`, `status`, `emlContextual`, `emlScanContextual`, `emlAnalysis`, `dailyFile`, `connectionStatus`, `occupancyStatus`, `tamper`, `occupancy`, `adjudication`, `report`, `siteStatistics`, `nationalSummary`, `vehicleOcr`, `location`, `alarm`, `KromekDetectorRadiometricsV1Report`, `KromekSerialRadiometricStatusReport`) route into 30-minute PostgreSQL stage partitions (`osg_*`) that retire after SHA-256 parity (`ONLY oscar.obs` stays permanently near-empty at `~52` static singleton rows).
- `ArchiveExporter` splits each closed 30-minute `PARQUET_PRIMARY` window directly via file-backed DuckDB + native `DuckDBAppender` into two strictly complementary Parquet V2 profiles: **`RAW_EVENTS`** (the 9 searchable event/summary streams `occupancy`, `alarm`, `adjudication`, `report`, `vehicleOcr`, `emlAnalysis`, `tamper`, `siteStatistics`, `nationalSummary`, `~1.23%` of rows, 20 columns with 9 pre-extracted projected scalar columns, `ROW_GROUP_SIZE = 8192`, Split-Block Bloom filters at `0.01` FPR, and selective `ocr_bloom`) and write-once **`RAW_TELEMETRY`** (all 17 remaining high-rate `1 Hz` telemetry/status streams including `dailyFile`, `connectionStatus`, `occupancyStatus`, `~98.77%` of rows, 11 base columns, `ROW_GROUP_SIZE = 65536`, `128 MiB` uncompressed cap, `ocr_bloom = NULL`, **`1.0x` write amplification, never rewritten**).
- `ArchiveCompactionManager` compacts **only the event tier** (`RAW_EVENTS -> DAILY_EVENTS` at Day-1 with `window_end <= now - 2h` & `activated_at <= now - 2h`, folding settled overlays `>= 2h`; `DAILY_EVENTS -> MONTHLY_EVENTS` at Month+15d with `activated_at <= now - 7d`, plus independent per-part monthly overlay defrag for `>= 64` settled overlays `>= 7d`), enforces explicit rollover ceilings (`1,000,000` rows / `192 MiB` uncompressed with strictly disjoint `[window_start, window_end)` cuts and chunk-spilled `ScratchDirectory` streaming), preserves a `15m` `DELETING` file-unlink grace window, and self-heals stale `>= 2h` unregistered `.partial` artifacts during `drainDeletingGenerations`. Legacy `RAW_GATED` and pre-split `DAILY_TELEMETRY` generations remain read-only compatible without upgrade rewrite storms.
- **Never** add growing B-tree or GIN indexes over unbounded historical observations (`docs/STORAGE_ARCHITECTURE.md`), and **never** use raw `?` JSONB operators inside JDBC `PreparedStatement` SQL (use `jsonb_typeof(col->'key')`).
2. **Bounded DuckDB Cold-Tier Concurrency (`max 2` sessions per JVM) & Mandatory `try-with-resources` Stream Closure:**
- `DuckDbResourcePolicy` caps concurrent Parquet queries at `2` sessions (`30 s` timeout). **Never** introduce background UI timers, per-lane `searchObservations` loops, or premature bucket-count fan-out that open cold Parquet scans without an explicit user filter/sort action.
- **CQL <-> Summary Counter Lockstep, Non-Blocking Upgrades & 10-Year Scale Guardrails:** Every CQL predicate executed by `StatisticsOutput`, `ReportDataAggregator` (`Utils.java`), or Viewer `StatusTable` (`tamperStatus=true OR alarmState='Fault - ...'`) across high-rate telemetry/alarm streams must map to an exact `JsonCqlEvaluator.SummaryCounterSpec` (verified by `TestArchiveLifecycleInvariants.statisticsAndReportCqlQueriesMapToExactSummaryCountersAndV2Masks`) backed by `oscar_archive_schema` (`26` counters) and `ArchiveCompactionManager.StreamStatsAccumulator`. New nullable summary columns must use `COALESCE(s.<col>, COALESCE(s.row_count, 0))` for `upperBoundExpr` (never `COALESCE(s.<col>, 0)`), guard `exactReadyExpr` on `IS NOT NULL`, and version any new `base_summary_mask` bits behind `JsonCqlEvaluator.BIT_MASK_V2` (`1 << 30`). Because `ModuleRegistry.loadAllModules` enforces a hard `60 s` datastore startup timeout, **never** run unbounded full-table `UPDATE oscar_archive_schema` or multi-file DuckDB backfills synchronously inside `ArchiveCatalog.migrate()` or `OscarTieredObsStore` startup: gate inline backfills to `<= 64` generations and drain larger upgrades newest-first in bounded committed batches on `oscar-base-summary-backfill` (`backfillPendingSchemaUpgradeColumnsBatch(128)` + DuckDB `backfillExtendedSummaryCountersBatch` under `isBackgroundCountOperation`), latching completed phases so steady-state ticks execute zero scans. Summary queries **must** always keep `s.generation_id = ANY (?::uuid[])` chunked in `2,048`-UUID batches (never omit generation filtering for `> 64` generations), pure event queries prune via `EVENT_QUERY_PROFILES` (`oscar_archive_generation_time_idx`), plain bounded queries (`?limit=N`) slice `candidatesInitialClusters` by `row_count`, and nightly `oscar_archive_schema` reindexing is bloat-gated above `256 MiB` (`>= 50,000` dead tuples or `>= 10%` dead ratio).
2. **Bounded DuckDB Cold-Tier Concurrency (`max 2` sessions per JVM, Anti-Starvation Aging) & Mandatory `try-with-resources` Stream Closure:**
- `DuckDbResourcePolicy` caps concurrent Parquet queries at `2` sessions (`30 s` timeout, `5 s` anti-starvation aging, `parquet_metadata_cache=true`), `ParquetArchiveReader` slices wide overlapping clusters into `<= 16`-file sub-window batches (`sliceWideCluster`), and `VehicleIncidentAggregator` bounds `OcrSearchCacheSlot` to a rolling `30-day` hot window (merging pre-hot cold observations via CQL2 pushdown and skipping empty-`vehicleId` EML `Code 9999` commands). **Never** introduce background UI timers, per-lane `searchObservations` loops, or premature bucket-count fan-out that open cold Parquet scans without an explicit user filter/sort action.
- **Always** wrap every Java `IObsStore.select(...)`, `selectKeys(...)`, and `selectEntries(...)` (plus `ISystemDescStore.select*`) stream in `try-with-resources`, and pass `.withLimit(1)` on single-record `ObsFilter.Builder` lookups (`findFirst()`, `withLatestResult()`, exact-timestamp correlation) so tiered PostgreSQL/DuckDB cursors close deterministically on both hit and miss.
- Always bound routine ConSys observation lookups by narrow time windows (`phenomenonTime` on `/sensorhub/api/observations`, or `resultTime` when calling `osh-js` `DataStream.searchObservations`, which strips `phenomenonTime`).
3. **Zero Per-Tick SWE `DataComponent.copy()` Tree Cloning on `>= 1 Hz` Drivers:**
Expand Down
Loading
Loading