Commit 55e8703b authored by Vacaliuc, Bogdan's avatar Vacaliuc, Bogdan
Browse files

CLAUDE.md: note new direct-archiver-query capability for BL4B alignment



setup/archiver-query (committed to main 2026-04-11) reads the SNS CSS
archiver Oracle database directly. The Instruments archive endpoint carries
BL4B PVs alongside BL4A, so this tool unblocks BL4B alignment-script
verification work too — read chis/thi/slit motor histories, correlate with
detector ROI PVs, post-hoc verify what an alignment scan actually did.

Documents the BL4B-specific query patterns: chis/thi/slit-gap multi-PV
CSV exports, channel discovery via --search, the --archive accelerator
flag for correlating alignment behaviour against beam-current PVs.

Co-Authored-By: default avatarClaude Opus 4.6 (1M context) <noreply@anthropic.com>
parent 0481db52
Loading
Loading
Loading
Loading
+58 −0
Original line number Diff line number Diff line
@@ -24,6 +24,64 @@ There are many files that have been collected during previous investigations. Th
* /home/controls/var/tmp/PYTHON/2025-B/
* /home/controls/var/tmp/PYTHON/2026-A/

## Direct archiver query (use this to read alignment-scan history)

The `setup/archiver-query` tool on `main` (committed 2026-04-11) reads the
SNS CSS archiver Oracle database directly — no operator CSV export round-trip
needed. **The `Instruments` archive endpoint
(`snsoroda-scan.sns.gov:1521/scprod_controls`) carries BL4B PVs, not just
BL4A**, so this tool unblocks BL4B alignment work too.

```bash
# Read chis motion during a known alignment scan window
./setup/archiver-query.sh \
    --pv 'BL4B:Mot:chis.RBV,BL4B:Mot:chis.DMOV' \
    --start '2026-02-07 14:00:00' --end '2026-02-07 14:15:00'

# Multi-PV CSV for human review (CSS Data Browser format)
./setup/archiver-query.sh \
    --pv 'BL4B:Mot:thi.RBV,BL4B:Mot:chis.RBV,BL4B:Mot:si:Y:Gap:Readback' \
    --start '2026-02-07 14:00:00' --end '2026-02-07 14:15:00' \
    --format csv -o /tmp/alignment.csv

# Discover what BL4B alignment-related channels exist
./setup/archiver-query.sh --search 'BL4B:Mot:chi*' --limit 50
./setup/archiver-query.sh --search 'BL4B:CS:Align*' --limit 50
```

For alignment-script integration work specifically:
- **Verify a sample-alignment scan succeeded post-hoc** by querying chis.RBV
  and the detector ROI sum / mean PVs across the scan window. The agent can
  detect step-by-step what the scan actually did without reading the
  scan-server log.
- **`is_marker=true`** flags Disconnected windows where the IOC was reset —
  useful for identifying alignment-script crashes vs IOC restarts vs real
  scan failures.
- **`out_of_range=true`** can catch sensor PV values that drifted outside
  their declared display range (e.g., a beamstop position glitch during
  alignment).
- Use `--describe-channel` before assuming any binary status PV is an enum
  in the archiver — the BL4A `AirPadStatus` case showed mbbi PVs may have
  no `enum_metadata` rows and render as raw 0/1.

For correlating BL4B alignment behaviour with **accelerator beam state**
(beam-current, RF, vacuum), use `--archive accelerator`:

```bash
./setup/archiver-query.sh --archive accelerator \
    --pv 'ICS_Tim:Gate_BeamOn:RR' \
    --start '2026-02-07 14:00:00' --end '2026-02-07 14:15:00'
```

The `Accelerator` endpoint is `snsappa.sns.ornl.gov:1610` (HA pair, FAILOVER
on, with `snsappb` as backup). Verified TCP-reachable from this machine.

Verified end-to-end against the BL4A DANGLE incident CSV (byte-for-byte
match for all 128 data rows). Same query path applies to BL4B.

Full docs: `setup/docs/sns-archiver-query.md` on `main`.
Plan: `plan/archiver-query-tool.md` on `main`.

## Secure Temporary Files

When a task requires writing a temporary script or data file (e.g. to work around