# Session Start

## Purpose
This project is developed in small verified steps across many interrupted sessions.
Every new session must begin by reading:

1. `SESSION_START.md`
2. `WORKLOG.md`

The goal is to resume quickly, work safely, and avoid losing context.

---

## Project location

This project lives at **D:\test\32** on the user's computer.
At session start, read files directly using Filesystem tools — do NOT ask the user
to upload them. The allowed directory is already configured.

---

## Repository reading and edit-output rules

1. Read project files directly when needed.
   - Source files are in `src/`.
   - Integration tests are in `tests/integration/`.
   - Do not guess file contents when they can be read directly.

2. When providing file edits, always provide the **full new contents of the file**.
   - Do not provide patch-style edits.
   - Do not provide partial method-only replacements unless explicitly requested.

3. Before every file you provide, always print the file name first.

---

## Main working principles

1. Work in **small steps** only.
2. Prefer **reliability, safety, and clarity** over new feature expansion.
3. Before coding, always do:
   - understand the task,
   - identify affected files,
   - define the smallest useful scope,
   - define verification.
4. Every completed step must include:
   - implementation,
   - verification,
   - update to `WORKLOG.md`,
   - identification of the next step.
5. If a critical bug or blocking inconsistency is found, it may replace the planned step, but this must be recorded in `WORKLOG.md`.
6. Do not silently switch focus in the middle of a step.
7. Keep changes easy to review and easy to test.

---

## Dialogue rules:
- No patches - only the entire file.
- Be sure to enter the file name before your file.
- The entire dialogue is in Russian. All files are in English.

## Standard work cycle

For every task/session:

1. Read `SESSION_START.md`
2. Read `WORKLOG.md`
3. Confirm the current active step
4. Analyze current code and constraints
5. Write a short implementation plan
6. Define or update tests
7. Implement
8. Verify
9. Record result in `WORKLOG.md`
10. Mark the next smallest step

---

## Session resume rule

If the previous session ended mid-step:

1. first confirm what is already done,
2. confirm what remains,
3. decide whether to continue or explicitly re-scope,
4. record that decision in `WORKLOG.md`.

Never assume the old plan is still correct without checking.

---

## Allowed deviations

A session may deviate from the active step only if one of the following is discovered:

- a critical bug,
- a blocking architectural inconsistency,
- a broken test or broken build that prevents progress,
- necessary documentation update caused by a completed change.

If that happens:
- record the deviation,
- complete the urgent fix,
- return to the normal cycle.

---

## Definition of done for one step

A step is done only if all are true:

- the intended code change is complete,
- relevant verification was performed,
- the result is recorded in `WORKLOG.md`,
- the next small step is identified.

If verification is missing, the step is not done.

---

## Current project priorities

Current global priorities for this repository:

1. Agent core reliability
2. Safety and policy controls
3. Memory/state hygiene
4. Observability and replayability
5. End-to-end and regression test depth
6. Docs/code consistency
7. Repo hygiene and maintainability

---

## Step size rule

A good step should usually fit one session and be one of:

- one bug fix,
- one regression test,
- one narrow refactor,
- one explicit invariant,
- one lifecycle cleanup,
- one small docs alignment update.

Avoid steps that are too broad, such as:

- redesign all memory,
- refactor the whole agent,
- rewrite orchestration,
- fix all safety issues at once.

---

## Working style for this project

When implementing changes:

- keep scope narrow,
- preserve behavior unless intentionally changing it,
- prefer explicit contracts over hidden heuristics,
- prefer tests for behavior-critical logic,
- prefer auditability over cleverness.

---

## Main files to review first when unclear

If the next step is unclear, first inspect:

- `src/agent/loops/mod.rs`
- `src/agent/loops/tests.rs`
- `src/task_state.rs`
- `src/agent/prompt.rs`
- `src/tools/core.rs`
- `src/tools/spec.rs`
- `src/config_loader.rs`
- `src/agent/session/lifecycle.rs`
- `src/agent/session/mod.rs`
- `src/loop_policy.rs`

Also inspect integration coverage in:

- `tests/integration/`

---

## End-of-session rule

Before ending any session, update `WORKLOG.md` with:

- current status,
- what changed,
- how it was verified,
- what exactly should happen next.

This is mandatory even if the step is unfinished.
