PAS DEFT Workflow
Standalone install? If this session was not initialized by the TAO skill
bank plugin, run the tao-setup skill first for host preflight, credential
checks, and cross-skill discovery.
Run the canonical PAS flow as one resumable, disk-backed workflow. All PAS
workflow logic, templates, and host adapters ship with this skill; customers do
not need a separate source checkout. The bundled scripts make stage calls
deterministic without adding another orchestration layer.
This skill supports every packaged TAO execution platform: Docker, SLURM,
Kubernetes, Brev, and virtualenv. The workflow produces a platform-neutral,
schema-validated action bundle; the selected platform skill owns native
submit/status/logs/cancel and the job-record.
Virtualenv execution uses separate immutable pyt and ds runtime profiles;
the workspace control .venv is not an execution runtime.
Entry Contract
tao-deft-pas and tao-run-deft-pas select this same workflow. If the user
did not choose a platform, ask once among Docker, SLURM, Kubernetes, Brev, and
virtualenv; never default to Docker. On resume, the immutable platform in
deft_state.json is already the selection and must not be changed.
Use two intake phases:
Perform only bounded, lightweight path discovery. Two explicit archive file
paths win and suppress all archive searching. An explicit archive directory
is treated as one approved search root. Otherwise, resolve the conventional
~/workspace and use only these deduplicated search roots: ~/pas, the
workspace root, and its pas/, input/, and inputs/ children. Check the
workspace root itself only; beneath each other search root, inspect the root
and directories at most two levels below it. This AOI-style bounded-subtree
lookup supports nested export/drop directories without turning into a home
or repository scan. Never follow symlinks or add the current checkout,
source repositories, tutorial/notebook trees, or workspace dataset-output
trees as implicit search roots.
An archive candidate contains direct regular-file children
images_raw.tar and meta.tar.gz; the workflow needs one such pair, not
multiple dataset directories. Follow the classification and provenance
format in references/preflight.md so the user sees every search root, its
reason and depth bound, the directory in which a pair was found, and whether
it is archive-only or mixed with extracted data.
Enumerate run-state files only at
<workspace>/results/run_*/deft_state.json. Read the minimal identity fields
and present a resume candidate only when workflow is exactly
tao-run-deft-pas; never offer AOI or unidentified DEFT state as PAS.
Do not validate large archives to EOF or inspect platforms, images, GPUs, or
credentials yet.
If max_iterations or a time budget is absent, ask one consolidated
question for that required value and any genuinely ambiguous path/run
choice. State the documented defaults and that a complete read-only
preflight plus approval summary follows. Do not ask whether the user wants
optional KPI, authentication, or parameter overrides; apply their defaults
unless the prompt already supplies an override.
After required intake is resolved, discover and validate:
- workspace and either a new
${RESULTS_DIR} or one existing run to resume;
images_raw.tar and meta.tar.gz; SHA256SUMS is optional;
max_iterations, or a user-supplied time budget from which an iteration
limit can be estimated;
- metric name, query type, operator, and optional target;
- whether the deployment requires authenticated Hugging Face model access;
- selected TAO execution platform and its platform-specific prerequisites;
- any explicit epoch, GPU, mining, continual-learning, or visualization
overrides.
For a new run, RESULTS_DIR must be a child of WORKSPACE. DATASET_ROOT
must be below a workspace data directory (for example
$WORKSPACE/data/pas_v31_tao_ft), not directly below the workspace; neither
path may contain the other. All approved paths are absolute and non-symlink.
Never replace an explicit value with a heuristic. Defaults apply only to
unspecified values and must be identified as defaults in the pre-flight
summary. max_iterations has no default. An absent metric target means an
ungated run that stops after max_iterations. Hugging Face token forwarding
defaults to disabled because the bundled model is public.
The authoritative parameter contract is the nested dataclass schema in
scripts/pas_deft/config.py, adapted from the PAS reference notebook. Read
that schema when a request needs the meaning, default, numeric bounds, or valid
options of a DEFT parameter. Do not infer an undocumented field or bypass its
metadata constraint. Config preparation, initialization, audit, and every
host-side stage validate the materialized bundle through that same schema;
the pas YAML section is validated through the typed PAS configuration model.
If required information remains missing after full discovery, ask one
consolidated follow-up. A normal invocation should need no knowledge of stage
modules, container mounts, state files, or bundled-runtime function
signatures.
Safety Gate
Perform only read-only discovery before approval: resolve paths, inspect file
metadata and archives, check process-environment variable presence, inspect
local images, inspect GPUs, and audit an existing run. Credentials come only
from the launching process environment; never open or source a credential file,
and never print, grep, copy, or echo a credential value. If a required variable
is absent, tell the user which name
to export in the shell that launches the agent; never ask for its value in
chat. Do not inspect credential-file metadata when no credential is needed. If
the user explicitly asks for a file-permission check, stat only that named
file and warn about group/other readability.
Show the summary defined in references/preflight.md, including every
parameter and source, planned file creation/extraction, image pulls, estimated
runtime, and resume status. Wait for explicit approval before registry login or
pulls, platform submit, package installation, archive extraction, config/state
creation, or any write under the workspace.
If an approved parameter later changes, show the changed summary rows and get
approval again before continuing. No confirmation is needed between unchanged,
already-approved stages.
Execution Contract
After approval, follow references/preflight.md to prepare the runtime,
materialize the immutable run config, and initialize state once. Never
reinitialize an existing run.
Before every stage, after context compaction, and before any completion
claim, run:
"$SKILL_ROOT/scripts/deft_python.sh" --workspace "$WORKSPACE" --runtime \
"$SKILL_ROOT/scripts/audit_deft_run.py" --results-dir "$RESULTS_DIR"
Continue only when the audit reports IN_PROGRESS and its next_action
matches the intended stage. For INVALID, stop launching work and report
the listed inconsistency. For nonterminal FAILED whose next_action is
loop_stop, follow the pipeline reference and commit hard_stop; for
terminal FAILED, report the failure and launch no more work. For
COMPLETE, do not rerun a stage.
Read only the current stage reference named by read_before_action. Use
run_pas_stage.py for bundled PAS host stages. For every TAO action, use
run_deft_action.py prepare, reconcile any interrupted launch, bind the
exact request-owned job-record before native submit, dispatch the emitted
bundle through the selected platform's four verbs, synchronize remote
outputs, capture native logs, then use run_deft_action.py finalize. Follow
references/platform-execution.md; never assemble an untracked launch.
A command succeeds only when its exit status is zero and its documented
output checks pass. Capture verbose output at the action-owned log path;
inspect the final error block or at most the last 40 lines.
Commit each successful or terminally failed stage exactly once with
commit_stage.py. It validates artifact structure, freshness, iteration
scope, command evidence, leakage, and transition order before applying a
recoverable, journaled update to deft_state.json and loop_log.jsonl.
Never call
log_stage.py or record_metric_result.py directly, and never hand-edit
canonical state, log, metric, or history files.
Render the HTML report with render_deft_report.py. Reporting is a
deterministic read of audited state; it does not require another agent.
Keep the driving turn attached through the complete bounded loop. After a
stage reaches terminal status, finalize/commit it, re-audit, and immediately
continue with the audit-selected next action. An in-progress update is
commentary, not a final response and not a detach point.
All recorded artifact paths are absolute host paths under ${RESULTS_DIR}.
Baseline artifacts live under zs/, iteration N under iter_N/, and run-wide
splits, source embeddings, and history files at the run root.
Workflow
The normal path is linear, with only two meaningful decisions:
pre-flight approval
-> dataset_setup -> pool_embed -> baseline evaluate
-> KPI met? yes: loop_stop
no: baseline gap_analysis
-> for N = 1..max_iterations:
data_mining -> history_select -> visualize -> train -> evaluate
-> KPI met? yes: loop_stop
no and N < max: gap_analysis -> next iteration
no and N = max: loop_stop
-> final audit -> HTML report
Stage ownership and exact commands are in
references/scripts-and-agents.md. Read the detailed reference only when its
stage is next:
| Stage |
Reference |
Required result |
| dataset setup |
references/data-layout.md |
verified rebuilt dataset, transparent layout report, five split files, non-empty source-pool parquet |
| pool embedding and mining |
references/mining.md |
fresh command evidence plus non-empty, schema-checked parquet outputs |
| evaluate and train |
references/clip-train-eval.md, references/metric-contract.md |
successful TAO status, bound metric evidence; for train, a fresh best and normalized checkpoint |
| gap analysis |
references/gap-analysis.md |
non-empty iteration-scoped gaps parquet |
| history selection |
references/mining.md |
budgeted mined set, cumulative/history entry, zero eval leakage |
| visualization |
references/visualization.md |
enabled artifacts and command evidence, or a config-authorized skip |
visualize is the only optional stage. Commit it with --skip only when both
visualization settings are false in the approved config. Do not turn off a
failing visualization mid-run without revising and reapproving the config.
Loop and Recovery Rules
- The loop is bounded by
max_iterations; never create an iteration outside
that range. Once the KPI passes, the only legal next transition is
loop_stop. Do not mine or train again.
- Monitoring defaults to attached (
long_running_enabled=true, five-minute
updates). Use terminal-condition polling: retain the selected platform's job
id and poll its native status no more often than every 30 seconds, continuing
through finalize, commit, audit, and the next stage.
The bounded workflow's terminal audit status is the end condition, so this is
not open-ended polling.
- Never send a final response while an approved run is nonterminal. A final
response ends chat-side execution and nothing can wake it automatically.
Finalize the turn only after the audit reports
COMPLETE, terminal FAILED,
or INVALID, or when the user explicitly asks to stop or detach. If the
runtime genuinely cannot keep a turn alive, say so before launch and provide
the exact durable resume audit command; do not claim unattended monitoring.
- Never repeat an unchanged failed command speculatively. Classify the failure,
inspect its final log block, make one evidence-based correction permitted by
the stage reference, then retry once. Stable command status records persist
attempt 1/2, and the wrappers refuse a third attempt after context loss. The
audit must pass before advancing.
- A transient registry/network interruption or GPU contention may be retried
once after evidence shows the condition changed. A second equivalent failure
is terminal for the run.
- Never retry checksum or rebuild verification failure, zero-row mining,
schema/cardinality failure, missing eval-split evidence, eval leakage,
history conflict that fails documented resume, metric-contract mismatch,
stale/cross-iteration output, or an unsupported GPU architecture. Commit an
error when state permits and stop with the exact recovery action.
- If a command wrote outputs but crashed before stage commit, run the audit.
Reuse outputs only when their command status is successful, fresh, correctly
scoped, and all stage validators pass. History selection has one supported
recovery: rerun the deterministic adapter with
--resume; never delete or
edit a history entry by hand.
- Manual modification or truncation of
deft_state.json or loop_log.jsonl
invalidates the run. Preserve it for diagnosis and start a new results
directory.
Metric and Stop Semantics
The approved metric contract is immutable for the run. Evaluation must parse
the exact iteration's nvidia_pas_metrics_aggregate.csv; the result records
its source path and is re-derived during commit and audit. Checkpoint ranking
and best-run reporting follow the approved operator (>=/> chooses the
higher value, <=/< the lower), not a hard-coded metric convention.
Successful completion is exactly one of:
loop_stop(reason=kpi_met) after a bound evaluation satisfies its target;
loop_stop(reason=max_iterations) after the final allowed evaluation when
the target is unmet or absent.
hard_stop is a failed terminal outcome, not successful completion.
Completion
At a normal loop boundary:
commit loop_stop with the audit-selected reason;
render ${RESULTS_DIR}/DEFT_Loop_Report.html with trigger loop-end;
require this command to exit zero:
"$SKILL_ROOT/scripts/deft_python.sh" --workspace "$WORKSPACE" --runtime \
"$SKILL_ROOT/scripts/audit_deft_run.py" \
--results-dir "$RESULTS_DIR" --require-complete
Report the stop reason, baseline and best metric, best iteration/checkpoint,
completed iteration count, report path, and any warnings. A checkpoint, CSV,
HTML file, or assistant statement alone is not completion evidence.
Progressive References
| Need |
Read |
| read-only checks, approval summary, initialization |
references/preflight.md |
| stage commands and script interfaces |
references/scripts-and-agents.md |
| platform staging, four verbs, job records, finalization |
references/platform-execution.md |
| state transitions and resume behavior |
references/pipeline-and-state.md |
| dataset/archive contract |
references/data-layout.md |
| KPI parsing and evidence |
references/metric-contract.md |
| gap generation |
references/gap-analysis.md |
| embeddings, k-NN, selection |
references/mining.md |
| contact sheets and t-SNE |
references/visualization.md |
| train/evaluate/checkpoints |
references/clip-train-eval.md |
1---2name: tao-run-deft-pas3description: >4 Run iterative improvement for NVIDIA TAO CLIP / SigLIP image-text retrieval5 on attribute-labelled data. Use when a request combines retrieval evaluation,6 weak-attribute or caption-pair mining, repeated retraining, and a stopping7 condition based on a retrieval KPI, validation plateau, or iteration budget;8 the customer need not know the DEFT or People Attribute Search (PAS)9 names. The self-contained workflow performs dataset preparation, zero-shot10 evaluation, attribute gap analysis, caption-space k-NN mining, history-aware11 selection, retraining, and re-evaluation. Treat12 `tao-deft-pas` as shorthand for this canonical `tao-run-deft-pas` workflow.13 Do not use for standalone CLIP training, one-off evaluation or embedding,14 generic k-NN mining, or AOI/ChangeNet DEFT workflows.15license: Apache-2.0 AND CC-BY-4.016compatibility: Requires one supported TAO execution platform (Docker, SLURM, Kubernetes, Brev, or virtualenv), accessible NVIDIA GPUs, the two PAS dataset export archives, and Python 3.9+ for control; virtualenv execution additionally requires the documented CPython 3.12 pyt and ds profiles.17metadata:18 author: NVIDIA Corporation19 version: "0.4.0"20allowed-tools: Read Bash Write21tags:22- application23- workflow24- deft25- pas26- clip27- retrieval28- loop29---3031# PAS DEFT Workflow3233> **Standalone install?** If this session was not initialized by the TAO skill34> bank plugin, run the `tao-setup` skill first for host preflight, credential35> checks, and cross-skill discovery.3637Run the canonical PAS flow as one resumable, disk-backed workflow. All PAS38workflow logic, templates, and host adapters ship with this skill; customers do39not need a separate source checkout. The bundled scripts make stage calls40deterministic without adding another orchestration layer.4142This skill supports every packaged TAO execution platform: Docker, SLURM,43Kubernetes, Brev, and virtualenv. The workflow produces a platform-neutral,44schema-validated action bundle; the selected platform skill owns native45`submit`/`status`/`logs`/`cancel` and the job-record.46Virtualenv execution uses separate immutable `pyt` and `ds` runtime profiles;47the workspace control `.venv` is not an execution runtime.4849## Entry Contract5051`tao-deft-pas` and `tao-run-deft-pas` select this same workflow. If the user52did not choose a platform, ask once among Docker, SLURM, Kubernetes, Brev, and53virtualenv; never default to Docker. On resume, the immutable platform in54`deft_state.json` is already the selection and must not be changed.5556Use two intake phases:57581. Perform only bounded, lightweight path discovery. Two explicit archive file59 paths win and suppress all archive searching. An explicit archive directory60 is treated as one approved search root. Otherwise, resolve the conventional61 `~/workspace` and use only these deduplicated search roots: `~/pas`, the62 workspace root, and its `pas/`, `input/`, and `inputs/` children. Check the63 workspace root itself only; beneath each other search root, inspect the root64 and directories at most two levels below it. This AOI-style bounded-subtree65 lookup supports nested export/drop directories without turning into a home66 or repository scan. Never follow symlinks or add the current checkout,67 source repositories, tutorial/notebook trees, or workspace dataset-output68 trees as implicit search roots.6970 An archive candidate contains direct regular-file children71 `images_raw.tar` and `meta.tar.gz`; the workflow needs one such pair, not72 multiple dataset directories. Follow the classification and provenance73 format in `references/preflight.md` so the user sees every search root, its74 reason and depth bound, the directory in which a pair was found, and whether75 it is archive-only or mixed with extracted data.7677 Enumerate run-state files only at78 `<workspace>/results/run_*/deft_state.json`. Read the minimal identity fields79 and present a resume candidate only when `workflow` is exactly80 `tao-run-deft-pas`; never offer AOI or unidentified DEFT state as PAS.81 Do not validate large archives to EOF or inspect platforms, images, GPUs, or82 credentials yet.832. If `max_iterations` or a time budget is absent, ask one consolidated84 question for that required value and any genuinely ambiguous path/run85 choice. State the documented defaults and that a complete read-only86 preflight plus approval summary follows. Do not ask whether the user wants87 optional KPI, authentication, or parameter overrides; apply their defaults88 unless the prompt already supplies an override.8990After required intake is resolved, discover and validate:9192- workspace and either a new `${RESULTS_DIR}` or one existing run to resume;93- `images_raw.tar` and `meta.tar.gz`; `SHA256SUMS` is optional;94- `max_iterations`, or a user-supplied time budget from which an iteration95 limit can be estimated;96- metric name, query type, operator, and optional target;97- whether the deployment requires authenticated Hugging Face model access;98- selected TAO execution platform and its platform-specific prerequisites;99- any explicit epoch, GPU, mining, continual-learning, or visualization100 overrides.101102For a new run, `RESULTS_DIR` must be a child of `WORKSPACE`. `DATASET_ROOT`103must be below a workspace data directory (for example104`$WORKSPACE/data/pas_v31_tao_ft`), not directly below the workspace; neither105path may contain the other. All approved paths are absolute and non-symlink.106107Never replace an explicit value with a heuristic. Defaults apply only to108unspecified values and must be identified as defaults in the pre-flight109summary. `max_iterations` has no default. An absent metric target means an110ungated run that stops after `max_iterations`. Hugging Face token forwarding111defaults to disabled because the bundled model is public.112113The authoritative parameter contract is the nested dataclass schema in114`scripts/pas_deft/config.py`, adapted from the PAS reference notebook. Read115that schema when a request needs the meaning, default, numeric bounds, or valid116options of a DEFT parameter. Do not infer an undocumented field or bypass its117metadata constraint. Config preparation, initialization, audit, and every118host-side stage validate the materialized bundle through that same schema;119the `pas` YAML section is validated through the typed PAS configuration model.120121If required information remains missing after full discovery, ask one122consolidated follow-up. A normal invocation should need no knowledge of stage123modules, container mounts, state files, or bundled-runtime function124signatures.125126## Safety Gate127128Perform only read-only discovery before approval: resolve paths, inspect file129metadata and archives, check process-environment variable presence, inspect130local images, inspect GPUs, and audit an existing run. Credentials come only131from the launching process environment; never open or source a credential file,132and never print, grep, copy, or echo a credential value. If a required variable133is absent, tell the user which name134to export in the shell that launches the agent; never ask for its value in135chat. Do not inspect credential-file metadata when no credential is needed. If136the user explicitly asks for a file-permission check, `stat` only that named137file and warn about group/other readability.138139Show the summary defined in `references/preflight.md`, including every140parameter and source, planned file creation/extraction, image pulls, estimated141runtime, and resume status. Wait for explicit approval before registry login or142pulls, platform submit, package installation, archive extraction, config/state143creation, or any write under the workspace.144145If an approved parameter later changes, show the changed summary rows and get146approval again before continuing. No confirmation is needed between unchanged,147already-approved stages.148149## Execution Contract1501511. After approval, follow `references/preflight.md` to prepare the runtime,152 materialize the immutable run config, and initialize state once. Never153 reinitialize an existing run.1542. Before every stage, after context compaction, and before any completion155 claim, run:156157 ```bash158 "$SKILL_ROOT/scripts/deft_python.sh" --workspace "$WORKSPACE" --runtime \159 "$SKILL_ROOT/scripts/audit_deft_run.py" --results-dir "$RESULTS_DIR"160 ```161162 Continue only when the audit reports `IN_PROGRESS` and its `next_action`163 matches the intended stage. For `INVALID`, stop launching work and report164 the listed inconsistency. For nonterminal `FAILED` whose `next_action` is165 `loop_stop`, follow the pipeline reference and commit `hard_stop`; for166 terminal `FAILED`, report the failure and launch no more work. For167 `COMPLETE`, do not rerun a stage.1683. Read only the current stage reference named by `read_before_action`. Use169 `run_pas_stage.py` for bundled PAS host stages. For every TAO action, use170 `run_deft_action.py prepare`, reconcile any interrupted launch, bind the171 exact request-owned job-record before native submit, dispatch the emitted172 bundle through the selected platform's four verbs, synchronize remote173 outputs, capture native logs, then use `run_deft_action.py finalize`. Follow174 `references/platform-execution.md`; never assemble an untracked launch.1754. A command succeeds only when its exit status is zero and its documented176 output checks pass. Capture verbose output at the action-owned log path;177 inspect the final error block or at most the last 40 lines.1785. Commit each successful or terminally failed stage exactly once with179 `commit_stage.py`. It validates artifact structure, freshness, iteration180 scope, command evidence, leakage, and transition order before applying a181 recoverable, journaled update to `deft_state.json` and `loop_log.jsonl`.182 Never call183 `log_stage.py` or `record_metric_result.py` directly, and never hand-edit184 canonical state, log, metric, or history files.1856. Render the HTML report with `render_deft_report.py`. Reporting is a186 deterministic read of audited state; it does not require another agent.1877. Keep the driving turn attached through the complete bounded loop. After a188 stage reaches terminal status, finalize/commit it, re-audit, and immediately189 continue with the audit-selected next action. An in-progress update is190 commentary, not a final response and not a detach point.191192All recorded artifact paths are absolute host paths under `${RESULTS_DIR}`.193Baseline artifacts live under `zs/`, iteration N under `iter_N/`, and run-wide194splits, source embeddings, and history files at the run root.195196## Workflow197198The normal path is linear, with only two meaningful decisions:199200```text201pre-flight approval202 -> dataset_setup -> pool_embed -> baseline evaluate203 -> KPI met? yes: loop_stop204 no: baseline gap_analysis205 -> for N = 1..max_iterations:206 data_mining -> history_select -> visualize -> train -> evaluate207 -> KPI met? yes: loop_stop208 no and N < max: gap_analysis -> next iteration209 no and N = max: loop_stop210 -> final audit -> HTML report211```212213Stage ownership and exact commands are in214`references/scripts-and-agents.md`. Read the detailed reference only when its215stage is next:216217| Stage | Reference | Required result |218|---|---|---|219| dataset setup | `references/data-layout.md` | verified rebuilt dataset, transparent layout report, five split files, non-empty source-pool parquet |220| pool embedding and mining | `references/mining.md` | fresh command evidence plus non-empty, schema-checked parquet outputs |221| evaluate and train | `references/clip-train-eval.md`, `references/metric-contract.md` | successful TAO status, bound metric evidence; for train, a fresh best and normalized checkpoint |222| gap analysis | `references/gap-analysis.md` | non-empty iteration-scoped gaps parquet |223| history selection | `references/mining.md` | budgeted mined set, cumulative/history entry, zero eval leakage |224| visualization | `references/visualization.md` | enabled artifacts and command evidence, or a config-authorized skip |225226`visualize` is the only optional stage. Commit it with `--skip` only when both227visualization settings are false in the approved config. Do not turn off a228failing visualization mid-run without revising and reapproving the config.229230## Loop and Recovery Rules231232- The loop is bounded by `max_iterations`; never create an iteration outside233 that range. Once the KPI passes, the only legal next transition is234 `loop_stop`. Do not mine or train again.235- Monitoring defaults to attached (`long_running_enabled=true`, five-minute236 updates). Use terminal-condition polling: retain the selected platform's job237 id and poll its native status no more often than every 30 seconds, continuing238 through finalize, commit, audit, and the next stage.239 The bounded workflow's terminal audit status is the end condition, so this is240 not open-ended polling.241- Never send a final response while an approved run is nonterminal. A final242 response ends chat-side execution and nothing can wake it automatically.243 Finalize the turn only after the audit reports `COMPLETE`, terminal `FAILED`,244 or `INVALID`, or when the user explicitly asks to stop or detach. If the245 runtime genuinely cannot keep a turn alive, say so before launch and provide246 the exact durable resume audit command; do not claim unattended monitoring.247- Never repeat an unchanged failed command speculatively. Classify the failure,248 inspect its final log block, make one evidence-based correction permitted by249 the stage reference, then retry once. Stable command status records persist250 attempt 1/2, and the wrappers refuse a third attempt after context loss. The251 audit must pass before advancing.252- A transient registry/network interruption or GPU contention may be retried253 once after evidence shows the condition changed. A second equivalent failure254 is terminal for the run.255- Never retry checksum or rebuild verification failure, zero-row mining,256 schema/cardinality failure, missing eval-split evidence, eval leakage,257 history conflict that fails documented resume, metric-contract mismatch,258 stale/cross-iteration output, or an unsupported GPU architecture. Commit an259 error when state permits and stop with the exact recovery action.260- If a command wrote outputs but crashed before stage commit, run the audit.261 Reuse outputs only when their command status is successful, fresh, correctly262 scoped, and all stage validators pass. History selection has one supported263 recovery: rerun the deterministic adapter with `--resume`; never delete or264 edit a history entry by hand.265- Manual modification or truncation of `deft_state.json` or `loop_log.jsonl`266 invalidates the run. Preserve it for diagnosis and start a new results267 directory.268269## Metric and Stop Semantics270271The approved metric contract is immutable for the run. Evaluation must parse272the exact iteration's `nvidia_pas_metrics_aggregate.csv`; the result records273its source path and is re-derived during commit and audit. Checkpoint ranking274and best-run reporting follow the approved operator (`>=`/`>` chooses the275higher value, `<=`/`<` the lower), not a hard-coded metric convention.276277Successful completion is exactly one of:278279- `loop_stop(reason=kpi_met)` after a bound evaluation satisfies its target;280- `loop_stop(reason=max_iterations)` after the final allowed evaluation when281 the target is unmet or absent.282283`hard_stop` is a failed terminal outcome, not successful completion.284285## Completion286287At a normal loop boundary:2882891. commit `loop_stop` with the audit-selected reason;2902. render `${RESULTS_DIR}/DEFT_Loop_Report.html` with trigger `loop-end`;2913. require this command to exit zero:292293 ```bash294 "$SKILL_ROOT/scripts/deft_python.sh" --workspace "$WORKSPACE" --runtime \295 "$SKILL_ROOT/scripts/audit_deft_run.py" \296 --results-dir "$RESULTS_DIR" --require-complete297 ```298299Report the stop reason, baseline and best metric, best iteration/checkpoint,300completed iteration count, report path, and any warnings. A checkpoint, CSV,301HTML file, or assistant statement alone is not completion evidence.302303## Progressive References304305| Need | Read |306|---|---|307| read-only checks, approval summary, initialization | `references/preflight.md` |308| stage commands and script interfaces | `references/scripts-and-agents.md` |309| platform staging, four verbs, job records, finalization | `references/platform-execution.md` |310| state transitions and resume behavior | `references/pipeline-and-state.md` |311| dataset/archive contract | `references/data-layout.md` |312| KPI parsing and evidence | `references/metric-contract.md` |313| gap generation | `references/gap-analysis.md` |314| embeddings, k-NN, selection | `references/mining.md` |315| contact sheets and t-SNE | `references/visualization.md` |316| train/evaluate/checkpoints | `references/clip-train-eval.md` |