# NFT-LIM-01 — Jetson memory budget

**Task**: AZ-440_nft_lim_01_jetson_memory
**Name**: Steady-state memory ≤ 4.5 GB (Plan A) / ≤ 6.0 GB (Plan B); peak ≤ 5.0 GB / 6.5 GB; no OOM (AC-NEW-13)
**Description**: Implement NFT-LIM-01 — Tier-2 ONLY; 5 min Derkachi replay + 30 s warm-up; sample memory at 1 Hz from `/proc/<pid>/status` AND `tegrastats`; assert steady-state and peak budgets per Plan A / Plan B; no OOM kills observed.
**Complexity**: 3 points
**Dependencies**: AZ-406, AZ-407, AZ-444
**Component**: Blackbox Tests / Resource Limit (epic AZ-262)
**Tracker**: AZ-440
**Epic**: AZ-262 (E-BBT)

## Problem

Jetson Orin Nano Super has 8 GB RAM total; the SUT must operate within Plan A (4.5 GB) or Plan B (6.0 GB) budgets to leave headroom for OS + suite. AC-NEW-13 prescribes the budgets and Plan-A/Plan-B switching rules.

## Outcome

- pytest scenario at `e2e/tests/resource_limit/test_nft_lim_01_jetson_memory.py`. Tier-2 ONLY.
- 5 min Derkachi replay + 30 s warm-up.
- Per-second memory sample from (a) `/proc/<pid>/status` `VmRSS`, (b) `tegrastats` (system-level memory).
- Compute steady-state (post-warm-up p50) and peak (post-warm-up max).
- Assert `steady_state ≤ 4.5 GB` (Plan A default) AND `peak ≤ 5.0 GB`. Plan B (6.0 / 6.5 GB) gated behind `MEMORY_PLAN=B` flag.
- Assert no OOM kills in `dmesg` during the run.

## Scope

### Included
- `/proc/<pid>/status` + `tegrastats` sampling.
- Steady-state + peak computation.
- OOM detection in `dmesg`.

### Excluded
- FDR size budget — owned by NFT-LIM-02 (AZ-441).
- Tier-1 memory measurement — irrelevant (Docker on x86 has different budgets).

## Acceptance Criteria

**AC-1: tier guard**
Given `tier == tier1-docker`
Then the test SKIPs.

**AC-2: steady-state budget (Plan A)**
Given the post-warm-up samples
Then `p50(VmRSS) ≤ 4.5 GB` AND `p50(tegrastats system memory) ≤ 4.5 GB`.

**AC-3: peak budget (Plan A)**
Given the same samples
Then `max(VmRSS) ≤ 5.0 GB`.

**AC-4: no OOM kills**
Given `dmesg --since "<run_start>"`
Then no entries match `oom-killer` or `Killed process .*gps-denied-onboard`.

**AC-5: Plan B gated**
Given `MEMORY_PLAN=B` env flag
Then the budgets relax to `steady ≤ 6.0 GB` AND `peak ≤ 6.5 GB`.

**AC-6: parameterization**
Given conftest parameterization
Then the scenario runs per `(fc_adapter, vio_strategy)`.

## System Under Test Boundary

End-to-end on real hardware through public boundaries.

- **Allowed**: `/proc`, `tegrastats` (public OS / NVIDIA telemetry), `dmesg`.
- **Forbidden**: instrumenting SUT internal allocators.

## Constraints

- Tier-2 only.
- Plan A / Plan B switching is per the SUT's documented config; the test does NOT trigger the switch — it observes and reports the active plan.

## Document Dependencies

- `_docs/02_document/tests/resource-limit-tests.md` § NFT-LIM-01
- `_docs/02_document/tests/test-data.md` § Resource Limits (NFT-LIM-01 row)
