# Okstra Context Loader Contract

## When to Use

- When starting okstra lead Phase 1 task-bundle intake.
- When the user needs the task bundle or current run paths.

## JSON Boundary

Do not open, parse, or infer Okstra-owned task, run, discovery, or active-context JSON. This contract uses the fixed text views below before the lead contract is loaded, so it cannot bypass that boundary.

- `okstra model-io project-context --project-root <project-root> --task-ref <task-ref>` provides project identity and the pointer for one explicit task reference. `task-ref` accepts a bare task ID, full task key, or that task's manifest path.
- `okstra model-io run-input --run-manifest <run-manifest-path>` provides the current run identity, worker roster, model assignments, and permitted artifact paths.

## Step 1: Resolve the Task and Run Paths

1. Determine `<project-root>` from the user request or the current project.
2. If the user supplies a task ID, full task key, or task-manifest path, run `okstra model-io project-context --project-root <project-root> --task-ref <task-ref>`. Otherwise run `okstra model-io project-context --project-root <project-root>`.
3. If the supplied bare task ID is ambiguous, require the full task key or task-manifest path.
4. Use the `Task key`, `Task manifest`, and `Latest run manifest` labels from the same Project Context result.
5. Use `Latest run manifest` as `<run-manifest-path>`. If it is `-`, request an explicit run-manifest path from the launch context or stop with `OKSTRA_CONTEXT_NOT_INITIALIZED`. Do not scan task directories or reconstruct a run path.
6. Run `okstra model-io run-input --run-manifest <run-manifest-path>`.

## Step 2: Read the Compact Intake Files

Use the `Instruction set` and `Reference expectations` labels in Run Input as paths for Markdown resources. Read only the resources needed for the current action.

1. `<instruction-set>/analysis-profile.md` for the task-type rules and required worker block.
2. `<instruction-set>/analysis-packet.md` for the Phase 1 compact input.
3. `<instruction-set>/host-orchestration-rules.md` when the launch prompt supplies that path.

Read `task-brief.md`, `analysis-material.md`, `reference-expectations.md`, and `final-report-template.md` only at their phase-specific need. The report writer owns the final-report template.

### Brief Reporter-Confirmation Precondition (BLOCKING)

After reading `task-brief.md`, extract the frontmatter `reporter-confirmations` field when present and apply the shared handling matrix in `prompts/profiles/_common-contract.md` "Brief handoff contract" → "Reporter confirmation precondition". That block is the authority for the value semantics.

On `pending`, emit `REPORTER_CONFIRMATION_PENDING` and stop. Do not invoke `team-contract` or an analyser, and do not write a final report. Regenerate the brief with `okstra-brief-gen` Step 6.5 and prepare a fresh run. A missing field is a legacy brief and proceeds with the matrix's carried flags. Current-format invalid values are rejected during preparation.

## Step 3: Use Run Input as the Run-State View

Run Input is the only Phase 1 source for task identity, work category, workflow state, selected workers, model assignments, worker prompt paths, result paths, validator path, resume command, and configuration references.

Use the `Worker Roster` section for dispatch and model assignment. Use `Artifact Paths` for prompt, result, report, status, validator, and resume locations. Use `Configuration References` for the task-level Markdown resources. Do not derive sibling paths from file names or sequence counters.

Use the `Current phase` labels as the workflow view. Rules for `nextRecommendedPhase` are maintained by [report-writer](./report-writer.md); do not re-derive phase routing here.

## Output

Information produced after completing this contract:

- Project ID, task key, task type, work category, and workflow snapshot.
- Selected workers and assigned models.
- Prompt, result, report, status, validator, resume, and configuration-reference paths.
- The compact Markdown intake paths required for Phase 1.
