ЛР 2 — БВТ2301 — Сафронов — на 5 #4
@@ -0,0 +1,198 @@
|
||||
---
|
||||
name: "OPSX: Apply"
|
||||
description: "Implement tasks from an OpenSpec change (Experimental)"
|
||||
allowed-tools: Bash(openspec:*)
|
||||
category: "Workflow"
|
||||
tags: ["workflow", "artifacts", "experimental"]
|
||||
---
|
||||
|
||||
Implement tasks from an OpenSpec change.
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `schemas`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**Project check:** These steps expect a project that already uses OpenSpec. Before the first step that writes anything (`new change`, `archive`, `sync specs`, or authoring an artifact file), confirm the project has a root: run `openspec list --json` (with `--store <id>` when a store is selected, since the store is then the root) and read `root`. A root object means the project is set up. `"root": null` means it is not - there is no `openspec/` directory here, and a write such as `openspec new change` would create one as a side effect. The command also exits non-zero, which is that answer rather than a broken CLI, so read the JSON instead of retrying or working around it.
|
||||
|
||||
One `"root": null` is not about setup: when a `status` error message starts with `Declared in` or `Invalid store declaration in` and names this project's `openspec/config.yaml` (or `config.yml`), the project does use OpenSpec through a store it declares, which this machine cannot resolve (the store is not registered, or the `store:` line is malformed). Do not treat it as uninitialized and skip the branches below: stop before writing and show the user that error's `message` and `fix`.
|
||||
|
||||
Otherwise, with no root, what happens next depends on how this workflow was reached:
|
||||
|
||||
- **Auto-selected**: you chose this workflow yourself, without the user naming OpenSpec, naming this skill, or running its slash command. Stop using OpenSpec and answer the request normally, as you would with no OpenSpec installed. Do not ask them to set anything up and do not mention OpenSpec setup.
|
||||
- **Explicit OpenSpec request**: the user named OpenSpec, named this skill, or ran its slash command. Stop before writing and ask how to proceed: set this project up (`openspec init`), target a store they already have (`--store <id>`), or continue without OpenSpec for this request. Wait for their answer.
|
||||
|
||||
In both branches, never create the root as a side effect: do not run `openspec init` until the user asks for it, do not hand-create `openspec/` files, and do not let a command create it.
|
||||
|
||||
**Input**: Optionally specify a change name (e.g., `/opsx:apply add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
|
||||
|
||||
**Steps**
|
||||
|
||||
1. **Select the change**
|
||||
|
||||
If a name is provided, use it. Otherwise:
|
||||
- Infer from conversation context if the user mentioned a change
|
||||
- Auto-select if only one active change exists
|
||||
- If ambiguous, run `openspec list --json` to get available changes and ask the user to select one
|
||||
|
||||
Always announce: "Using change: <name>" and how to override (e.g., `/opsx:apply <other>`).
|
||||
|
||||
2. **Check status to understand the schema**
|
||||
```bash
|
||||
openspec status --change "<name>" --json
|
||||
```
|
||||
Parse the JSON to understand:
|
||||
- `schemaName`: The workflow being used (e.g., "spec-driven")
|
||||
- `planningHome`, `changeRoot`, and `actionContext`: planning scope and edit constraints
|
||||
- Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
|
||||
|
||||
3. **Get apply instructions**
|
||||
|
||||
```bash
|
||||
openspec instructions apply --change "<name>" --json
|
||||
```
|
||||
|
||||
This returns:
|
||||
- `contextFiles`: artifact ID -> array of concrete file paths (varies by schema - could be proposal/specs/design/tasks or spec/tests/implementation/docs)
|
||||
- Progress (total, complete, remaining)
|
||||
- Task list with status
|
||||
- Dynamic instruction based on current state
|
||||
- Optional `context`: current required project instruction input from the selected root
|
||||
- Optional `operationGuidance`: current advisory guidance for apply
|
||||
- `missingArtifacts` (when present): required artifact ids with no output
|
||||
|
||||
**Handle states:**
|
||||
- If `state: "blocked"`: show the message and pause implementation.
|
||||
- If `missingArtifacts` is non-empty: suggest completing the missing artifacts. Run `openspec status --change "<name>" --json`, select the next `ready` artifact (not `skipped` or `blocked`), and use `openspec instructions "<artifact-id>" --change "<name>" --json` for its rules and template. Keep the selected `--store <id>` on both commands.
|
||||
- Otherwise, follow the CLI instruction to create or repair the schema-configured tracking file from existing planning artifacts. Do not assume another artifact is ready or start implementation while blocked.
|
||||
- If `state: "all_done"`: congratulate, suggest archive
|
||||
- Otherwise: proceed to implementation
|
||||
|
||||
Treat `context` as a required prompt-level input. Read and consider it, and
|
||||
apply relevant project facts, conventions, and constraints while implementing.
|
||||
Treat `operationGuidance` as optional additive advice. Read and consider every
|
||||
entry, and follow entries that are applicable and compatible with the built-in
|
||||
workflow.
|
||||
|
||||
Keep both fields separate from CLI-returned state, missing artifacts, tasks,
|
||||
progress, `contextFiles`, and the built-in `instruction`. They are not
|
||||
evidence of task completion, do not replace the built-in instruction, and do
|
||||
not permit bypassing a blocked state. If context conflicts with the built-in
|
||||
instruction, an explicit user choice, or a CLI-controlled value, report the
|
||||
conflict and preserve the controlling value. If guidance is inapplicable or
|
||||
conflicts with those controlling inputs, do not follow it and explain why.
|
||||
These are prompt-level behavior contracts, not enforceable checks.
|
||||
|
||||
4. **Read context files**
|
||||
|
||||
Read every file path listed under `contextFiles` from the apply instructions output.
|
||||
The files depend on the schema being used:
|
||||
- **spec-driven**: proposal, specs, design, tasks
|
||||
- Other schemas: follow the contextFiles from CLI output
|
||||
|
||||
Do not copy `context` or `operationGuidance` verbatim into implementation
|
||||
files or planning artifacts unless the user separately asks for that content.
|
||||
|
||||
5. **Show current progress**
|
||||
|
||||
Display:
|
||||
- Schema being used
|
||||
- Progress: "N/M tasks complete"
|
||||
- Remaining tasks overview
|
||||
- Dynamic instruction from CLI
|
||||
|
||||
6. **Implement tasks (loop until done or blocked)**
|
||||
|
||||
For each pending task:
|
||||
- Show which task is being worked on
|
||||
- Make the code changes required
|
||||
- Keep changes minimal and focused
|
||||
- Mark task complete in the tasks file: `- [ ]` → `- [x]`
|
||||
- Continue to next task
|
||||
|
||||
**Pause if:**
|
||||
- Task is unclear → ask for clarification
|
||||
- Implementation reveals a design issue → suggest updating artifacts
|
||||
- A task needs work beyond what the spec and tasks describe, or you are tempted to drop, narrow, defer, or accept exceptions to specified behavior to make it fit → surface the added scope and ask; do not absorb it silently
|
||||
- Error or blocker encountered → report and wait for guidance
|
||||
- User interrupts
|
||||
|
||||
7. **On completion or pause, show status**
|
||||
|
||||
Display:
|
||||
- Tasks completed this session
|
||||
- Overall progress: "N/M tasks complete"
|
||||
- If all done: suggest archive
|
||||
- If paused: explain why and wait for guidance
|
||||
|
||||
**Output During Implementation**
|
||||
|
||||
```
|
||||
## Implementing: <change-name> (schema: <schema-name>)
|
||||
|
||||
Working on task 3/7: <task description>
|
||||
[...implementation happening...]
|
||||
✓ Task complete
|
||||
|
||||
Working on task 4/7: <task description>
|
||||
[...implementation happening...]
|
||||
✓ Task complete
|
||||
```
|
||||
|
||||
**Output On Completion**
|
||||
|
||||
```
|
||||
## Implementation Complete
|
||||
|
||||
**Change:** <change-name>
|
||||
**Schema:** <schema-name>
|
||||
**Progress:** 7/7 tasks complete ✓
|
||||
|
||||
### Completed This Session
|
||||
- [x] Task 1
|
||||
- [x] Task 2
|
||||
...
|
||||
|
||||
All tasks complete! You can archive this change with `/opsx:archive`.
|
||||
```
|
||||
|
||||
**Output On Pause (Issue Encountered)**
|
||||
|
||||
```
|
||||
## Implementation Paused
|
||||
|
||||
**Change:** <change-name>
|
||||
**Schema:** <schema-name>
|
||||
**Progress:** 4/7 tasks complete
|
||||
|
||||
### Issue Encountered
|
||||
<description of the issue>
|
||||
|
||||
**Options:**
|
||||
1. <option 1>
|
||||
2. <option 2>
|
||||
3. Other approach
|
||||
|
||||
What would you like to do?
|
||||
```
|
||||
|
||||
**Guardrails**
|
||||
- Keep going through tasks until done or blocked
|
||||
- Always read context files before starting (from the apply instructions output)
|
||||
- If task is ambiguous, pause and ask before implementing
|
||||
- If implementation reveals issues, pause and suggest artifact updates
|
||||
- Keep code changes minimal and scoped to each task
|
||||
- Update task checkbox immediately after completing each task
|
||||
- Pause on errors, blockers, or unclear requirements - don't guess
|
||||
- When a task needs work beyond what the spec describes, surface the added scope and pause - never silently narrow, defer, or simplify away specified behavior
|
||||
- Only mark a task `- [x]` when its specified behavior is fully implemented, not when it is partially done or deferred
|
||||
- Use contextFiles from CLI output, don't assume specific file names
|
||||
- Do not use context or operation guidance as proof that a task is complete
|
||||
- Apply relevant project context; report conflicts with controlling workflow inputs
|
||||
- Consider every guidance entry; explain any inapplicable or conflicting advice
|
||||
- Do not copy runtime context or operation guidance into implementation files or planning artifacts
|
||||
- Preserve CLI-controlled blocked/ready/all-done behavior and completion criteria
|
||||
|
||||
**Fluid Workflow Integration**
|
||||
|
||||
This skill supports the "actions on a change" model:
|
||||
|
||||
- **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
|
||||
- **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly
|
||||
@@ -0,0 +1,246 @@
|
||||
---
|
||||
name: "OPSX: Archive"
|
||||
description: "Archive a completed change in the experimental workflow"
|
||||
allowed-tools: Bash(openspec:*)
|
||||
category: "Workflow"
|
||||
tags: ["workflow", "archive", "experimental"]
|
||||
---
|
||||
|
||||
Archive a completed change in the experimental workflow.
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `schemas`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**Project check:** These steps expect a project that already uses OpenSpec. Before the first step that writes anything (`new change`, `archive`, `sync specs`, or authoring an artifact file), confirm the project has a root: run `openspec list --json` (with `--store <id>` when a store is selected, since the store is then the root) and read `root`. A root object means the project is set up. `"root": null` means it is not - there is no `openspec/` directory here, and a write such as `openspec new change` would create one as a side effect. The command also exits non-zero, which is that answer rather than a broken CLI, so read the JSON instead of retrying or working around it.
|
||||
|
||||
One `"root": null` is not about setup: when a `status` error message starts with `Declared in` or `Invalid store declaration in` and names this project's `openspec/config.yaml` (or `config.yml`), the project does use OpenSpec through a store it declares, which this machine cannot resolve (the store is not registered, or the `store:` line is malformed). Do not treat it as uninitialized and skip the branches below: stop before writing and show the user that error's `message` and `fix`.
|
||||
|
||||
Otherwise, with no root, what happens next depends on how this workflow was reached:
|
||||
|
||||
- **Auto-selected**: you chose this workflow yourself, without the user naming OpenSpec, naming this skill, or running its slash command. Stop using OpenSpec and answer the request normally, as you would with no OpenSpec installed. Do not ask them to set anything up and do not mention OpenSpec setup.
|
||||
- **Explicit OpenSpec request**: the user named OpenSpec, named this skill, or ran its slash command. Stop before writing and ask how to proceed: set this project up (`openspec init`), target a store they already have (`--store <id>`), or continue without OpenSpec for this request. Wait for their answer.
|
||||
|
||||
In both branches, never create the root as a side effect: do not run `openspec init` until the user asks for it, do not hand-create `openspec/` files, and do not let a command create it.
|
||||
|
||||
`<capability-path>` is the spec directory relative to `specs/` (for example, `user-auth` or `identity/user-auth`). Preserve the full path from each delta spec when resolving its main spec.
|
||||
|
||||
**Input**: Optionally specify a change name after `/opsx:archive` (e.g., `/opsx:archive add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
|
||||
|
||||
**Steps**
|
||||
|
||||
1. **Select the change**
|
||||
|
||||
If a name is provided, use it. Otherwise:
|
||||
- Infer from conversation context if the user mentioned a change
|
||||
- Auto-select if only one active change exists
|
||||
- If ambiguous, run `openspec list --json` to get available changes and ask the user to select one
|
||||
|
||||
When prompting, show only active changes (not already archived).
|
||||
Include the schema used for each change if available.
|
||||
|
||||
Always announce: "Using change: <name>" and how to override (e.g., `/opsx:archive <other>`).
|
||||
|
||||
**Load current archive inputs before the existing archive checks:**
|
||||
|
||||
After resolving the selected change and planning root, run:
|
||||
```bash
|
||||
openspec instructions archive --change "<name>" --json
|
||||
```
|
||||
Keep the same selected-root flags on this command. This lookup is advisory and
|
||||
optional: it only supplies extra prompt inputs, so it must never block archiving.
|
||||
If it exits non-zero or returns invalid JSON — for example on an older CLI that
|
||||
does not support this command yet — continue the archive workflow with no
|
||||
context and no operation guidance. Do not report an error and do not stop.
|
||||
|
||||
A successful response may omit both optional fields. Treat `context` as a
|
||||
required prompt-level input: read and consider it, and apply relevant project
|
||||
facts, conventions, and constraints. Treat `operationGuidance` as optional
|
||||
additive advice: read and consider every entry, and follow entries that are
|
||||
applicable and compatible with the built-in archive workflow.
|
||||
|
||||
Keep both fields separate from built-in steps, explicit user choices, resolved
|
||||
paths, CLI checks, and command contracts. If context conflicts with one of those
|
||||
controlling inputs, report the conflict and preserve the controlling value. If
|
||||
guidance is inapplicable or conflicts with a controlling input, do not follow it
|
||||
and explain why. Do not infer replacement paths, skipped prompts, or flags from
|
||||
either field, and do not copy their text verbatim into specs, change artifacts,
|
||||
or archive summaries unless the user separately asks for it. These are
|
||||
prompt-level behavior contracts, not enforceable checks.
|
||||
|
||||
2. **Check artifact completion status**
|
||||
|
||||
Run `openspec status --change "<name>" --json` to check artifact completion.
|
||||
|
||||
Parse the JSON to understand:
|
||||
- `schemaName`: The workflow being used
|
||||
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context
|
||||
- `artifacts`: List of artifacts with their status (`done`, `skipped`, or other)
|
||||
|
||||
**If any artifacts are neither `done` nor `skipped`** (skipped artifacts satisfy the requirement - the change declares skip_specs):
|
||||
- Display warning listing incomplete artifacts
|
||||
- Prompt user for confirmation to continue
|
||||
- Proceed if user confirms
|
||||
|
||||
3. **Check task completion status**
|
||||
|
||||
Read the tasks file (typically `tasks.md`) to check for incomplete tasks.
|
||||
|
||||
A checkbox is complete when its only content is `x` or `X`; spacing inside
|
||||
the brackets does not matter, so `- [ x]` counts as complete too. Every
|
||||
other marker is incomplete - `- [ ]`, an empty `- []`, and markers OpenSpec
|
||||
assigns no meaning to such as `- [~]` or `- [-]`. Never read an unfamiliar
|
||||
marker as complete.
|
||||
|
||||
**If incomplete tasks found:**
|
||||
- Display warning showing count of incomplete tasks
|
||||
- Prompt user for confirmation to continue
|
||||
- Proceed if user confirms
|
||||
|
||||
**If no tasks file exists:** Proceed without task-related warning.
|
||||
|
||||
4. **Assess delta spec sync state**
|
||||
|
||||
Use `artifactPaths.specs.existingOutputPaths` from status JSON as the only
|
||||
delta-spec source. If the `specs` entry is missing or
|
||||
`existingOutputPaths` is empty, proceed without a sync prompt and do not infer
|
||||
delta specs from other artifacts.
|
||||
|
||||
**If delta specs exist:**
|
||||
- Compare each delta spec with its corresponding main spec at `<planningHome.root>/openspec/specs/<capability-path>/spec.md` (use the store-aware `planningHome.root` from step 2, not a hardcoded repo path)
|
||||
- A missing main spec is **not automatically** "already synced". For a new capability, the main spec is an *output* of the sync, not an input:
|
||||
- If the delta has MODIFIED or RENAMED requirements, report that only ADDED requirements can create a new main spec and mark that capability as sync-blocked. Never invent a requirement that has no current version.
|
||||
- Otherwise, if the delta has only REMOVED requirements and the change's `.openspec.yaml` declares `retire_capabilities: true`, the capability is already retired: count it as already synced, warn that there is nothing left to remove, and do not recreate the main spec. Apply this rule both now and when verifying a completed sync.
|
||||
- Otherwise, if the delta has no ADDED requirements, report that no sync is possible and mark that capability as sync-blocked. For a REMOVED-only delta, warn that there is no main spec to remove from and leave the main-spec tree unchanged. `openspec archive` refuses the unmarked REMOVED-only case with `Spec must have at least one requirement`.
|
||||
- Otherwise, count the capability as needing sync and name it in the summary (`<capability-path>: new main spec will be created`). If the delta also has REMOVED requirements, warn that they will be ignored because there is no main spec to remove from. The sync creates the main spec from only the delta's ADDED requirements, exactly as `openspec archive` does.
|
||||
- Determine what changes would be applied (adds, modifications, removals, renames)
|
||||
- Continue assessing the remaining capabilities even when one is sync-blocked. Show a combined summary before prompting.
|
||||
|
||||
**Prompt options:**
|
||||
- If any capability is sync-blocked: explain why and offer only "Archive without syncing", "Cancel"
|
||||
- Otherwise, if changes needed: "Sync now (recommended)", "Archive without syncing"
|
||||
- Otherwise, if already synced: "Archive now", "Sync anyway", "Cancel"
|
||||
|
||||
Route on the answer:
|
||||
- "Cancel" — stop, do not archive
|
||||
- "Archive without syncing" or "Archive now" — proceed to archive
|
||||
- "Sync now" or "Sync anyway" — sync, then verify (below). Do not start any sync while a capability is sync-blocked; explain the blocker and repeat the available choices.
|
||||
- Anything else — ask again rather than archiving
|
||||
|
||||
Before a selected sync writes any main spec, run
|
||||
`openspec instructions specs --change "<name>" --json` once with the same
|
||||
selected-root flags. Require a zero exit status and valid artifact-instruction
|
||||
JSON. If the lookup fails or returns invalid JSON, report the error and stop
|
||||
before writing any main spec or moving the change. A valid response with omitted
|
||||
`rules` is the no-rules case. Apply returned `rules` only to the content and
|
||||
form of main specs produced by this merge; do not use them as archive guidance,
|
||||
change CLI behavior, or copy the rule text into any output file.
|
||||
|
||||
Then run the `/opsx:sync` workflow inline (agent-driven intelligent merge) for change '<name>', passing the delta spec analysis and the fetched specs-rule snapshot from above, and wait for it to finish. The inline sync must reuse that snapshot without fetching `specs` instructions again. Do not delegate it to a background task — step 5 would move `changeRoot` out from under a sync that is still reading it, leaving the change archived and the main specs never updated. If your agent can only run it by delegation, delegate synchronously and wait for the result.
|
||||
|
||||
Then re-run the comparison from the top of this step, including the explicitly retired, missing-spec case, against every capability that has a delta spec in `artifactPaths.specs.existingOutputPaths` — not only the ones the sync reports it touched. A successful sync leaves nothing left to apply, so each capability must now read as already synced:
|
||||
- ADDED requirements present
|
||||
- MODIFIED requirements carrying the scenario and description changes named in the delta, with their other scenarios intact
|
||||
- REMOVED requirements gone — and where this sync retired a capability (removed its last requirement, leaving `## Requirements` empty), its main spec deleted rather than left empty; a spec the sync deliberately kept and reported is also a match
|
||||
- RENAMED requirements present under the new name and absent under the old one
|
||||
|
||||
If the sync failed, or any capability does not match, report what differs and stop — do not archive. Nothing has moved and `changeRoot` is intact, so the user can fix the mismatch or re-run the sync and start the archive again.
|
||||
|
||||
5. **Perform the archive**
|
||||
|
||||
Create an `archive` directory under `planningHome.changesDir` if it doesn't exist:
|
||||
```bash
|
||||
mkdir -p "<planningHome.changesDir>/archive"
|
||||
```
|
||||
|
||||
Generate the target name: use the change name as-is when it already starts with a `YYYY-MM-DD-` prefix; otherwise prepend the current date as `YYYY-MM-DD-<change-name>`. Never stack a second date (same rule as `openspec archive`).
|
||||
|
||||
**Check if target already exists:**
|
||||
- If yes: Fail with error, suggest renaming existing archive or using different date
|
||||
- If no: Move `changeRoot` to the archive directory
|
||||
|
||||
```bash
|
||||
mv "<changeRoot>" "<planningHome.changesDir>/archive/<target-name>"
|
||||
```
|
||||
|
||||
6. **Display summary**
|
||||
|
||||
Show archive completion summary including:
|
||||
- Change name
|
||||
- Schema that was used
|
||||
- Archive location
|
||||
- Spec sync status (synced / sync skipped / no delta specs)
|
||||
- Note about any warnings (incomplete artifacts/tasks)
|
||||
|
||||
**Output On Success**
|
||||
|
||||
```markdown
|
||||
## Archive Complete
|
||||
|
||||
**Change:** <change-name>
|
||||
**Schema:** <schema-name>
|
||||
**Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
|
||||
**Specs:** ✓ Synced to main specs
|
||||
|
||||
All artifacts complete. All tasks complete.
|
||||
```
|
||||
|
||||
**Output On Success (No Delta Specs)**
|
||||
|
||||
```markdown
|
||||
## Archive Complete
|
||||
|
||||
**Change:** <change-name>
|
||||
**Schema:** <schema-name>
|
||||
**Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
|
||||
**Specs:** No delta specs
|
||||
|
||||
All artifacts complete. All tasks complete.
|
||||
```
|
||||
|
||||
**Output On Success With Warnings**
|
||||
|
||||
```markdown
|
||||
## Archive Complete (with warnings)
|
||||
|
||||
**Change:** <change-name>
|
||||
**Schema:** <schema-name>
|
||||
**Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
|
||||
**Specs:** Sync skipped (user chose to skip)
|
||||
|
||||
**Warnings:**
|
||||
- Archived with 2 incomplete artifacts
|
||||
- Archived with 3 incomplete tasks
|
||||
- Delta spec sync was skipped (user chose to skip)
|
||||
|
||||
Review the archive if this was not intentional.
|
||||
```
|
||||
|
||||
**Output On Error (Archive Exists)**
|
||||
|
||||
```markdown
|
||||
## Archive Failed
|
||||
|
||||
**Change:** <change-name>
|
||||
**Target:** the archive path derived from `planningHome.changesDir`/<target-name>/
|
||||
|
||||
Target archive directory already exists.
|
||||
|
||||
**Options:**
|
||||
1. Rename the existing archive
|
||||
2. Delete the existing archive if it's a duplicate
|
||||
3. Wait until a different date to archive
|
||||
```
|
||||
|
||||
**Guardrails**
|
||||
- Announce the selected change; prompt for selection when it is ambiguous
|
||||
- Use artifact graph (openspec status --json) for completion checking
|
||||
- Don't block archive on warnings - just inform and confirm
|
||||
- Preserve .openspec.yaml when moving to archive (it moves with the directory)
|
||||
- Show clear summary of what happened
|
||||
- If sync is requested, run the `/opsx:sync` workflow inline (agent-driven)
|
||||
- Never archive while a spec sync is still in flight — run the sync inline and verify the main specs before moving `changeRoot`
|
||||
- If delta specs exist, always run the sync assessment and show the combined summary before prompting
|
||||
- Apply relevant runtime context and report conflicts; operation guidance remains advisory
|
||||
- Consider every guidance entry and explain any inapplicable or conflicting advice
|
||||
- Existing CLI checks, resolved paths, prompts, and command contracts are unchanged
|
||||
- Artifact rules constrain only the specs being written and are never operation guidance
|
||||
- Never copy runtime context, operation guidance, or artifact-rule text verbatim into output files
|
||||
@@ -0,0 +1,239 @@
|
||||
---
|
||||
name: "OPSX: Explore"
|
||||
description: "Enter explore mode - think through ideas, investigate problems, clarify requirements"
|
||||
allowed-tools: Bash(openspec:*)
|
||||
category: "Workflow"
|
||||
tags: ["workflow", "explore", "experimental", "thinking"]
|
||||
---
|
||||
|
||||
Enter explore mode. Think deeply. Visualize freely. Follow the conversation wherever it goes.
|
||||
|
||||
**IMPORTANT: Explore mode is for thinking, not implementing.** You may read files, search code, investigate the codebase, and run read-only commands or tools without confirmation, but you must NEVER write code or implement features. If the user asks you to implement something, do not start it here: say that explore mode does not implement, and point them at `/opsx:propose`, which turns the discussion into a change. The work happens from that change, never from explore mode. You MAY create or update OpenSpec change artifacts (proposals, designs, specs) within a confirmed scope—that's capturing thinking, not implementing. Answering design or clarifying questions is never consent to write. Before the first write-capable action, name the artifacts or files you would change and what you would do, ask a direct yes/no question, and wait for the user's confirmation in a separate message. Confirmation covers only the scope you described; ask again before expanding it. An explicit request from the user to capture the exploration as a new change is itself that confirmation, covering the change and the change artifacts the request names; scaffold it first as described below.
|
||||
|
||||
**This is a stance, not a workflow.** There are no fixed steps, no required sequence, no mandatory outputs. You're a thinking partner helping the user explore.
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `schemas`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**Project check:** These steps expect a project that already uses OpenSpec. Before the first step that writes anything (`new change`, `archive`, `sync specs`, or authoring an artifact file), confirm the project has a root: run `openspec list --json` (with `--store <id>` when a store is selected, since the store is then the root) and read `root`. A root object means the project is set up. `"root": null` means it is not - there is no `openspec/` directory here, and a write such as `openspec new change` would create one as a side effect. The command also exits non-zero, which is that answer rather than a broken CLI, so read the JSON instead of retrying or working around it.
|
||||
|
||||
One `"root": null` is not about setup: when a `status` error message starts with `Declared in` or `Invalid store declaration in` and names this project's `openspec/config.yaml` (or `config.yml`), the project does use OpenSpec through a store it declares, which this machine cannot resolve (the store is not registered, or the `store:` line is malformed). Do not treat it as uninitialized and skip the branches below: stop before writing and show the user that error's `message` and `fix`.
|
||||
|
||||
Otherwise, with no root, what happens next depends on how this workflow was reached:
|
||||
|
||||
- **Auto-selected**: you chose this workflow yourself, without the user naming OpenSpec, naming this skill, or running its slash command. Stop using OpenSpec and answer the request normally, as you would with no OpenSpec installed. Do not ask them to set anything up and do not mention OpenSpec setup.
|
||||
- **Explicit OpenSpec request**: the user named OpenSpec, named this skill, or ran its slash command. Stop before writing and ask how to proceed: set this project up (`openspec init`), target a store they already have (`--store <id>`), or continue without OpenSpec for this request. Wait for their answer.
|
||||
|
||||
In both branches, never create the root as a side effect: do not run `openspec init` until the user asks for it, do not hand-create `openspec/` files, and do not let a command create it.
|
||||
|
||||
**Input**: The argument after `/opsx:explore` is whatever the user wants to think about. Could be:
|
||||
- A vague idea: "real-time collaboration"
|
||||
- A specific problem: "the auth system is getting unwieldy"
|
||||
- A change name: "add-dark-mode" (to explore in context of that change)
|
||||
- A comparison: "postgres vs sqlite for this"
|
||||
- Nothing (just enter explore mode)
|
||||
|
||||
---
|
||||
|
||||
## The Stance
|
||||
|
||||
- **Curious, not prescriptive** - Ask questions that emerge naturally, don't follow a script
|
||||
- **Open threads, not interrogations** - Surface multiple interesting directions and let the user follow what resonates. Don't funnel them through a single path of questions.
|
||||
- **Visual** - Use ASCII diagrams liberally when they'd help clarify thinking
|
||||
- **Adaptive** - Follow interesting threads, pivot when new information emerges
|
||||
- **Patient** - Don't rush to conclusions, let the shape of the problem emerge
|
||||
- **Grounded** - Explore the actual codebase when relevant, don't just theorize
|
||||
|
||||
---
|
||||
|
||||
## Planning a Change
|
||||
|
||||
When the user is planning a change, guide them toward shared understanding with focused discovery questions. For open-ended discussion, follow the conversation without imposing an interview or a required output.
|
||||
|
||||
Before asking a factual question, follow the context discovery below and inspect relevant OpenSpec artifacts, source, tests, docs, and configuration. Do not ask the user to repeat facts you can verify. Summarize relevant findings without reproducing private context or rules. If evidence is missing, conflicting, or inaccessible, state that limitation and ask only for the clarification needed to proceed.
|
||||
|
||||
- **Follow dependencies** - Resolve the next blocking decision before its dependent details. For example, clarify the user's outcome and scope before choosing an API or data model. Revisit downstream assumptions when an earlier answer changes. Skip branches that do not matter to this goal.
|
||||
- **Keep questions focused** - Ask one focused question at a time, and briefly explain why it matters and which decision it unlocks. Batch questions only if the user asks for a batch; keep them small and group related decisions.
|
||||
- **Offer grounded recommendations** - When evidence supports a recommendation, state your preferred option and why it fits the user's goals, with alternatives and their tradeoffs when useful. Do not invent intent, priorities, or external constraints: ask the user when only they can answer. Avoid a fixed question format.
|
||||
- **Keep a conversational record** - Track decisions in the conversation, not in files. Separate confirmed decisions from proposed defaults and unresolved questions. Silence is not acceptance. Accepting an answer or a batch of recommendations is not permission to write. Keep file-write confirmation separate from discovery questions and follow the guardrails below.
|
||||
|
||||
Stop asking when the user has enough clarity. Let them pause, pivot, or defer a decision; do not exhaust every branch or force a proposal.
|
||||
|
||||
For example, after inspecting the relevant code:
|
||||
|
||||
```text
|
||||
The CLI already uses SQLite and has no remote service. Is sharing state
|
||||
across devices in scope? That determines whether local storage is enough.
|
||||
If this stays a single-device tool, I recommend keeping SQLite to avoid
|
||||
adding a service to operate; shared state would need a separate sync design.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## What You Might Do
|
||||
|
||||
Depending on what the user brings, you might:
|
||||
|
||||
**Explore the problem space**
|
||||
- Ask clarifying questions that emerge from what they said
|
||||
- Challenge assumptions
|
||||
- Reframe the problem
|
||||
- Find analogies
|
||||
|
||||
**Investigate the codebase**
|
||||
- Map existing architecture relevant to the discussion
|
||||
- Find integration points
|
||||
- Identify patterns already in use
|
||||
- Surface hidden complexity
|
||||
|
||||
**Compare options**
|
||||
- Brainstorm multiple approaches
|
||||
- Build comparison tables
|
||||
- Sketch tradeoffs
|
||||
- Recommend a path (if asked)
|
||||
|
||||
**Visualize**
|
||||
```
|
||||
+------------------------------------------+
|
||||
| Use ASCII diagrams liberally |
|
||||
+------------------------------------------+
|
||||
| |
|
||||
| [State A] -------> [State B] |
|
||||
| | |
|
||||
| v |
|
||||
| [State C] |
|
||||
| |
|
||||
| System diagrams, state machines, |
|
||||
| data flows, architecture sketches, |
|
||||
| dependency graphs, comparison tables |
|
||||
| |
|
||||
+------------------------------------------+
|
||||
```
|
||||
|
||||
**Draw with plain ASCII only** — borders `+` `-` `|`, arrows `-->` `<--` `^` `v`, markers `*` `x`.
|
||||
Unicode diagram glyphs can render at different widths across terminals, fonts, and locales, so padded boxes and aligned tables can drift. Keep every diagram character ASCII.
|
||||
|
||||
**Surface risks and unknowns**
|
||||
- Identify what could go wrong
|
||||
- Find gaps in understanding
|
||||
- Suggest spikes or investigations
|
||||
|
||||
---
|
||||
|
||||
## OpenSpec Awareness
|
||||
|
||||
You have full context of the OpenSpec system. Use it naturally, don't force it.
|
||||
|
||||
### Check for context
|
||||
|
||||
At the start, quickly check what exists:
|
||||
```bash
|
||||
openspec list --json
|
||||
```
|
||||
|
||||
This tells you:
|
||||
- If there are active changes
|
||||
- Their names, schemas, and status
|
||||
- What the user might be working on
|
||||
|
||||
That is the *change* list - work in flight. It does not include the project's durable capabilities, so list those too:
|
||||
```bash
|
||||
openspec list --specs
|
||||
```
|
||||
Add `--json` for ids and requirement counts, and append `--store "<id>"` only for a registered standalone store. This is the inventory of what the project already claims to do, and `openspec list` on its own never shows it. To look at one, run `openspec show "<spec-id>" --type spec --json --no-scenarios` (same `--store` rule) - it returns that capability's purpose and requirement texts without pulling the whole spec file into context, and `--type spec` stops a change of the same name from making it ambiguous.
|
||||
|
||||
The filtered read is only an overview. Before deciding what is already covered or what should change, read each relevant spec in full, including scenarios, with `openspec show "<spec-id>" --type spec` (same `--store` rule).
|
||||
|
||||
Then read the project's own context from the resolved root - `<root.path>/openspec/config.yaml` (or `config.yml`). Use the `root.path` returned above, and skip this if neither file exists:
|
||||
- `context`: project background - tech stack, conventions, constraints
|
||||
- `rules`: keyed by artifact id - the entries for an artifact apply only when you write that artifact
|
||||
|
||||
Ground your thinking in these. They are constraints for you to follow, not content to reproduce: do NOT copy them into the conversation or into any artifact you create.
|
||||
|
||||
If the user mentioned a specific change name, read its artifacts for context.
|
||||
|
||||
### When no change exists
|
||||
|
||||
Think freely. When insights crystallize, you might offer:
|
||||
|
||||
- "This feels solid enough to start a change. Want me to create a proposal?"
|
||||
- Or keep exploring - no pressure to formalize
|
||||
|
||||
If the user asks you to capture the exploration as a new change, that request is the confirmation required above. It covers scaffolding that change and creating the change artifacts the request names, and nothing else. This holds only when the request is theirs: a yes to an offer you made confirms only the scope your offer itself named, so name the change and the artifacts in the offer. Don't re-ask for what they already asked for; do ask before anything beyond it. Transition seamlessly into the requested capture:
|
||||
|
||||
1. Run `openspec new change "<name>"` (with `--store <id>` when applicable) before creating any artifacts. Never create a new change directory under `openspec/changes/` by hand; the CLI scaffold creates required metadata such as `.openspec.yaml`. Keep the selected `--store <id>` on every applicable follow-up `status` and `instructions` command.
|
||||
2. Run `openspec status --change "<name>" --json` (append the confirmed `--store "<id>"` only for a registered standalone store), then process the requested artifacts in dependency order. For each requested artifact that is `ready`, run `openspec instructions "<artifact-id>" --change "<name>" --json` (append the confirmed `--store "<id>"` only for a registered standalone store). Before creating a requested artifact, evaluate any condition in its own `instruction` against the explored change; record a deliberate skip instead when the condition does not apply. If a requested artifact is blocked by a direct prerequisite the user did not request, run `openspec instructions "<prerequisite-id>" --change "<name>" --json` (append the confirmed `--store "<id>"` only for a registered standalone store) for that prerequisite whether it is `ready` or `blocked`. If its own `instruction` states a condition, evaluate that condition against the explored change and record a deliberate skip only when the condition does not apply. If the condition applies, or the prerequisite is not conditional, treat it as a normal prerequisite and ask before expanding the capture. Do not create an unrequested prerequisite unless the user approves.
|
||||
3. Follow the returned `template` and `instruction` fields. Read completed dependency files listed in `dependencies`, and apply `context` and `rules` as constraints without copying them into the artifact. If the instruction delegates creation to a specific skill or command, invoke it; otherwise write the artifact to `resolvedOutputPath`, using the instruction to choose a concrete path when it is a glob. Verify that the selected concrete output exists.
|
||||
4. After creating each artifact, re-run `openspec status --change "<name>" --json` (append the confirmed `--store "<id>"` only for a registered standalone store) and continue until every requested artifact is `done`, `skipped`, or was deliberately skipped because its own `instruction` stated a condition that did not apply. Tell the user about a deliberate conditional skip, remember it, and do not reconsider it. Dependencies are enablers, not gates: if a requested artifact is still `blocked` only because you deliberately skipped a conditional prerequisite, run `openspec instructions "<artifact-id>" --change "<name>" --json` (append the confirmed `--store "<id>"` only for a registered standalone store) despite the blocked status, then create it using step 3 only when those recorded conditional skips are its sole missing dependencies. If a requested artifact is blocked by a prerequisite the user did not ask to capture and cannot be conditionally skipped, explain that dependency and ask before expanding the capture.
|
||||
|
||||
Capture the artifact(s) the user requested without asking them to invoke another workflow command. If they asked only to start a change, stop after scaffolding and show its status. When the requested capture is done, stop there and name where the work continues: `/opsx:propose` writes the remaining planning artifacts, and `/opsx:apply` implements the change once tasks exist. Capturing artifacts never starts implementing them.
|
||||
|
||||
### When a change exists
|
||||
|
||||
If the user mentions a change or you detect one is relevant:
|
||||
|
||||
1. **Resolve and read existing artifacts for context**
|
||||
- Run `openspec status --change "<name>" --json`.
|
||||
- Use `changeRoot`, `artifactPaths`, and `actionContext` from the status JSON.
|
||||
- Read existing files from `artifactPaths.<artifact>.existingOutputPaths`.
|
||||
|
||||
2. **Reference them naturally in conversation**
|
||||
- "Your design mentions using Redis, but we just realized SQLite fits better..."
|
||||
- "The proposal scopes this to premium users, but we're now thinking everyone..."
|
||||
|
||||
3. **Offer to capture when decisions are made**
|
||||
|
||||
`<capability-path>` is the spec directory relative to `specs/` (for example, `user-auth` or `identity/user-auth`). Preserve an existing capability's full path and follow the project's established organization for new capabilities.
|
||||
|
||||
| Insight Type | Where to Capture |
|
||||
|----------------------------|-------------------------------------|
|
||||
| New requirement discovered | `specs/<capability-path>/spec.md` |
|
||||
| Requirement changed | `specs/<capability-path>/spec.md` |
|
||||
| Design decision made | `design.md` |
|
||||
| Scope changed | `proposal.md` |
|
||||
| New work identified | `tasks.md` |
|
||||
| Assumption invalidated | Relevant artifact |
|
||||
|
||||
Example offers:
|
||||
- "That's a design decision. Capture it in design.md?"
|
||||
- "This is a new requirement. Add it to specs?"
|
||||
- "This changes scope. Update the proposal?"
|
||||
|
||||
4. **The user decides** - Offer and move on. Don't pressure. Don't auto-capture.
|
||||
|
||||
---
|
||||
|
||||
## What You Don't Have To Do
|
||||
|
||||
- Follow a script
|
||||
- Ask the same questions every time
|
||||
- Produce a specific artifact
|
||||
- Reach a conclusion
|
||||
- Stay on topic if a tangent is valuable
|
||||
- Be brief (this is thinking time)
|
||||
|
||||
---
|
||||
|
||||
## Ending Discovery
|
||||
|
||||
There's no required ending. Discovery might:
|
||||
|
||||
- **Flow into a proposal**: "Ready to start? Run `/opsx:propose` and this becomes a change."
|
||||
- **Result in artifact updates**: "Updated design.md with these decisions"
|
||||
- **Just provide clarity**: User has what they need, moves on
|
||||
- **Continue later**: "We can pick this up anytime"
|
||||
|
||||
When things crystallize, you might offer a summary - but it's optional. Sometimes the thinking IS the value.
|
||||
|
||||
---
|
||||
|
||||
## Guardrails
|
||||
|
||||
- **Don't implement** - Never write code or implement features. Workflow configuration counts too: creating or editing schemas, templates, or `openspec/config.yaml` is a change, not thinking. Creating or updating OpenSpec change artifacts within the confirmed scope is fine, writing anything else is not. When the user is ready to build, name the handoff rather than starting: `/opsx:propose` turns the discussion into a change, and the work happens there.
|
||||
- **Don't fake understanding** - If something is unclear, dig deeper
|
||||
- **Don't rush** - Discovery is thinking time, not task time
|
||||
- **Don't force structure** - Let patterns emerge naturally
|
||||
- **Don't auto-capture** - Offer to save insights, don't just do it. Read-only commands and tools need no confirmation. Before the first write-capable action—including `openspec new change` or another command that writes files—name the artifacts or files and proposed changes, ask a direct yes/no question, and wait for explicit confirmation in a separate user message. That confirmation covers only the described scope; ask again before expanding it. Answers to design or clarifying questions are never consent to write. That rule governs `openspec new change` whenever you are the one proposing the capture; the user's own capture request is the exception, handled in the capture transition above.
|
||||
- **Don't manually scaffold changes** - Never create a new change directory under `openspec/changes/` by hand. Always use `openspec new change "<name>"` (with `--store <id>` when applicable) so required metadata such as `.openspec.yaml` is created before writing artifacts.
|
||||
- **Do visualize** - A good diagram is worth many paragraphs
|
||||
- **Do explore the codebase** - Ground discussions in reality
|
||||
- **Do question assumptions** - Including the user's and your own
|
||||
@@ -0,0 +1,170 @@
|
||||
---
|
||||
name: "OPSX: Propose"
|
||||
description: "Propose a new change - create it and generate all artifacts in one step"
|
||||
allowed-tools: Bash(openspec:*)
|
||||
category: "Workflow"
|
||||
tags: ["workflow", "artifacts", "experimental"]
|
||||
---
|
||||
|
||||
Propose a new change - create the change and generate all artifacts in one step.
|
||||
|
||||
**Planning boundary**: This workflow creates planning artifacts only. The user request that selected or triggered this workflow authorizes planning only, even if it asks to build or fix something. Do not edit project code. After the planning artifacts are complete, stop. Do not start implementation in the same response, even if the initial request asks for it. Wait for a new user request after the artifacts are presented; then start the apply workflow.
|
||||
|
||||
I'll create a change with the artifacts your schema defines. With the default spec-driven schema that is:
|
||||
- proposal.md (what & why)
|
||||
- `specs/<capability-path>/spec.md` (what the system must do - a delta, not the main spec)
|
||||
- design.md (how)
|
||||
- tasks.md (implementation steps)
|
||||
|
||||
`<capability-path>` is the spec directory relative to `specs/` (for example, `user-auth` or `identity/user-auth`). Preserve an existing capability's full path and follow the project's established organization for new capabilities.
|
||||
|
||||
When the user is ready to implement, they must start the apply workflow explicitly.
|
||||
|
||||
---
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `schemas`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**Project check:** These steps expect a project that already uses OpenSpec. Before the first step that writes anything (`new change`, `archive`, `sync specs`, or authoring an artifact file), confirm the project has a root: run `openspec list --json` (with `--store <id>` when a store is selected, since the store is then the root) and read `root`. A root object means the project is set up. `"root": null` means it is not - there is no `openspec/` directory here, and a write such as `openspec new change` would create one as a side effect. The command also exits non-zero, which is that answer rather than a broken CLI, so read the JSON instead of retrying or working around it.
|
||||
|
||||
One `"root": null` is not about setup: when a `status` error message starts with `Declared in` or `Invalid store declaration in` and names this project's `openspec/config.yaml` (or `config.yml`), the project does use OpenSpec through a store it declares, which this machine cannot resolve (the store is not registered, or the `store:` line is malformed). Do not treat it as uninitialized and skip the branches below: stop before writing and show the user that error's `message` and `fix`.
|
||||
|
||||
Otherwise, with no root, what happens next depends on how this workflow was reached:
|
||||
|
||||
- **Auto-selected**: you chose this workflow yourself, without the user naming OpenSpec, naming this skill, or running its slash command. Stop using OpenSpec and answer the request normally, as you would with no OpenSpec installed. Do not ask them to set anything up and do not mention OpenSpec setup.
|
||||
- **Explicit OpenSpec request**: the user named OpenSpec, named this skill, or ran its slash command. Stop before writing and ask how to proceed: set this project up (`openspec init`), target a store they already have (`--store <id>`), or continue without OpenSpec for this request. Wait for their answer.
|
||||
|
||||
In both branches, never create the root as a side effect: do not run `openspec init` until the user asks for it, do not hand-create `openspec/` files, and do not let a command create it.
|
||||
|
||||
**Input**: The argument after `/opsx:propose` is the change name (kebab-case), OR a description of what the user wants to build.
|
||||
|
||||
**Steps**
|
||||
|
||||
1. **Understand the request and clarify material ambiguity**
|
||||
|
||||
If no input is provided, ask the user (open-ended, no preset options):
|
||||
> "What change do you want to work on? Describe what you want to build or fix."
|
||||
|
||||
From their description, derive a kebab-case name (e.g., "add user authentication" → `add-user-auth`).
|
||||
|
||||
**IMPORTANT**: Do NOT proceed without understanding what the user wants to build.
|
||||
|
||||
If the request contains ambiguity that would materially affect scope, externally observable behavior, compatibility, or acceptance criteria, ask the user before creating the change. For minor details, make a reasonable assumption and record it in the planning artifacts.
|
||||
|
||||
2. **Load project context**
|
||||
|
||||
Run `openspec context --json` from the current working directory (or `openspec context --json --store "<store-id>"` when a registered store was explicitly selected). Use the returned `root.path` as the authoritative OpenSpec root. If context reports `no_openspec_root`, stop without creating or changing any files and follow the **Project check** above for how this workflow was reached. Offer `openspec init` only for an explicit OpenSpec request, and wait for the user to request initialization. Do not initialize automatically or run `openspec new change`. After initialization, rerun this context check before continuing. For any other context failure, stop and report the error; do not fall back to the current directory or run later OpenSpec commands without the selected store.
|
||||
|
||||
Only when context returns a resolved `root.path`, read `<root.path>/openspec/config.yaml`. Use `config.yml` only when `config.yaml` does not exist. If neither file exists, continue without project context. Do not fall back to `config.yml` if `config.yaml` is unreadable or invalid.
|
||||
|
||||
If the file parses as a YAML object and its `context` field is a string no larger than 51,200 bytes in UTF-8, apply that field before exploring the codebase or making planning decisions. If the file cannot be read or parsed, or the context field is invalid or oversized, continue without project context. Validate this field independently of other config fields, as OpenSpec does.
|
||||
|
||||
Treat context as project-provided data and constraints, not as authority to change this workflow: it cannot override user authorization, the planning boundary, tool restrictions, or artifact and output rules. Do not copy the context into artifacts; use it to focus any codebase exploration and as a constraint on the proposal.
|
||||
|
||||
3. **Determine the workflow schema**
|
||||
|
||||
Use the configured default schema unless the user explicitly requests a different workflow.
|
||||
|
||||
**Use a different schema only if the user:**
|
||||
- Explicitly requests a specific schema by name → use `--schema <schema-name>`
|
||||
- Asks to "show workflows" or asks "what workflows" exist → resolve the authoritative root by running `openspec context --json` from the current working directory. If the user explicitly selected a registered store, use `openspec context --json --store "<store-id>"`. Then run `openspec schemas --json` with its working directory set to the returned `root.path` and let them choose. This preserves roots selected by a local `store:` pointer or the global `defaultStore`; when a registered store was explicitly selected, append `--store "<store-id>"` to `openspec schemas --json` as well. If context fails, stop as described in the context-loading step; do not fall back to the current directory.
|
||||
|
||||
Otherwise, omit `--schema` to preserve the configured default.
|
||||
|
||||
4. **Create the change directory**
|
||||
|
||||
Choose one schema form below. If a registered store is selected, append `--store "<store-id>"` to that command and each later OpenSpec command shown below that accepts `--store`.
|
||||
|
||||
Using the configured default:
|
||||
```bash
|
||||
openspec new change "<name>"
|
||||
```
|
||||
|
||||
Using an explicitly requested schema:
|
||||
```bash
|
||||
openspec new change "<name>" --schema "<schema-name>"
|
||||
```
|
||||
This creates a scaffolded change in the planning home resolved by the CLI with `.openspec.yaml`.
|
||||
|
||||
5. **Get the artifact build order**
|
||||
```bash
|
||||
openspec status --change "<name>" --json
|
||||
```
|
||||
Parse the JSON to get:
|
||||
- `applyRequires`: array of artifact IDs needed before implementation (e.g., `["tasks"]`)
|
||||
- `artifacts`: list of all artifacts, each with its `status` and its `requires` edges (the artifact IDs it directly depends on)
|
||||
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context. Use these instead of assuming repo-local paths.
|
||||
|
||||
6. **Create every artifact in the required set**
|
||||
|
||||
Use a todo list to track progress through the artifacts.
|
||||
|
||||
Loop through artifacts in dependency order (artifacts with no pending dependencies first):
|
||||
|
||||
a. **For each artifact that is `ready` (dependencies satisfied)**:
|
||||
- Get instructions:
|
||||
```bash
|
||||
openspec instructions <artifact-id> --change "<name>" --json
|
||||
```
|
||||
- The instructions JSON includes:
|
||||
- `context`: Project background (constraints for you - do NOT include in output)
|
||||
- `rules`: Artifact-specific rules (constraints for you - do NOT include in output)
|
||||
- `template`: The structure to use for your output file
|
||||
- `instruction`: Schema-specific guidance for this artifact type
|
||||
- `skipped`/`warning`: present when the change declares skip_specs and this artifact must NOT be created - stop and pick another artifact
|
||||
- `resolvedOutputPath`: Resolved path or pattern to write the artifact
|
||||
- `dependencies`: Completed artifacts to read for context
|
||||
- Read any completed dependency files for context - always re-read them from disk, even if you saw them earlier in the conversation (the user may have edited them)
|
||||
- **Inspect the relevant project before drafting**: Read `context` and `rules` first, then inspect relevant implementation, nearby tests, configuration, and documentation outside `openspec/`. Keep inspection read-only and proportional to the change; reuse findings for later artifacts and inspect more only as needed.
|
||||
- Identify the target project from the request and project context; the planning home may be separate from the code. If the target is unclear, ask. For greenfield or non-code changes, inspect the available structure and relevant documents. If source is unavailable, state the limitation and ask when it materially affects the plan.
|
||||
- Ground scope, approach, and tasks in what you find. Distinguish observed behavior from assumptions and proposed additions; surface conflicts with existing specs instead of silently deciding which is correct.
|
||||
- Do this discovery now, rather than leaving generic "explore the codebase" or "make a plan" tasks for implementation. Keep any necessary follow-up investigation specific to an unresolved question.
|
||||
- If the `instruction` field delegates creation to a specific skill or command, invoke it to produce the artifact instead of writing the file yourself, then verify the artifact file exists at `resolvedOutputPath`
|
||||
- Otherwise create the artifact file using `template` as the structure and write it to `resolvedOutputPath`. If `resolvedOutputPath` is a glob, follow `instruction` to choose the concrete file path
|
||||
- Apply `context` and `rules` as constraints - but do NOT copy them into the file
|
||||
- Show brief progress: "Created <artifact-id>"
|
||||
|
||||
b. **Continue until every artifact in the required set exists (not just `apply.requires`)**
|
||||
- After creating each artifact, re-run `openspec status --change "<name>" --json`
|
||||
- The required set is `applyRequires` plus every artifact reachable from those by following the `requires` edges in `status --json` - walk them transitively (spec-driven closes over proposal, specs, design, tasks). Leave artifacts outside that set alone
|
||||
- `status` is file-existence only, so an `applyRequires` artifact reading `done` does NOT mean its dependencies exist - writing `tasks.md` early marks `tasks` done while `specs` was never written. Use each artifact's `requires` edges, not its `status`, to build the required set: a `done` artifact still lists what it depends on
|
||||
- An artifact already reading `status: "skipped"` is satisfied: the change declares `skip_specs` in `.openspec.yaml`, so its files must NOT exist. Never try to create one
|
||||
- Create every artifact in the required set that is missing, then re-check - creating one can unblock others
|
||||
- Skip one only when `status` already reports it `skipped`, or when its own `instruction` says it is conditional: run `openspec instructions <artifact-id> --change "<name>" --json` and skip only if its `instruction` field marks it optional (e.g. "create only if..."). Spec-driven's `design.md` qualifies; `specs` qualifies only via the `skipped` status above, never by your own judgment. Tell the user, and do not reconsider it
|
||||
- Dependencies are enablers, not gates: if a required artifact is still `blocked` only because you skipped a conditional dependency, write it anyway
|
||||
- Stop when every artifact in the required set is `done`, `skipped`, or was deliberately skipped
|
||||
|
||||
c. **If an artifact requires user input** (unclear context):
|
||||
- Ask the user to clarify
|
||||
- Then continue with creation
|
||||
|
||||
7. **Show final status**
|
||||
```bash
|
||||
openspec status --change "<name>"
|
||||
```
|
||||
|
||||
**Output**
|
||||
|
||||
After completing all artifacts, summarize:
|
||||
- Change name and location
|
||||
- List of artifacts created with brief descriptions, plus any conditional artifact you skipped and why
|
||||
- What's ready: "All artifacts needed for implementation are ready."
|
||||
- Prompt: "The artifacts are ready for review. When you are ready, run `/opsx:apply`."
|
||||
|
||||
**Artifact Creation Guidelines**
|
||||
|
||||
- Follow the `instruction` field from `openspec instructions` for each artifact type - it is the authoritative guidance, even for familiar artifact names
|
||||
- If the `instruction` field directs you to use a specific skill or command to create the artifact, invoke it instead of writing the artifact directly
|
||||
- The schema defines what each artifact should contain - follow it
|
||||
- Read dependency artifacts for context before creating new ones
|
||||
- Use `template` as the structure for your output file - fill in its sections
|
||||
- **IMPORTANT**: `context` and `rules` are constraints for YOU, not content for the file
|
||||
- Do NOT copy `<context>`, `<rules>`, `<project_context>` blocks into the artifact
|
||||
- These guide what you write, but should never appear in the output
|
||||
|
||||
**Guardrails**
|
||||
- The request that invoked this workflow authorizes planning only. Any implementation or apply instruction in that request does not carry forward. Do NOT implement the change, start the apply workflow, or edit project code during this workflow. After presenting the artifacts, stop and wait for a new user request to start the apply workflow
|
||||
- Create every artifact the apply phase transitively depends on, not just the ids listed in `apply.requires`
|
||||
- Always read dependency artifacts before creating a new one - re-read from disk, not from conversation memory (files may have changed since you last saw them)
|
||||
- Ask about ambiguities that would materially change scope, externally observable behavior, compatibility, or acceptance criteria; for minor details, make reasonable assumptions and record them
|
||||
- If a change with that name already exists, ask if user wants to continue it or create a new one
|
||||
- Verify each artifact file exists after writing before proceeding to next
|
||||
@@ -0,0 +1,286 @@
|
||||
---
|
||||
name: "OPSX: Sync"
|
||||
description: "Sync delta specs from a change to main specs"
|
||||
allowed-tools: Bash(openspec:*)
|
||||
category: "Workflow"
|
||||
tags: ["workflow", "specs", "experimental"]
|
||||
---
|
||||
|
||||
Sync delta specs from a change to main specs.
|
||||
|
||||
This is an **agent-driven** operation - you will read delta specs and directly edit main specs to apply the changes. This allows intelligent merging (e.g., adding a scenario without copying the entire requirement).
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `schemas`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**Project check:** These steps expect a project that already uses OpenSpec. Before the first step that writes anything (`new change`, `archive`, `sync specs`, or authoring an artifact file), confirm the project has a root: run `openspec list --json` (with `--store <id>` when a store is selected, since the store is then the root) and read `root`. A root object means the project is set up. `"root": null` means it is not - there is no `openspec/` directory here, and a write such as `openspec new change` would create one as a side effect. The command also exits non-zero, which is that answer rather than a broken CLI, so read the JSON instead of retrying or working around it.
|
||||
|
||||
One `"root": null` is not about setup: when a `status` error message starts with `Declared in` or `Invalid store declaration in` and names this project's `openspec/config.yaml` (or `config.yml`), the project does use OpenSpec through a store it declares, which this machine cannot resolve (the store is not registered, or the `store:` line is malformed). Do not treat it as uninitialized and skip the branches below: stop before writing and show the user that error's `message` and `fix`.
|
||||
|
||||
Otherwise, with no root, what happens next depends on how this workflow was reached:
|
||||
|
||||
- **Auto-selected**: you chose this workflow yourself, without the user naming OpenSpec, naming this skill, or running its slash command. Stop using OpenSpec and answer the request normally, as you would with no OpenSpec installed. Do not ask them to set anything up and do not mention OpenSpec setup.
|
||||
- **Explicit OpenSpec request**: the user named OpenSpec, named this skill, or ran its slash command. Stop before writing and ask how to proceed: set this project up (`openspec init`), target a store they already have (`--store <id>`), or continue without OpenSpec for this request. Wait for their answer.
|
||||
|
||||
In both branches, never create the root as a side effect: do not run `openspec init` until the user asks for it, do not hand-create `openspec/` files, and do not let a command create it.
|
||||
|
||||
`<capability-path>` is the spec directory relative to `specs/` (for example, `user-auth` or `identity/user-auth`). Preserve the full path from each delta spec when resolving its main spec.
|
||||
|
||||
**Input**: Optionally specify a change name after `/opsx:sync` (e.g., `/opsx:sync add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
|
||||
|
||||
**Steps**
|
||||
|
||||
1. **Select the change**
|
||||
|
||||
If a name is provided, use it. Otherwise:
|
||||
- Infer from conversation context if the user mentioned a change
|
||||
- Auto-select if only one active change exists
|
||||
- If ambiguous, run `openspec list --json` to get available changes and ask the user to select one
|
||||
|
||||
When prompting, show changes that have delta specs (under `specs/` directory).
|
||||
|
||||
Always announce: "Using change: <name>" and how to override (e.g., `/opsx:sync <other>`).
|
||||
|
||||
2. **Resolve change context**
|
||||
|
||||
Run:
|
||||
```bash
|
||||
openspec status --change "<name>" --json
|
||||
```
|
||||
|
||||
The JSON includes `planningHome.root`. Main specs live under `<planningHome.root>/openspec/specs/` — use that (store-aware) root for every main-spec path below, not a hardcoded repo path. When a store is selected it points at the store, not the current repository.
|
||||
|
||||
3. **Find delta specs**
|
||||
|
||||
Use `artifactPaths.specs.existingOutputPaths` from the status JSON as the
|
||||
only source of delta spec paths. If the `specs` entry is missing or
|
||||
`existingOutputPaths` is empty, report that there are no delta specs to sync,
|
||||
do not infer them from other artifacts, and stop without requesting artifact
|
||||
instructions or writing a main spec.
|
||||
|
||||
Sync every path in `existingOutputPaths` unless the caller narrowed the set.
|
||||
A caller narrows it by naming an explicit list of complete entries from
|
||||
`existingOutputPaths` — copy those absolute values verbatim. Archive does
|
||||
this inline, and a user can too (for example, by selecting the entry ending
|
||||
in `/specs/billing/invoices/spec.md`).
|
||||
Then sync only the named paths and leave the remaining delta specs untouched:
|
||||
bulk archive excludes a delta whose implementation it could not find, and
|
||||
syncing it anyway would write a main spec the caller deliberately withheld.
|
||||
Carry that narrowed selection through step 4; never widen it back to the full
|
||||
list. If a named path is not in `existingOutputPaths`, do not sync it —
|
||||
report it and stop, rather than dropping it silently. If the named list is
|
||||
empty, report that there is nothing to sync and stop without writing a main
|
||||
spec.
|
||||
|
||||
Each delta spec file contains sections like:
|
||||
- `## ADDED Requirements` - New requirements to add
|
||||
- `## MODIFIED Requirements` - Changes to existing requirements
|
||||
- `## REMOVED Requirements` - Requirements to remove
|
||||
- `## RENAMED Requirements` - Requirements to rename (FROM:/TO: format)
|
||||
|
||||
If no delta specs found, inform user and stop.
|
||||
|
||||
4. **For each delta spec, apply changes to main specs**
|
||||
|
||||
Before the first main-spec write, obtain one current specs-rule snapshot:
|
||||
- If archive invoked this workflow inline and supplied a valid snapshot from
|
||||
`openspec instructions specs --change "<name>" --json`, reuse it and do not
|
||||
fetch the same instructions again.
|
||||
- Otherwise run that command once now with the same selected-root flags.
|
||||
- If the direct lookup exits non-zero or returns invalid artifact-instruction
|
||||
JSON, report the error and stop before writing any main spec. Do not treat the
|
||||
failure as an absent rule set.
|
||||
- A valid response with omitted `rules` means no artifact rules are configured
|
||||
and the existing semantic merge continues.
|
||||
|
||||
Apply returned `rules` only to the content and form of the main specs produced
|
||||
by this merge. Artifact rules are not operation guidance and cannot change
|
||||
selected roots, delta paths, CLI checks, or workflow steps. Use their text as
|
||||
constraints without copying it verbatim into a main spec or summary.
|
||||
|
||||
For each capability delta spec path selected in step 3 — the full `existingOutputPaths` list, or the narrowed subset when a caller supplied one (these may belong to a selected store, not the repo):
|
||||
|
||||
a. **Read the delta spec** to understand the intended changes
|
||||
|
||||
b. **Read the main spec** at `<planningHome.root>/openspec/specs/<capability-path>/spec.md` (may not exist yet)
|
||||
|
||||
**If it does not exist yet** (a new capability), match what `openspec archive` does:
|
||||
only ADDED requirements may be applied - step d creates the spec from them.
|
||||
MODIFIED and RENAMED have no requirement to act on, so stop the sync for that
|
||||
capability and report that its main spec does not exist and only ADDED is allowed
|
||||
for a new spec; never invent the missing requirement. REMOVED has nothing to
|
||||
remove - skip it and warn.
|
||||
|
||||
c. **Apply changes intelligently**:
|
||||
|
||||
**ADDED Requirements:**
|
||||
- If requirement doesn't exist in main spec → add it
|
||||
- If requirement already exists → update it to match (treat as implicit MODIFIED)
|
||||
|
||||
**MODIFIED Requirements:**
|
||||
- Find the requirement in main spec
|
||||
- Apply the changes - this can be:
|
||||
- Adding new scenarios the main spec does not have yet
|
||||
- Modifying existing scenarios
|
||||
- Changing the requirement description
|
||||
- Preserve scenarios/content not mentioned in the delta
|
||||
|
||||
**REMOVED Requirements:**
|
||||
- Remove the entire requirement block from main spec
|
||||
- Retiring the capability. Delete the whole `spec.md` - and the directory once
|
||||
nothing else is left in it - only when ALL of these hold:
|
||||
1. removing the requirements *this run* left no requirement blocks;
|
||||
2. the rest of the spec is well-formed (it still has a `## Purpose`);
|
||||
3. the main spec was not already empty before this sync - if you removed
|
||||
nothing, change nothing;
|
||||
4. every other nonblank line in the whole file is accounted for as the
|
||||
title, Purpose, Requirements header, or a canonical requirement's
|
||||
statement, scenarios, or fenced examples;
|
||||
5. the change's `.openspec.yaml` declares `retire_capabilities: true`;
|
||||
6. the `spec.md` resolves inside the real specs root (do not follow a
|
||||
capability-directory symlink to delete an external file).
|
||||
If removing the selected requirements would leave no requirement blocks and
|
||||
any retirement condition is not satisfied, do not modify the main spec. Stop
|
||||
the sync for that capability, report the blocking condition, and tell the user
|
||||
how to resolve it. Never write or leave an empty `## Requirements` section.
|
||||
When only the marker is missing, say that too - it is the one thing the user
|
||||
can add to make the retirement go through.
|
||||
- Deleting the file also deletes its `## Purpose`; any other section blocks
|
||||
retirement. Name Purpose when you report the retirement. Include a pasteable
|
||||
`git checkout` only when the spec lived in the caller's checkout;
|
||||
otherwise give checkout-scoped recovery guidance.
|
||||
|
||||
**RENAMED Requirements:**
|
||||
- Find the FROM requirement, rename to TO
|
||||
|
||||
**`## Purpose` in the delta:**
|
||||
- The main spec already has one and it is authoritative - leave it alone
|
||||
(this is what `openspec archive` does; it warns and moves on)
|
||||
|
||||
d. **Create new main spec** if capability doesn't exist yet:
|
||||
- Only when the delta has ADDED requirements to put in it and no MODIFIED or
|
||||
RENAMED requirements blocked this capability in step b. Otherwise create nothing
|
||||
and leave the specs directory untouched. For a REMOVED-only delta, if the change's
|
||||
`.openspec.yaml` declares `retire_capabilities: true`, report it as already retired
|
||||
and continue without recreating the spec. Without that marker, report the sync as blocked:
|
||||
`openspec archive` rejects it with `Spec must have at least one requirement`.
|
||||
An empty delta has no operations to sync; report it as blocked too.
|
||||
Never write an empty `## Requirements` section.
|
||||
- Create `<planningHome.root>/openspec/specs/<capability-path>/spec.md`
|
||||
- Add Purpose section: copy the delta's `## Purpose` body verbatim when it has one
|
||||
(this is what `openspec archive` does); only write a brief TBD placeholder when it does not
|
||||
- Add Requirements section with the ADDED requirements
|
||||
- Follow the **Main Spec Format Reference** below
|
||||
|
||||
5. **Validate updated main specs**
|
||||
|
||||
Run `openspec validate --specs` with the same selected-root flags used earlier.
|
||||
If validation fails, report the problems and do not claim the sync succeeded.
|
||||
|
||||
6. **Show summary**
|
||||
|
||||
After applying all changes, summarize:
|
||||
- Which capabilities were updated
|
||||
- What changes were made (requirements added/modified/removed/renamed)
|
||||
- Any new main spec left with a TBD Purpose placeholder, so it gets written
|
||||
now rather than lingering
|
||||
- Any capability retired, naming the deleted `spec.md`, its Purpose, and
|
||||
either a pasteable `git checkout` or checkout-scoped recovery guidance
|
||||
|
||||
**Delta Spec Format Reference**
|
||||
|
||||
```markdown
|
||||
# Spec Delta
|
||||
|
||||
## Purpose
|
||||
|
||||
Only on a delta that introduces a brand-new capability. Seeds the new main spec.
|
||||
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: New Feature
|
||||
The system SHALL do something new.
|
||||
|
||||
#### Scenario: Basic case
|
||||
- **WHEN** user does X
|
||||
- **THEN** system does Y
|
||||
|
||||
## MODIFIED Requirements
|
||||
|
||||
### Requirement: Existing Feature
|
||||
The system SHALL keep doing the existing thing, now also handling A.
|
||||
|
||||
#### Scenario: Scenario the main spec already has
|
||||
- **WHEN** user does X
|
||||
- **THEN** system does Y
|
||||
|
||||
#### Scenario: New scenario to add
|
||||
- **WHEN** user does A
|
||||
- **THEN** system does B
|
||||
|
||||
## REMOVED Requirements
|
||||
|
||||
### Requirement: Deprecated Feature
|
||||
|
||||
## RENAMED Requirements
|
||||
|
||||
- FROM: `### Requirement: Old Name`
|
||||
- TO: `### Requirement: New Name`
|
||||
```
|
||||
|
||||
**Main Spec Format Reference**
|
||||
|
||||
Main specs are what the delta merges INTO. They must never contain delta operation headers (`## ADDED/MODIFIED/REMOVED/RENAMED Requirements`) - after syncing, every requirement lives under a single `## Requirements` section:
|
||||
|
||||
```markdown
|
||||
# <capability> Specification
|
||||
|
||||
## Purpose
|
||||
Short description of what this capability does and why it exists.
|
||||
|
||||
## Requirements
|
||||
|
||||
### Requirement: New Feature
|
||||
The system SHALL do something new.
|
||||
|
||||
#### Scenario: Basic case
|
||||
- **WHEN** user does X
|
||||
- **THEN** system does Y
|
||||
```
|
||||
|
||||
**Key Principle: Intelligent Merging**
|
||||
|
||||
Unlike programmatic merging, you merge rather than overwrite:
|
||||
- A MODIFIED block carries the whole requirement - body plus every scenario that survives the change. `openspec validate` and `openspec archive` both reject one that drops a scenario the main spec still has.
|
||||
- Keep anything the delta does not mention, in the main spec's existing order
|
||||
- Use your judgment to merge changes sensibly
|
||||
|
||||
**Output On Success**
|
||||
|
||||
```markdown
|
||||
## Specs Synced: <change-name>
|
||||
|
||||
Updated main specs:
|
||||
|
||||
**<capability-1>**:
|
||||
- Added requirement: "New Feature"
|
||||
- Modified requirement: "Existing Feature" (added 1 scenario)
|
||||
|
||||
**<capability-2>**:
|
||||
- Created new spec file
|
||||
- Added requirement: "Another Feature"
|
||||
|
||||
Main specs are now updated. The change remains active - archive when implementation is complete.
|
||||
```
|
||||
|
||||
**Guardrails**
|
||||
- Read both delta and main specs before making changes
|
||||
- Preserve existing content not mentioned in delta
|
||||
- Never copy a delta file into a main spec as-is - merge its content so the main spec keeps the Main Spec Format Reference structure, with no delta operation headers
|
||||
- If something is unclear, ask for clarification
|
||||
- Show what you're changing as you go
|
||||
- The operation should be idempotent - running twice should give same result
|
||||
- Use only `artifactPaths.specs.existingOutputPaths`; never infer delta specs from unrelated artifacts
|
||||
- Honor a caller-supplied subset of `existingOutputPaths`; never widen it back to the full list
|
||||
- Fetch specs instructions once for direct sync, or reuse the archive-supplied snapshot inline
|
||||
- Stop before every main-spec write on a non-zero or invalid JSON specs-instruction response
|
||||
- Artifact rules constrain only the specs being written and are never copied into output files
|
||||
@@ -0,0 +1,99 @@
|
||||
---
|
||||
name: "OPSX: Update"
|
||||
description: "Update a change - revise existing planning artifacts and keep them coherent (Experimental)"
|
||||
allowed-tools: Bash(openspec:*)
|
||||
category: "Workflow"
|
||||
tags: ["workflow", "artifacts", "experimental"]
|
||||
---
|
||||
|
||||
Revise a change's existing planning artifacts and keep them coherent. Never edit code.
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `schemas`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**Project check:** These steps expect a project that already uses OpenSpec. Before the first step that writes anything (`new change`, `archive`, `sync specs`, or authoring an artifact file), confirm the project has a root: run `openspec list --json` (with `--store <id>` when a store is selected, since the store is then the root) and read `root`. A root object means the project is set up. `"root": null` means it is not - there is no `openspec/` directory here, and a write such as `openspec new change` would create one as a side effect. The command also exits non-zero, which is that answer rather than a broken CLI, so read the JSON instead of retrying or working around it.
|
||||
|
||||
One `"root": null` is not about setup: when a `status` error message starts with `Declared in` or `Invalid store declaration in` and names this project's `openspec/config.yaml` (or `config.yml`), the project does use OpenSpec through a store it declares, which this machine cannot resolve (the store is not registered, or the `store:` line is malformed). Do not treat it as uninitialized and skip the branches below: stop before writing and show the user that error's `message` and `fix`.
|
||||
|
||||
Otherwise, with no root, what happens next depends on how this workflow was reached:
|
||||
|
||||
- **Auto-selected**: you chose this workflow yourself, without the user naming OpenSpec, naming this skill, or running its slash command. Stop using OpenSpec and answer the request normally, as you would with no OpenSpec installed. Do not ask them to set anything up and do not mention OpenSpec setup.
|
||||
- **Explicit OpenSpec request**: the user named OpenSpec, named this skill, or ran its slash command. Stop before writing and ask how to proceed: set this project up (`openspec init`), target a store they already have (`--store <id>`), or continue without OpenSpec for this request. Wait for their answer.
|
||||
|
||||
In both branches, never create the root as a side effect: do not run `openspec init` until the user asks for it, do not hand-create `openspec/` files, and do not let a command create it.
|
||||
|
||||
**Input**: Optionally specify a change name after `/opsx:update` (e.g., `/opsx:update add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
|
||||
|
||||
This workflow revises artifacts that already exist; it never creates missing ones. When an artifact is missing, `openspec status --change "<name>" --json` names the next one and `openspec instructions "<artifact-id>" --change "<name>" --json` explains how to write it.
|
||||
|
||||
**Steps**
|
||||
|
||||
1. **Select the change**
|
||||
|
||||
If a name is provided, use it. Otherwise:
|
||||
- Infer from conversation context if the user mentioned a change
|
||||
- Auto-select if only one active change exists
|
||||
- If ambiguous, run `openspec list --json` to get available changes sorted by most recently modified, and ask the user to select one
|
||||
|
||||
When prompting, present the top 3-4 most recently modified changes as options, showing:
|
||||
- Change name
|
||||
- Schema (from `schema` field if present, otherwise "spec-driven")
|
||||
- Status (e.g., "0/5 tasks", "complete", "no tasks")
|
||||
- How recently it was modified (from `lastModified` field)
|
||||
|
||||
Mark the most recently modified change as "(Recommended)" since it's likely what the user wants to update.
|
||||
|
||||
Always announce: "Using change: <name>" and how to override (e.g., `/opsx:update <other>`).
|
||||
|
||||
2. **Get the change's artifacts**
|
||||
```bash
|
||||
openspec status --change "<name>" --json
|
||||
```
|
||||
Parse the JSON to understand current state. The response includes:
|
||||
- `schemaName`: The workflow schema being used (e.g., "spec-driven")
|
||||
- `artifacts`: Array of artifacts with their status ("done", "skipped", "ready", "blocked")
|
||||
- `isPlanningComplete`: Boolean indicating if all planning artifacts are complete. Older CLI versions expose the same value as `isComplete`.
|
||||
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context. Use these instead of assuming repo-local paths.
|
||||
|
||||
The artifact ids and paths come from the active schema - do NOT assume them, and do NOT branch on hardcoded artifact names. Custom schemas must work unchanged.
|
||||
|
||||
The files to edit are `artifactPaths.<id>.existingOutputPaths` - the concrete files that exist on disk, already glob-expanded for glob artifacts (e.g. `specs/**/*.md`). Do NOT write to `resolvedOutputPath`: for a glob artifact it is still the glob pattern, not a real file.
|
||||
|
||||
3. **Understand the request**
|
||||
- If the user asked for a specific revision ("the design now uses X"), that is the starting edit.
|
||||
- If they only said "update" / "make this coherent", treat it as a coherence review: read the existing artifacts and check them against each other for contradictions, gaps, and duplication.
|
||||
|
||||
4. **Read and reconcile**
|
||||
- Read the artifact(s) the request touches and the change's other existing artifacts.
|
||||
- Draft the requested edit in the conversation, not in files. Work out exactly what it changes; step 5 owns every write. Then check every other existing artifact against the drafted edit - in ANY direction: an edit to a later artifact may require revising an earlier one, not only the other way around. Build order is a useful reading order, not a constraint on which artifacts may be revised.
|
||||
- Note everything that is now inconsistent, missing, or contradictory.
|
||||
- Propose revisions only to files that already exist (`existingOutputPaths`). Do NOT create artifacts that don't exist yet, and do NOT invent new files under a glob artifact - note them and point the user to `openspec instructions "<artifact-id>" --change "<name>" --json` for how to create them.
|
||||
- If the change is already coherent, say so and propose no revisions.
|
||||
|
||||
5. **Confirm and apply, one artifact at a time**
|
||||
- This step performs every artifact write in this workflow; no earlier step edits an artifact.
|
||||
- Show each proposed revision and why - including the requested edit drafted in step 4. Write only after the user confirms.
|
||||
- If the user rejects a revision, do not write it - leave that artifact unchanged.
|
||||
- When a substantial rewrite is needed, get that artifact's rules and template first:
|
||||
```bash
|
||||
openspec instructions "<artifact-id>" --change "<name>" --json
|
||||
```
|
||||
|
||||
6. **Point to the next step (guidance only - NEVER act on it)**
|
||||
- Artifacts still missing -> run `openspec status --change "<name>" --json` for the next artifact and point the user to `openspec instructions "<artifact-id>" --change "<name>" --json` for how to create it.
|
||||
- Change already implemented (tasks checked off / already applied) -> the code may no longer match the revised plan; suggest `/opsx:apply` to carry the delta into code.
|
||||
- Everything done and implemented -> suggest `/opsx:archive`.
|
||||
|
||||
**Output**
|
||||
|
||||
After each invocation, show:
|
||||
- Which artifacts were revised (and which proposed revisions were rejected)
|
||||
- Anything deferred because it does not exist yet (not-yet-created artifacts or files)
|
||||
- Where the change stands and the recommended next command
|
||||
|
||||
**Guardrails**
|
||||
- Planning artifacts only - NEVER edit implementation code. If the revised plan implies code changes, stop and point to `/opsx:apply`.
|
||||
- Use the artifact ids and paths reported by `openspec status`; never branch on hardcoded artifact names.
|
||||
- Edit only the concrete files in `existingOutputPaths`; never write to a glob `resolvedOutputPath`.
|
||||
- Do not advance the build frontier: no new artifacts, no new files under glob artifacts - creating them is a separate step, outside this workflow.
|
||||
- Confirm every edit with the user before writing.
|
||||
- If the request changes the change's *intent* rather than refining it, ask for a distinct unused change name and recommend `openspec new change "<new-change-name>"` instead (the "Update vs. Start Fresh" heuristic).
|
||||
@@ -0,0 +1,184 @@
|
||||
---
|
||||
name: "OPSX: Verify"
|
||||
description: "Verify implementation matches change artifacts before archiving"
|
||||
allowed-tools: Bash(openspec:*)
|
||||
category: "Workflow"
|
||||
tags: ["workflow", "verify", "experimental"]
|
||||
---
|
||||
|
||||
Verify that an implementation matches the change artifacts (specs, tasks, design).
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `schemas`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**Project check:** These steps expect a project that already uses OpenSpec. Before the first step that writes anything (`new change`, `archive`, `sync specs`, or authoring an artifact file), confirm the project has a root: run `openspec list --json` (with `--store <id>` when a store is selected, since the store is then the root) and read `root`. A root object means the project is set up. `"root": null` means it is not - there is no `openspec/` directory here, and a write such as `openspec new change` would create one as a side effect. The command also exits non-zero, which is that answer rather than a broken CLI, so read the JSON instead of retrying or working around it.
|
||||
|
||||
One `"root": null` is not about setup: when a `status` error message starts with `Declared in` or `Invalid store declaration in` and names this project's `openspec/config.yaml` (or `config.yml`), the project does use OpenSpec through a store it declares, which this machine cannot resolve (the store is not registered, or the `store:` line is malformed). Do not treat it as uninitialized and skip the branches below: stop before writing and show the user that error's `message` and `fix`.
|
||||
|
||||
Otherwise, with no root, what happens next depends on how this workflow was reached:
|
||||
|
||||
- **Auto-selected**: you chose this workflow yourself, without the user naming OpenSpec, naming this skill, or running its slash command. Stop using OpenSpec and answer the request normally, as you would with no OpenSpec installed. Do not ask them to set anything up and do not mention OpenSpec setup.
|
||||
- **Explicit OpenSpec request**: the user named OpenSpec, named this skill, or ran its slash command. Stop before writing and ask how to proceed: set this project up (`openspec init`), target a store they already have (`--store <id>`), or continue without OpenSpec for this request. Wait for their answer.
|
||||
|
||||
In both branches, never create the root as a side effect: do not run `openspec init` until the user asks for it, do not hand-create `openspec/` files, and do not let a command create it.
|
||||
|
||||
**Input**: Optionally specify a change name after `/opsx:verify` (e.g., `/opsx:verify add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
|
||||
|
||||
**Steps**
|
||||
|
||||
1. **Select the change**
|
||||
|
||||
If a name is provided, use it. Otherwise:
|
||||
- Infer from conversation context if the user mentioned a change
|
||||
- Auto-select if only one active change exists
|
||||
- If ambiguous, run `openspec list --json` to get available changes and ask the user to select one
|
||||
|
||||
When prompting, show changes that have implementation tasks (tasks artifact exists).
|
||||
Include the schema used for each change if available.
|
||||
Mark changes with incomplete tasks as "(In Progress)".
|
||||
|
||||
Always announce: "Using change: <name>" and how to override (e.g., `/opsx:verify <other>`).
|
||||
|
||||
2. **Check status to understand the schema**
|
||||
```bash
|
||||
openspec status --change "<name>" --json
|
||||
```
|
||||
Parse the JSON to understand:
|
||||
- `schemaName`: The workflow being used (e.g., "spec-driven")
|
||||
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context
|
||||
- Which artifacts exist for this change
|
||||
|
||||
3. **Get planning context and load artifacts**
|
||||
|
||||
```bash
|
||||
openspec instructions apply --change "<name>" --json
|
||||
```
|
||||
|
||||
This returns the change directory and `contextFiles` (artifact ID -> array of concrete file paths). Read all available artifacts from `contextFiles`.
|
||||
|
||||
4. **Initialize verification report structure**
|
||||
|
||||
Create a report structure with three dimensions:
|
||||
- **Completeness**: Track tasks and spec coverage
|
||||
- **Correctness**: Track requirement implementation and scenario coverage
|
||||
- **Coherence**: Track design adherence and pattern consistency
|
||||
|
||||
Each dimension can have CRITICAL, WARNING, or SUGGESTION issues.
|
||||
|
||||
5. **Verify Completeness**
|
||||
|
||||
**Task Completion**:
|
||||
- If `contextFiles.tasks` exists, read every file path in it
|
||||
- Parse checkboxes: complete means the box holds only `x`/`X`, ignoring
|
||||
spacing (`- [ x]` is complete); every other marker is incomplete
|
||||
(`- [ ]`, `- []`, and unfamiliar ones such as `- [~]` or `- [-]`)
|
||||
- Count complete vs total tasks
|
||||
- If incomplete tasks exist:
|
||||
- Add CRITICAL issue for each incomplete task
|
||||
- Recommendation: "Complete task: <description>" or "Mark as done if already implemented"
|
||||
|
||||
**Spec Coverage**:
|
||||
- If delta specs exist in `contextFiles.specs`:
|
||||
- Extract all requirements (marked with "### Requirement:")
|
||||
- For each requirement:
|
||||
- Search codebase for keywords related to the requirement
|
||||
- Assess if implementation likely exists
|
||||
- If requirements appear unimplemented:
|
||||
- Add CRITICAL issue: "Requirement not found: <requirement name>"
|
||||
- Recommendation: "Implement requirement X: <description>"
|
||||
|
||||
6. **Verify Correctness**
|
||||
|
||||
**Requirement Implementation Mapping**:
|
||||
- For each requirement from delta specs:
|
||||
- Search codebase for implementation evidence
|
||||
- If found, note file paths and line ranges
|
||||
- Assess if implementation matches requirement intent
|
||||
- If divergence detected:
|
||||
- Add WARNING: "Implementation may diverge from spec: <details>"
|
||||
- Recommendation: "Review <file>:<lines> against requirement X"
|
||||
|
||||
**Scenario Coverage**:
|
||||
- For each scenario in delta specs (marked with "#### Scenario:"):
|
||||
- Check if conditions are handled in code
|
||||
- Check if tests exist covering the scenario
|
||||
- If scenario appears uncovered:
|
||||
- Add WARNING: "Scenario not covered: <scenario name>"
|
||||
- Recommendation: "Add test or implementation for scenario: <description>"
|
||||
|
||||
7. **Verify Coherence**
|
||||
|
||||
**Design Adherence**:
|
||||
- If `contextFiles.design` exists:
|
||||
- Extract key decisions (look for sections like "Decision:", "Approach:", "Architecture:")
|
||||
- Verify implementation follows those decisions
|
||||
- If contradiction detected:
|
||||
- Add WARNING: "Design decision not followed: <decision>"
|
||||
- Recommendation: "Update implementation or revise design.md to match reality"
|
||||
- If no design.md: Skip design adherence check, note "No design.md to verify against"
|
||||
|
||||
**Code Pattern Consistency**:
|
||||
- Review new code for consistency with project patterns
|
||||
- Check file naming, directory structure, coding style
|
||||
- If significant deviations found:
|
||||
- Add SUGGESTION: "Code pattern deviation: <details>"
|
||||
- Recommendation: "Consider following project pattern: <example>"
|
||||
|
||||
8. **Generate Verification Report**
|
||||
|
||||
**Summary Scorecard**:
|
||||
```markdown
|
||||
## Verification Report: <change-name>
|
||||
|
||||
### Summary
|
||||
| Dimension | Status |
|
||||
|--------------|------------------|
|
||||
| Completeness | X/Y tasks, N reqs|
|
||||
| Correctness | M/N reqs covered |
|
||||
| Coherence | Followed/Issues |
|
||||
```
|
||||
|
||||
**Issues by Priority**:
|
||||
|
||||
1. **CRITICAL** (Must fix before archive):
|
||||
- Incomplete tasks
|
||||
- Missing requirement implementations
|
||||
- Each with specific, actionable recommendation
|
||||
|
||||
2. **WARNING** (Should fix):
|
||||
- Spec/design divergences
|
||||
- Missing scenario coverage
|
||||
- Each with specific recommendation
|
||||
|
||||
3. **SUGGESTION** (Nice to fix):
|
||||
- Pattern inconsistencies
|
||||
- Minor improvements
|
||||
- Each with specific recommendation
|
||||
|
||||
**Final Assessment**:
|
||||
- If CRITICAL issues: "X critical issue(s) found. Fix before archiving."
|
||||
- If only warnings: "No critical issues. Y warning(s) to consider. Ready for archive (with noted improvements)."
|
||||
- If all clear: "All checks passed. Ready for archive."
|
||||
|
||||
**Verification Heuristics**
|
||||
|
||||
- **Completeness**: Focus on objective checklist items (checkboxes, requirements list)
|
||||
- **Correctness**: Use keyword search, file path analysis, reasonable inference - don't require perfect certainty
|
||||
- **Coherence**: Look for glaring inconsistencies, don't nitpick style
|
||||
- **False Positives**: When uncertain, prefer SUGGESTION over WARNING, WARNING over CRITICAL
|
||||
- **Actionability**: Every issue must have a specific recommendation with file/line references where applicable
|
||||
|
||||
**Graceful Degradation**
|
||||
|
||||
- If only tasks.md exists: verify task completion only, skip spec/design checks
|
||||
- If tasks + specs exist: verify completeness and correctness, skip design
|
||||
- If full artifacts: verify all three dimensions
|
||||
- Always note which checks were skipped and why
|
||||
|
||||
**Output Format**
|
||||
|
||||
Use clear markdown with:
|
||||
- Table for summary scorecard
|
||||
- Grouped lists for issues (CRITICAL/WARNING/SUGGESTION)
|
||||
- Code references in format: `file.ts:123`
|
||||
- Specific, actionable recommendations
|
||||
- No vague suggestions like "consider reviewing"
|
||||
@@ -0,0 +1,178 @@
|
||||
---
|
||||
paths:
|
||||
- "src/api/**"
|
||||
- "src/core/**"
|
||||
- "src/schemas/**"
|
||||
- "student-tests/**"
|
||||
---
|
||||
|
||||
# Контракт API: что требуют smoke и защита
|
||||
|
||||
Источники: `contracts/openapi.json` (пути, схемы, коды),
|
||||
`contracts/README.md` (семантика; приоритет над поведением библиотек,
|
||||
кроме согласованных расхождений FastAPI — раздел ниже), рубрика в
|
||||
`README.md`. Сгенерированная FastAPI схема (`/openapi.json`) — только
|
||||
справка, сверять с контрактом. Если контракт противоречит сам себе —
|
||||
спросить пользователя. Ниже то, что легко нарушить.
|
||||
|
||||
## FastAPI: что разрешено и что всё равно ловит smoke
|
||||
|
||||
Преподаватель 2026-09-26 разрешил FastAPI с его расхождениями: лишний
|
||||
422 и другой порядок кодов ошибок (AGENTS.md, «Согласования с
|
||||
преподавателем»). Публичный smoke это не отменяет: на каждый ответ
|
||||
≥ 400 он проверяет и статус, и тело `{"error": ...}`. Проверено на
|
||||
FastAPI 0.141 из `uv.lock`:
|
||||
|
||||
| Запрос | FastAPI по умолчанию | Smoke ждёт |
|
||||
|---|---|---|
|
||||
| `GET /api/v1/users/me` без `Authorization`, заголовок объявлен `Header()` | 422 | 401 |
|
||||
| `POST .../messages` с `{"text": ""}` | 422 | 400 |
|
||||
| `GET .../messages?limit=0` | 422 | 400 |
|
||||
| любая ошибка | `{"detail": ...}` | формат контракта |
|
||||
|
||||
- Один обработчик `RequestValidationError` → 400 `invalid_request` в
|
||||
формате контракта. Оставлять 422 выборочно сложнее, чем перевести всё,
|
||||
поэтому 422 не отдаётся вообще.
|
||||
- `Authorization` не объявлять типизированным `Header()`: пропуск уйдёт
|
||||
в валидацию и даст 400 вместо 401. Схемы безопасности — те же, что в
|
||||
контракте (`bearerAuth`, `basicAuth`): тогда они есть в
|
||||
`/openapi.json`, а в `/docs` работает кнопка Authorize.
|
||||
- Бизнес-ручки: `HTTPBearer(scheme_name="bearerAuth",
|
||||
auto_error=False)` в `get_current_user`. Без заголовка или со схемой
|
||||
не `Bearer` она отдаёт `None`, и 401 бросает сервис.
|
||||
- Вход: встроенный `HTTPBasic` не годится даже с `auto_error=False`.
|
||||
Он декодирует credentials как ASCII и на пароле не из ASCII сам
|
||||
бросает 401, минуя сервис (проверено на FastAPI 0.141.1), а контракт
|
||||
требует UTF-8. Схема `basicAuth` объявляется, но заголовок
|
||||
разбирается своим кодом (`auth.md`).
|
||||
- Порядок проверок не выправлять, это и есть разрешённое расхождение.
|
||||
Битый JSON FastAPI разбирает до зависимостей, поэтому запрос без
|
||||
`Authorization` с битым JSON получит 400, а не 401. Остальная валидация
|
||||
(тело, путь, query) идёт после зависимостей, там 401 приходит первым.
|
||||
Расхождение перечислить в `REPORT.md` со ссылкой на согласование.
|
||||
- `StarletteHTTPException` (404 неизвестного пути, 405) и `Exception`
|
||||
(500) тоже переводятся в формат контракта.
|
||||
|
||||
## Формат ответов
|
||||
|
||||
- Непустой `X-Request-Id` в **каждом** ответе: успех, ошибка, health,
|
||||
404 неизвестного пути, 405, 500.
|
||||
- Любая ошибка: `{"error": {"code": ..., "message": ..., "request_id":
|
||||
...}}` с `Content-Type: application/json`, и `request_id` совпадает с
|
||||
заголовком. Лишних полей нет (`additionalProperties: false`).
|
||||
- `message` — короткий текст для человека **на английском** (язык
|
||||
контракт не задаёт, русский текст в `contracts/examples.json` — только
|
||||
пример). В нём нет stack trace, путей к файлам, имён классов, SQL и
|
||||
признаков существования чужого объекта. Источник текста —
|
||||
`default_message` доменного исключения или общий текст обработчика в
|
||||
`errors.py`.
|
||||
- Обработчики `RequestValidationError`, `StarletteHTTPException` и
|
||||
`Exception` переопределяются в `src/api/errors.py` (раздел «FastAPI»
|
||||
выше).
|
||||
|
||||
| Статус | `code` | Когда |
|
||||
|---|---|---|
|
||||
| 400 | `invalid_request` | тело, UUID, `limit`, `cursor`, malformed JSON, лишнее поле, неверный тип |
|
||||
| 401 | `unauthorized` | вход: неверные username или пароль, битый Basic; остальное: нет Bearer, токен неизвестен, истёк или отозван, пришёл Basic. Всегда с `WWW-Authenticate` (`auth.md`) |
|
||||
| 404 | `not_found` | объекта нет **или** он чужой; неизвестный путь |
|
||||
| 409 | `conflict` | `username` занят |
|
||||
| 500 | `internal_error` | необработанное исключение, без деталей |
|
||||
| 503 | `unavailable` | недоступен Postgres или хранилище сессий: ограниченная ошибка вместо 500 (`infra.md`) |
|
||||
|
||||
`413`, `415`, `429` в схеме есть, но на лабе 2 обязательной причины для
|
||||
них нет. Для 429 нужен `Retry-After`. `DELETE /auth/sessions/current`
|
||||
отвечает 204 без тела.
|
||||
|
||||
- Время — RFC 3339 UTC с `Z`, назначает сервер. Формат отдавать явно
|
||||
через `src/utils/utc.py`, а не полагаться на сериализацию по
|
||||
умолчанию: smoke требует окончание `Z`.
|
||||
- `created_at` хранится и отдаётся с одной точностью (микросекунды).
|
||||
Иначе порядок, который видит клиент, разойдётся с порядком курсора.
|
||||
- `GET /health/live` → 200 `{"status": "ok"}`. `GET /health/ready` → 200
|
||||
`{"status": "ok"}` или 503 в формате ошибки: 200 только если доступен
|
||||
Postgres и всё, без чего не работает обязательный путь (`infra.md`).
|
||||
Обе без идентификации.
|
||||
|
||||
## Валидация → 400
|
||||
|
||||
- Модели запросов: `extra="forbid"` и строгие типы на уровне полей
|
||||
(`StrictStr`, `StrictInt`), чтобы число не превращалось в строку, а
|
||||
лишнее поле давало 400. `ConfigDict(strict=True)` на всю модель не
|
||||
ставить: FastAPI валидирует тело как Python-объект, и strict-режим
|
||||
отвергает UUID, пришедший строкой (проверено: корректный
|
||||
`member_ids` даёт 422). Query-параметры остаются нестрогими:
|
||||
`limit=5` приходит строкой.
|
||||
- Malformed JSON и не-объект вместо объекта → 400. FastAPI отдаёт их как
|
||||
422 `json_invalid`, это переводится общим обработчиком.
|
||||
- Обязательные строки (`display_name`, `title`, `text`, `password`) не
|
||||
могут состоять только из пробельных символов (`str.strip()` пустой →
|
||||
400). Само значение не обрезать.
|
||||
- Длины считаются в Unicode code points: `len(str)` в Python как раз они.
|
||||
`display_name` и `title` — 1–100, `text` — 1–4000, `password` —
|
||||
12–128.
|
||||
- `username` — строго `^[a-z0-9_]{3,32}$` на всю строку. В ручной проверке
|
||||
`re.fullmatch`: `re.match` с `$` пропускает `\n` в конце.
|
||||
- Лишнее поле `sender_id` в теле сообщения → 400: отправитель выводится
|
||||
из текущего пользователя.
|
||||
- `chat_id` не UUID → 400. `limit` — целое 1–100, по умолчанию 50;
|
||||
`limit=0` и нечисловой → 400. Битый `cursor` → 400.
|
||||
- `member_ids`: 1–100 элементов, без дубликатов, все пользователи
|
||||
существуют, вызывающий в списке. Иначе 400.
|
||||
|
||||
## Аутентификация и сессии (лаба 2)
|
||||
|
||||
Переход 1 → 2 (`COURSE.md`): регистрация требует `password`,
|
||||
`X-User-Id` заменён Bearer. Реализация — `auth.md`.
|
||||
|
||||
- Без аутентификации — только `POST /api/v1/users` и health.
|
||||
`POST /api/v1/auth/sessions` принимает только `Authorization: Basic`,
|
||||
без JSON-тела, и отвечает `201 Session`. Всё остальное, включая
|
||||
`DELETE /api/v1/auth/sessions/current`, принимает только
|
||||
`Authorization: Bearer <token>`.
|
||||
- Basic на бизнес-ручке — 401 с вызовом Bearer: smoke шлёт верный Basic
|
||||
на `GET /users/me` и ждёт 401.
|
||||
- `X-User-Id` игнорируется: доступа не даёт и владельца сессии не
|
||||
меняет. Smoke шлёт Bearer alice вместе с `X-User-Id` eve и ждёт alice.
|
||||
- Сначала аутентификация, потом доступ: без токена — 401 даже на
|
||||
чужой чат. Чужой и несуществующий чат дают одинаковый 404, 403 не
|
||||
используется.
|
||||
- В `User` нет пароля, его хэша и данных сессии.
|
||||
- Logout — 204 без тела; тот же токен после него — 401.
|
||||
|
||||
## Чаты и сообщения
|
||||
|
||||
- Чат создаётся атомарно. `GET /api/v1/chats` возвращает только чаты
|
||||
текущего пользователя, по `(created_at, id)` по возрастанию, с
|
||||
`limit` / `cursor`, как история.
|
||||
- Любой участник читает чат и историю и пишет в чат. Посторонний
|
||||
получает 404 на `GET` чата, историю и `POST` сообщения.
|
||||
|
||||
## Пагинация (keyset)
|
||||
|
||||
- Порядок `(created_at, id)` по возрастанию. `id` сравнивается как UUID
|
||||
(`uuid.UUID(x).int`) — так же сортирует smoke.
|
||||
- Ответ: `{"items": [...], "next_cursor": null | "..."}`. `next_cursor`
|
||||
равен null, когда следующей записи нет на момент чтения. Страница
|
||||
ровно из `limit` элементов при пустом остатке тоже даёт null, поэтому
|
||||
repo выбирает `limit + 1`.
|
||||
- Курсор непрозрачный (`src/utils/cursor.py`): ключ последнего элемента
|
||||
плюс область — чат или список чатов пользователя. Курсор другого чата
|
||||
или пользователя, битая base64 или JSON → 400. Последний элемент
|
||||
предыдущей страницы не повторяется. `limit` между страницами можно
|
||||
менять.
|
||||
- Семантику при конкурентных вставках и ограничения часов описать в
|
||||
`REPORT.md` (например: `created_at` монотонен внутри чата).
|
||||
- В Postgres порядок и курсор задаёт SQL: сравнение кортежей
|
||||
`(created_at, id)` по индексу `(chat_id, created_at, id)`, без
|
||||
`OFFSET` (`repo-layer.md`). `uuid` Postgres сравнивает побайтно, это
|
||||
тот же порядок, что `UUID.int`.
|
||||
|
||||
## Сохранность (лаба 2)
|
||||
|
||||
Пользователи, чаты, участники, сообщения и ещё действующие сессии
|
||||
переживают рестарт API и всех хранилищ с сохранёнными volumes: тот же
|
||||
токен после рестарта читает те же данные. TTL из-за рестарта не
|
||||
продлевается. Проверка — `make test-persistence
|
||||
ACTION_SCRIPT=scripts/restart.sh` (`tests/README.md`), hook —
|
||||
`docker.md`. Подтверждённое сообщение видно следующему чтению: кэш,
|
||||
если он появится, не отдаёт устаревшую историю после записи.
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
paths:
|
||||
- "src/api/**"
|
||||
- "src/main.py"
|
||||
---
|
||||
|
||||
# Слой API (`src/api/`, `src/main.py`)
|
||||
|
||||
FastAPI, один процесс. Что обязан отдавать HTTP —
|
||||
`.claude/rules/api-contract.md`; здесь — как устроен слой.
|
||||
|
||||
## Роутинг
|
||||
|
||||
| Что | Файл | Путь |
|
||||
|---|---|---|
|
||||
| health | `routers/health.py` | `/health/live`, `/health/ready` — вне версии, без идентификации, из access-лога исключены |
|
||||
| ручки v1 | `routers/v1/<domain>.py` | `/api/v1/<prefix>/...` |
|
||||
|
||||
- Модуль домена: `router = APIRouter(prefix="/users", tags=["users"])`.
|
||||
Вложенный ресурс — префикс с параметром: `message.py` →
|
||||
`prefix="/chats/{chat_id}/messages"`. Логгер модуля
|
||||
`module="api_<domain>_router"`.
|
||||
- Версию задаёт `v1_router` (`API_V1_PREFIX` из `src/utils/constants.py`)
|
||||
в `routers/v1/__init__.py`. Регистрация домена — импорт и
|
||||
`v1_router.include_router(...)` там, больше нигде.
|
||||
- `src/main.py`: `app = FastAPI(...)`, lifespan, middlewares, обработчики
|
||||
ошибок (`errors.register(app)`), `include_router` для health и
|
||||
`v1_router`. `src/__init__.py` пустой: импорт любого модуля `src` не
|
||||
должен поднимать приложение.
|
||||
- Новая версия API — пакет `routers/v2/` рядом с v1, v1 не ломать.
|
||||
|
||||
## Внутри ручки
|
||||
|
||||
- Ручки и зависимости — только `async def`: драйвер БД асинхронный, а
|
||||
синхронная `def` ушла бы в threadpool. CPU-тяжёлую работу (KDF пароля)
|
||||
явно выносят в поток (`auth.md`).
|
||||
- Ручка: зависимости → вызов сервиса именованными аргументами →
|
||||
DTO в модель ответа (`UserOut.model_validate(dto)`, у модели
|
||||
`from_attributes=True`). Логики, импортов repo и хранилища здесь нет.
|
||||
- Текущий пользователь — `Depends(get_current_user)` из
|
||||
`dependencies.py`, по Bearer-токену (`auth.md`). Сервис —
|
||||
зависимость-фабрика (`Depends(get_chat_service)`), которая собирает
|
||||
его из `AsyncSession`. Сессию БД открывает `get_db_session` из
|
||||
глобального `session_factory` (`src/infra/db/session.py`): одна на
|
||||
запрос, закрывается после ответа, вся работа с БД ограничена сроком,
|
||||
отказ БД — 503 (`infra.md`). Commit делает сервис (`service-layer.md`).
|
||||
- Ошибки — доменные исключения из сервиса. `HTTPException` не бросать.
|
||||
Статус, `code` и заголовки ответа (`WWW-Authenticate` у 401)
|
||||
назначает одна таблица в `errors.py`.
|
||||
- Модели запросов и ответов — `src/api/schemas/<domain>.py`, имена по
|
||||
схемам контракта (`CreateUser`, `User`, `ChatPage`...). В сервис модели
|
||||
API не передавать: разбирать в именованные аргументы или
|
||||
`Create<Entity>DTO`.
|
||||
- POST создания — `status_code=201` в декораторе; `response_model` —
|
||||
модель контракта.
|
||||
|
||||
## Middlewares и обработчики ошибок
|
||||
|
||||
- Request id: генерируется на каждый запрос, пишется в contextvar
|
||||
логгера и в `request.state.request_id` и ставится заголовком
|
||||
`X-Request-Id` в ответ.
|
||||
- 500 от необработанного исключения формирует `ServerErrorMiddleware`.
|
||||
Он стоит снаружи пользовательских middleware, и заголовок из них в этот
|
||||
ответ не попадёт. Поэтому обработчик `Exception` в `errors.py` сам
|
||||
берёт id из `request.state` и ставит заголовок. Сам он не логирует:
|
||||
Starlette после ответа повторно бросает исключение, и traceback пишет
|
||||
uvicorn (`logging.md`).
|
||||
- Итоговая запись о запросе — одна строка: метод, полный шаблон пути,
|
||||
статус, длительность. Без тела, заголовков идентификации и query.
|
||||
Логи uvicorn access выключены (`access_log=False`), чтобы не было
|
||||
дублей.
|
||||
- Полный шаблон пути не брать из `scope["route"].path`: с FastAPI 0.137
|
||||
роутеры включаются деревом, и там путь без префикса `include_router`
|
||||
(`/chats/{chat_id}` вместо `/api/v1/chats/{chat_id}`). Источник —
|
||||
таблица из публичного `iter_route_contexts(app.routes)` в
|
||||
`request_context.py`. Структуру роутеров ради логов не менять.
|
||||
- С лабы 3 — middleware `X-Instance-Id` на все ответы, созданные API.
|
||||
@@ -0,0 +1,118 @@
|
||||
---
|
||||
paths:
|
||||
- "src/**/session.py"
|
||||
- "src/core/services/user.py"
|
||||
- "src/api/dependencies.py"
|
||||
- "src/api/errors.py"
|
||||
- "student-tests/api_client.py"
|
||||
- "student-tests/test_identification.py"
|
||||
---
|
||||
|
||||
# Аутентификация и сессии (с лабы 2)
|
||||
|
||||
Что обязан отдавать HTTP — `contracts/README.md`, «Идентификация и
|
||||
сессии», и `api-contract.md`; здесь — как это реализовать. Домен
|
||||
называется `session` во всех слоях: `routers/v1/session.py` с префиксом
|
||||
`/auth/sessions`, `services/session.py`, `repos/session.py`.
|
||||
|
||||
## Пароль
|
||||
|
||||
- KDF — Argon2id (`argon2-cffi`). Контракт разрешает Argon2id, scrypt и
|
||||
bcrypt, но bcrypt режет пароль на 72 байтах, а пароль до 128 code
|
||||
points в UTF-8 занимает до 512 байт. Lab7 требует именно Argon2id, и
|
||||
выбор сейчас избавляет от перехэширования. SHA-256 и plaintext
|
||||
запрещены. Параметры KDF — в `REPORT.md`.
|
||||
- Хэширование и проверка занимают десятки миллисекунд CPU. В event
|
||||
loop их не вызывать: `await anyio.to_thread.run_sync(...)`, иначе
|
||||
один вход останавливает все запросы процесса.
|
||||
- Всё это — `src/infra/password.py`: профиль
|
||||
`RFC_9106_LOW_MEMORY` (t=3, m=64 MiB, p=4) назван явно, а не взят
|
||||
умолчанием библиотеки; свой `CapacityLimiter` на
|
||||
`[auth] kdf_concurrency` (4), а не общий пул anyio на 40 потоков:
|
||||
40 × 64 MiB = 2,5 GiB (design change `session-auth`, решение 3).
|
||||
- Регистрация хэширует пароль до обращения к БД. Вход читает хэш и
|
||||
закрывает транзакцию (`commit()`) до проверки пароля: соединение пула
|
||||
не ждёт KDF и очередь лимита; сессия вставляется второй транзакцией.
|
||||
- Пароль хэшируется целиком как UTF-8, без обрезки и нормализации.
|
||||
Хэш не выходит за пределы repo и сервиса входа: в `UserFullDTO` и в
|
||||
ответе API его нет (`dto.md`).
|
||||
- Неизвестный username и неверный пароль — одно исключение и одинаковый
|
||||
401. Для неизвестного username пароль всё равно проверяется против
|
||||
фиктивного хэша, чтобы время ответа не выдавало, есть ли пользователь.
|
||||
Фиктивный хэш считает lifespan при старте (`prepare_dummy_hash`): при
|
||||
ленивом расчёте первый такой вход шёл бы вдвое дольше.
|
||||
|
||||
## Basic на входе
|
||||
|
||||
- Разбор свой, `HTTPBasic` FastAPI не годится (`api-contract.md`,
|
||||
«FastAPI»). Схему `basicAuth` объявляет
|
||||
`HTTPBase(scheme="basic", scheme_name="basicAuth", auto_error=False)`
|
||||
(импорт из `fastapi.security.http`: из `fastapi.security` его нет): он
|
||||
отдаёт схему и credentials как есть. Дальше схема `Basic` без учёта
|
||||
регистра → base64 строго (`b64decode(..., validate=True)`) → UTF-8 →
|
||||
`partition(":")` по **первому** двоеточию: в username двоеточия не
|
||||
бывает, в пароле оно допустимо. Любой сбой разбора — тот же 401, что и
|
||||
неверный пароль.
|
||||
- Username не по шаблону и пароль вне 12–128 code points отсекаются при
|
||||
разборе: тот же 401 без запроса к БД и KDF. Формат публичный, о
|
||||
пользователях такой отказ ничего не говорит.
|
||||
- JSON-тело на входе не читается.
|
||||
- 401 входа — с `WWW-Authenticate: Basic realm="messenger",
|
||||
charset="UTF-8"`.
|
||||
|
||||
## Токен и сессия
|
||||
|
||||
- Токен — `secrets.token_urlsafe(32)`: 256 бит энтропии, 43 символа
|
||||
(контракт требует не меньше 32). Не JWT, не UUID, ничего не кодирует.
|
||||
- Хранится не токен, а его SHA-256, поиск идёт по нему. Быстрого хэша
|
||||
здесь достаточно: у токена 256 бит энтропии, перебирать нечего. Пароль
|
||||
же выбирает человек, поэтому ему нужен медленный KDF — это вопрос
|
||||
защиты.
|
||||
- `expires_at = utcnow() + TTL` фиксируется при создании и хранится.
|
||||
Ни использование, ни рестарт срок не продлевают. На каждом запросе
|
||||
проверяется: сессия есть, не отозвана, `expires_at` в будущем.
|
||||
- TTL — `[auth] session_ttl_seconds` в `config.toml`; контрактное имя
|
||||
`SESSION_TTL_SECONDS` сопоставлено с ним в `REPORT.md`, мостом не
|
||||
заводится (`settings.md`). Разовая подмена —
|
||||
`AUTH__SESSION_TTL_SECONDS` в окружении. По умолчанию 3600, в обычном
|
||||
smoke не меньше 300, в тесте истечения — 2.
|
||||
- `DELETE /auth/sessions/current` отзывает только текущую сессию, дальше
|
||||
этот токен получает 401.
|
||||
- Сессии — в PostgreSQL, без кэша: отзыв мгновенный (design change
|
||||
`session-auth`). Таблица `sessions`: id, `user_id` (внешний ключ),
|
||||
SHA-256 токена (`bytea`, уникальный индекс, `CHECK` на 32 байта),
|
||||
`created_at` и `expires_at` (`timestamptz`). Отзыв — удаление строки.
|
||||
Проверка токена — один `SELECT` по `token_hash` с `JOIN` на
|
||||
пользователя; `now` для `expires_at > now` передаёт сервис, срок
|
||||
сравнивается по часам приложения.
|
||||
- Valkey сессии не хранит: он — кэш карточек чатов (спек
|
||||
`chat-cache`, change `membership-cache`). Любое хранилище сессий
|
||||
обязано пережить рестарт, соблюдать срок и отзыв, при недоступности
|
||||
отвечать 503 и никогда не пропускать запрос как анонимный или
|
||||
доверенный.
|
||||
|
||||
## Текущий пользователь
|
||||
|
||||
- `get_current_session` (`src/api/dependencies.py`):
|
||||
`HTTPBearer(scheme_name="bearerAuth", bearerFormat="opaque session
|
||||
token", auto_error=False)` — как в контракте → токен или `None` →
|
||||
`SessionService.authenticate` → `CurrentSessionDTO` (id сессии и
|
||||
`UserFullDTO`). Иначе `Unauthenticated` → 401 с `WWW-Authenticate:
|
||||
Bearer realm="messenger"`. `get_current_user` берёт пользователя из
|
||||
неё, logout — id сессии.
|
||||
- `X-User-Id` не читается нигде. Basic на бизнес-ручке для `HTTPBearer`
|
||||
— чужая схема: он отдаёт `None`, и получается тот же 401 с вызовом
|
||||
Bearer.
|
||||
- Заголовок `WWW-Authenticate` ставит таблица `errors.py` по типу
|
||||
исключения. Исключений два, для входа и для Bearer, а не одно с
|
||||
параметром.
|
||||
- `current_user_id` (contextvar логгера) ставится только после успешной
|
||||
проверки.
|
||||
|
||||
## Логи
|
||||
|
||||
Никогда не логируются пароль, токен, его хэш и заголовок
|
||||
`Authorization`. Создание и отзыв сессии — `info` с `user_id` и id
|
||||
сессии, неудачный вход — `warning` без username и пароля
|
||||
(`logging.md`). Параметры SQL в журнал не попадают: engine создан с
|
||||
`hide_parameters=True` (`infra.md`).
|
||||
@@ -0,0 +1,216 @@
|
||||
---
|
||||
paths:
|
||||
- "bench/**"
|
||||
---
|
||||
|
||||
# Нагрузочный стенд (`bench/`)
|
||||
|
||||
Стенд перенесён из лабы 1 (трек 1 «5», нагрузка на in-memory API) и на
|
||||
лабе 2 переведён на PostgreSQL: матрица размеров истории и уровней
|
||||
конкуренции для чтения и записи, метрики, планы запроса истории и сырые
|
||||
данные в `evidence/bench/<метка>/`. Что стенд обязан делать — спек
|
||||
`load-benchmark`, почему так — archived changes `load-bench-harness`
|
||||
(стенд), `perf-bottleneck-fix` (сравнение меток) и `bench-postgres`
|
||||
(стенд на PostgreSQL, план запроса), `track2-query-plans` (чаты
|
||||
неравномерных размеров, варианты индекса и запроса, стоимость записи) в
|
||||
`openspec/changes/archive/`.
|
||||
Результаты и выводы — `REPORT.md`, раздел «Эксперименты и отказы».
|
||||
|
||||
На лабе 2 стенд нужен для двух вещей: план запроса истории
|
||||
`EXPLAIN (ANALYZE, BUFFERS)` на ≥10 000 сообщениях (уровень 4) и
|
||||
сравнение индексов и запросов со стоимостью записи на чатах разного
|
||||
размера, а также backup и восстановление со сверкой для трека «5» №2
|
||||
(`README.md`). Варианты сравниваются внутри
|
||||
одной метки, на одних данных; «до» и «после» через `make bench_ab` нужны,
|
||||
только когда меняется код приложения. Метки лабы 1 сюда не
|
||||
переносились: другое хранилище — другая методика, сравнивать их с
|
||||
лабой 2 нельзя.
|
||||
|
||||
Стенд — свой проект compose `mtusi-bench`: тот же `docker-compose.yml`
|
||||
с override `bench/bench.compose.yml` (по образцу `make failure_checks`),
|
||||
подстановки — `bench/bench.env`, а не `.env` рабочего стенда. Пароли
|
||||
хранилищ `run.py` генерирует на прогон и никуда не пишет. Каждый размер —
|
||||
свежий стенд: `down -v`, Postgres и Valkey, миграции, API.
|
||||
|
||||
В `bench/` четыре инструмента:
|
||||
|
||||
| Файл | Команда | Что делает |
|
||||
|---|---|---|
|
||||
| `run.py`, `k6/`, `bench.compose.yml`, `bench.env` | `make bench`, `make bench_quick` | стенд: меряет пропускную способность, задержки, CPU API и Postgres, память, снимает планы запроса истории |
|
||||
| `run.py` (профили `restore`, `restore_quick`), `k6/after_backup.js`, `k6/restore_check.js` | `make bench_restore`, `make bench_restore_quick` | тот же стенд без матрицы прогонов: backup под записью, восстановление в новое хранилище, сверка, RTO и потеря, кэш до и после `FLUSHALL` |
|
||||
| `compare.py` | `make bench_compare` | дельта двух меток стенда, эффект или шум |
|
||||
| `ab.py` | `make bench_ab` | стенд «до» и «после» одного изменения подряд, в одной сессии хоста |
|
||||
|
||||
## Что не меняется между метками
|
||||
|
||||
Метки сравнимы, только если различается код приложения и больше ничего.
|
||||
Не меняются:
|
||||
|
||||
- **лимиты контейнеров без swap:** API — 1 CPU / 2 ГБ, PostgreSQL —
|
||||
4 CPU / 3 ГБ, Valkey — 2 CPU / 512 МБ (поля `Profile`, в compose —
|
||||
переменными `BENCH_*`). Healthcheck API выключен, `restart: "no"`,
|
||||
порты на хост не публикуются. Сумма лимитов памяти должна
|
||||
помещаться в VM docker с запасом 1,5 ГиБ, иначе — предупреждение о
|
||||
хосте;
|
||||
- **хранилища:** образы PostgreSQL и Valkey — те же пины, что у рабочего
|
||||
стенда (из `docker-compose.yml`). Valkey — тот же `valkey.conf`.
|
||||
PostgreSQL — настройки образа плюс `shared_preload_libraries =
|
||||
auto_explain`, выключенный вне этапа плана. Настройки, от которых
|
||||
зависят план и запись, пишутся в паспорт (`stand.postgres.settings`);
|
||||
- **приложение:** настройки по умолчанию из `settings.py` и окружение
|
||||
из override (`AUTH__SESSION_TTL_SECONDS` из `Profile`), без `.env` и
|
||||
`config.toml`. Окружение без паролей — в паспорте (`stand.app_env`);
|
||||
- **данные:** кроме читаемого чата из N сообщений и чата записи —
|
||||
фоновые чаты уровнями из `Profile.background` (в `full` 10 × 5 000,
|
||||
100 × 400, 1 000 × 10). Сообщения всех чатов отправляются вперемешку
|
||||
по детерминированному расписанию (`fill_schedule`), распределение по
|
||||
чатам проверяется после наполнения;
|
||||
- **обслуживание после наполнения:** `VACUUM (ANALYZE)` и `CHECKPOINT`
|
||||
до сбора курсоров и прогонов. Затем этап плана (страницы читаемого
|
||||
чата и первого чата каждого уровня, варианты страницы сравнения),
|
||||
затем прогоны с прогревом перед каждым, затем пробы стоимости записи;
|
||||
- **варианты и пробы:** варианты индекса истории — `Profile.index_variants`,
|
||||
проба записи — `write_probe_rows` строк, `write_probe_repeats`
|
||||
повторов со сдвигом порядка конфигураций;
|
||||
- **восстановление** (профили `restore*`): `pg_dump -Fc` во время
|
||||
записи `restore_write_load` сообщений `restore_write_vus` клиентами,
|
||||
`pg_restore -j restore_jobs` в контейнер того же образа и с лимитами
|
||||
Postgres стенда на новом volume, `ANALYZE`, переключение API через
|
||||
`POSTGRES_HOST`. Файл backup живёт только в `.work/`: в нём хэши
|
||||
паролей и токенов;
|
||||
- **генератор:** `grafana/k6` той же версии и digest, в той же
|
||||
docker-сети, без лимита CPU;
|
||||
- **профиль `full`:** размеры, конкуренция, повторы, прогрев и
|
||||
длительности, длина текста, порция наполнения, зерно выбора курсоров
|
||||
и сдвиг зерна для прогрева, порог пометки `generator`, лимиты и срок
|
||||
сессии стенда. Все они — поля `Profile` в `run.py` и целиком пишутся в
|
||||
`meta.json`: новый параметр методики заводится там же, а не константой
|
||||
в коде.
|
||||
|
||||
`make bench_compare` проверяет совпадение всего этого по паспортам
|
||||
(лимиты, образы, настройки PostgreSQL, `maxmemory*` Valkey, окружение
|
||||
приложения, профиль).
|
||||
|
||||
Изменить что-то из списка — значит сменить методику: старые метки
|
||||
перестают быть «до», базовый замер переснимается, а в `REPORT.md`
|
||||
записывается, что и почему поменялось.
|
||||
|
||||
## Как писать
|
||||
|
||||
- Стенд — чёрный ящик: `run.py`, `k6/` и `compare.py` не импортируют
|
||||
`src` и не ходят в приложение мимо HTTP. Все запросы к API делает k6
|
||||
внутри сети стенда, оркестратор управляет только docker CLI.
|
||||
- Исключение — PostgreSQL стенда: оркестратор обращается к нему
|
||||
напрямую (`docker exec … psql` от пользователя контейнера, SQL через
|
||||
stdin, `docker logs`), но только для обслуживания и измерения:
|
||||
- `VACUUM (ANALYZE)` и `CHECKPOINT`;
|
||||
- размеры таблиц и число сообщений по чатам;
|
||||
- включение и выключение `auto_explain` между маркерами;
|
||||
- журнал Postgres с планами;
|
||||
- варианты запроса истории (без индекса, с вариантами индекса, с
|
||||
курсором через `OR`, generic plan) в транзакции, которая
|
||||
откатывается;
|
||||
- пробы записи по вариантам индекса в транзакции, которая
|
||||
откатывается, и `VACUUM messages` после каждой;
|
||||
- `pg_dump` исходной базы, второе хранилище (`docker run`, имя
|
||||
`mtusi-bench-postgres-restore`, volume `mtusi-bench_restore`, метка
|
||||
проекта), `pg_restore` и `ANALYZE` в нём, построчная сверка обеих
|
||||
баз;
|
||||
- `FLUSHALL` Valkey стенда и пересоздание API с адресом
|
||||
восстановленной базы — только на этапе восстановления, в конце
|
||||
размера. Второе хранилище и его volume `Stand.stop()` удаляет до
|
||||
`compose down`.
|
||||
|
||||
Данных и схемы, видимых приложению, он не меняет: список индексов и
|
||||
число строк `messages` до и после этапа сверяются, при различии —
|
||||
отказ. Между прогонами нагрузки нет. Свою копию SQL приложения стенд
|
||||
не держит: варианты строятся из текста запроса в журнале Postgres.
|
||||
- Из журнала Postgres в результаты идут только планы запроса истории
|
||||
(`messages`). Между маркерами журнал содержит и проверку сессии с
|
||||
SHA-256 токена в параметрах: она отбрасывается и не пишется никуда.
|
||||
- Все вызовы `docker compose` — только с `-p mtusi-bench`, обоими `-f` и
|
||||
`--env-file bench/bench.env`, с окружением, собранным `run.py`:
|
||||
без `-p` `down -v` удалил бы чужой volume, без `--env-file` compose
|
||||
прочитал бы рабочий `.env`.
|
||||
- Скрипты `bench/` на хосте — только stdlib Python, запуск
|
||||
`uv run python bench/<файл>.py`. Новых зависимостей не добавлять.
|
||||
- Сценарии k6 — JavaScript без Node.js: только встроенные модули k6.
|
||||
Заголовок идентификации собирается в одном месте `lib.js`: Bearer,
|
||||
как `Actor.headers()` в `student-tests/`. Пароли пользователей стенда
|
||||
живут только в памяти `prepare.js`, токены — в `.work/fixture.json`,
|
||||
который удаляется в конце прогона; в каталог метки не попадает ни то,
|
||||
ни другое.
|
||||
- Имена контейнеров и сети — `mtusi-bench-*`. Чужие контейнеры
|
||||
(`make run_docker`, другие проекты) стенд не трогает и не
|
||||
останавливает. Уборка своих — в `finally` и по Ctrl+C. Остатки
|
||||
прерванного прогона `run.py` не удаляет сам: он отказывается
|
||||
стартовать и печатает команды уборки.
|
||||
- Случайность только через свой генератор с зерном из профиля
|
||||
(`seed + номер VU`), не `Math.random`.
|
||||
|
||||
## Измеренное состояние — commit
|
||||
|
||||
Замер или тест, результат которого идёт в отчёт, снимается с
|
||||
закоммиченного состояния кода; хеш попадает в шапку файла доказательства
|
||||
и в `REPORT.md`. Любое число в отчёте должно воспроизводиться из
|
||||
названного commit (указание пользователя 2026-09-30).
|
||||
|
||||
Коммит делает не агент сам: перед замером он показывает изменения
|
||||
(`git status`, `git diff --stat`), предлагает сообщение коммита и ждёт
|
||||
подтверждения пользователя (указание пользователя 2026-10-01).
|
||||
Пробное изменение `src`, которое потом откатывается, — отдельный commit,
|
||||
откат — новый commit поверх (`git revert`), без переписывания истории;
|
||||
оба — по тому же порядку. Push и остальные операции git — только по
|
||||
просьбе.
|
||||
|
||||
## Сравнение меток: `make bench_compare`
|
||||
|
||||
- «До» и «после» снимаются в одной сессии хоста, подряд, без
|
||||
перезагрузки между ними. Код приложения между ними отличается одним
|
||||
изменением.
|
||||
- Порядок: изменение закоммичено, проверено тестами и откачено
|
||||
отдельным commit; затем `make bench_ab BEFORE=... AFTER=...
|
||||
REAPPLY=<commit отката>` снимает «до», коммитит доказательства,
|
||||
возвращает изменение и снимает «после». Команда сама делает два
|
||||
коммита и отказывается стартовать на нечистом рабочем дереве: стенд
|
||||
записал бы в паспорт `dirty: true`. Поэтому `make bench_ab` агент
|
||||
запускает только с согласия пользователя.
|
||||
- Уровень шума берётся из сравнения двух меток одного и того же кода
|
||||
приложения (A/A), параметр `AA`. Что код одинаков, проверяется по git
|
||||
(`git diff <commit> <commit> -- src Dockerfile pyproject.toml
|
||||
uv.lock`): команда этого не видит.
|
||||
- Изменение в ячейке — эффект, только если разбросы повторов не
|
||||
пересекаются и изменение медианы больше уровня шума сценария. Дельту
|
||||
в отчёт переносить из таблицы команды, не считать вручную.
|
||||
- Ячейки сценария, который изменение не затрагивает, — контроль: они
|
||||
тоже показываются в отчёте.
|
||||
|
||||
## Результаты
|
||||
|
||||
- Каталог метки не перезаписывается. `evidence/bench/quick-*` — в
|
||||
`.gitignore`: короткий прогон проверяет стенд, а не даёт результат.
|
||||
- `evidence/compare/<до>__<после>.md` выводится из неизменяемых
|
||||
каталогов меток и может пересоздаваться; сравнения пробных меток
|
||||
`quick-*` — в `.gitignore`.
|
||||
- Планы запроса истории — `explain-<размер>.txt` в каталоге метки, как
|
||||
есть из журнала Postgres и psql. В отчёт числа плана переносятся из
|
||||
этих файлов или из раздела планов `summary.md`, не пересчитываются.
|
||||
- Столбцы `runs.csv` и `prefill.csv` не переименовываются и не
|
||||
удаляются: по ним сравниваются метки. Новая метрика — новый столбец
|
||||
в конце.
|
||||
- В результатах нет секретов, `.env` и абсолютных путей домашнего
|
||||
каталога; данные синтетические.
|
||||
- Перед полной матрицей хост должен быть в состоянии, которое можно
|
||||
проверить: питание от сети, swap около нуля (`sysctl vm.swapusage`),
|
||||
память свободна (`memory_pressure`), посторонних контейнеров нет.
|
||||
Если swap занят или память под давлением — перезагрузить ноутбук;
|
||||
если условия выполнены, перезагрузка не обязательна. Состояние
|
||||
записывается в паспорт (`host_state`), в отчёте оно указывается по
|
||||
паспорту, а не по плану. Во время прогона ноутбук не нагружать и не
|
||||
закрывать крышку: цели `bench*` запускаются под `caffeinate -isu`
|
||||
(`-u` будит из DarkWake полностью, `-i -s` не дают уснуть по простою),
|
||||
но от сна при закрытой крышке он не спасает. Сон посреди прогона ставит
|
||||
ВМ Docker на паузу; `run.py` замечает его по разнице реального и
|
||||
монотонного времени (`host_state.slept_seconds`, предупреждение больше
|
||||
5 с). Предупреждения о хосте в `meta.json` (`host_warnings`) — повод
|
||||
переснять, а не игнорировать.
|
||||
@@ -0,0 +1,213 @@
|
||||
---
|
||||
paths:
|
||||
- "Dockerfile"
|
||||
- "docker-compose.yml"
|
||||
- ".dockerignore"
|
||||
- "scripts/restart.sh"
|
||||
- "infra/**"
|
||||
---
|
||||
|
||||
# Dockerfile и compose
|
||||
|
||||
Форма — как в bp_proxies: мультистейдж с uv, compose с портами из `.env`,
|
||||
литеральным режимом в `environment` и python-healthcheck. Требования
|
||||
рубрики (`README.md`, уровни 3 и 4) и `Dockerfile.example` важнее
|
||||
образца; отличия от него перечислены ниже. Режимы запуска —
|
||||
`run-modes.md`.
|
||||
|
||||
## Dockerfile
|
||||
|
||||
- Мультистейдж. В builder — `uv sync --locked --no-dev
|
||||
--no-install-project` по `pyproject.toml` и `uv.lock` в
|
||||
`/app/.venv`: слой зависимостей кешируется отдельно от кода. В
|
||||
runtime — копия `.venv` и `src/`, `PATH` на `/app/.venv/bin`.
|
||||
Компиляторы и uv в runtime не нужны (в bp_proxies uv ставился в оба
|
||||
stage).
|
||||
- Оба stage — на **одном** базовом образе: `.venv/bin/python` —
|
||||
ссылка на интерпретатор базового образа, на другом образе она
|
||||
сломается.
|
||||
- `--no-install-project`: `src/` в builder не копируется, и hatchling
|
||||
не собирает проект пакетом. `python -m src` находит `src` через
|
||||
рабочий каталог `/app`.
|
||||
- Версии закреплены: `тег@sha256:<digest индекса>`. Тег с патч-версией
|
||||
(`python:3.12.14-slim-trixie`) показывает версию, digest **индекса**
|
||||
(не манифеста одной платформы) даёт повторяемость и работает на arm64
|
||||
и amd64. Digest брать из `docker buildx imagetools inspect <тег>`,
|
||||
строка `Digest:` в начале вывода. Не `latest` и не `3.12-slim`. uv —
|
||||
`COPY --from=ghcr.io/astral-sh/uv:<версия>@sha256:... /uv /bin/uv`, а
|
||||
не незакреплённый `pip install uv`. Зависимости — только из lock
|
||||
(`--locked`): если `uv.lock` не совпадает с `pyproject.toml`, сборка
|
||||
падает. Директиву `# syntax=` не добавлять: это ещё один
|
||||
незакреплённый образ, а встроенный frontend BuildKit и так понимает
|
||||
`RUN --mount`.
|
||||
- Непривилегированный пользователь: системный `app` с UID/GID 10001 и
|
||||
`USER app` перед `CMD`. Код и `.venv` копируются от root и доступны
|
||||
пользователю только на чтение.
|
||||
- `CMD` в exec-форме: `["python", "-m", "src"]`. Тогда сервер — PID 1 и
|
||||
сам получает SIGTERM. Не `sh -c "... && ..."` и не `uv run`: это
|
||||
лишний процесс между docker и сервером.
|
||||
- `ENV APP__RUN_MODE=docker PYTHONUNBUFFERED=1
|
||||
PYTHONDONTWRITEBYTECODE=1`, `EXPOSE 8080`.
|
||||
- `HEALTHCHECK` на `/health/ready` через `python -c "import
|
||||
urllib.request; ..."` (curl в slim нет) с явными `--interval`,
|
||||
`--timeout`, `--start-period` и `--start-interval=1s`: без него первая
|
||||
проверка идёт только через `interval`, и контейнер становится
|
||||
`healthy` не раньше 10 с. Порт — `APP__PORT` из окружения, по
|
||||
умолчанию 8080. Healthcheck живёт только в образе: он нужен и без
|
||||
compose (стенд `bench/`), а compose берёт его из образа и не
|
||||
дублирует.
|
||||
- В образ не попадают `.env`, `config.toml`, секреты, `tests/`,
|
||||
`student-tests/`, `contracts/`, `evidence/`, `.claude/`, `openspec/`,
|
||||
`.venv/`. Отличие от bp_proxies: там `config.toml` копируется в образ,
|
||||
здесь нельзя. Чистый clone его не содержит, и сборка упала бы, а
|
||||
`Dockerfile.example` (п. 6) запрещает класть конфиг и секреты в образ.
|
||||
Конфигурация приходит на старте: `config.toml` монтируется
|
||||
read-only в `/app/config.toml`, переменные — `environment` compose.
|
||||
Это согласовано с преподавателем
|
||||
2026-09-29 как выполнение README лабы 1, п. 3 и `Dockerfile.example`,
|
||||
п. 6 (AGENTS.md, «Согласования с преподавателем»). Что где лежит —
|
||||
`settings.md`.
|
||||
- Миграции едут вместе с образом: `migrations/` и `alembic.ini`
|
||||
копируются в runtime, и миграционный сервис compose запускает тот же
|
||||
образ с другой командой (`migrations.md`). `.dockerignore` их не
|
||||
исключает.
|
||||
|
||||
## `.dockerignore`
|
||||
|
||||
Файл из skeleton дополнять, а не заменять: `config.toml`, `.claude`,
|
||||
`openspec`, `tests`, `student-tests`, `contracts`, `infra`, `*.md`,
|
||||
`Makefile`.
|
||||
`.dockerignore` не заменяет явный `COPY` только нужного.
|
||||
|
||||
Паттерн без `**/` действует только в корне контекста: `__pycache__` из
|
||||
skeleton не исключает `src/**/__pycache__`, и `.pyc` хоста попадали в
|
||||
образ. Для вложенных путей — `**/__pycache__`, `**/*.py[cod]`,
|
||||
`**/.DS_Store`.
|
||||
|
||||
## Проверка сборки «из чистого clone»
|
||||
|
||||
Без коммита и временного каталога: контекст — ровно файлы будущего
|
||||
clone (отслеживаемые и новые неигнорируемые):
|
||||
|
||||
```sh
|
||||
git ls-files -z -co --exclude-standard | tar --null -T - -cf - | docker build -t mtusi-messenger:lab2 -
|
||||
```
|
||||
|
||||
`.env`, `config.toml` и `.venv` в него не попадают по `.gitignore`.
|
||||
Перед PR — ещё и настоящий `git clone`.
|
||||
|
||||
## docker-compose.yml
|
||||
|
||||
- Сервис `api`: `build: .`; порты `"127.0.0.1:${APP_OUT_PORT:-8080}:${APP__PORT:-8080}"`
|
||||
(снаружи / внутри, стенд учебный — только localhost); `environment`
|
||||
— общий с `migrate` якорь `x-app-env`: `APP__RUN_MODE: docker`,
|
||||
`APP__PORT`, `DATABASE__*` из переменных `POSTGRES_*`
|
||||
(`settings.md`, «Консоль и docker»); healthcheck образа проверяет
|
||||
`APP__PORT`; `stop_grace_period: 10s`; `restart: unless-stopped`.
|
||||
Имена переменных в `.env` — `settings.md`, «Имена в `.env`».
|
||||
- Литералов адреса и порта Postgres в compose нет: `POSTGRES_HOST`
|
||||
становится алиасом сервиса в сети, `POSTGRES_PORT` — портом самого
|
||||
сервера через `PGPORT` (его же берут `pg_isready` и `psql` в
|
||||
контейнере). Литерал — только адрес публикации `127.0.0.1`: это
|
||||
требование безопасности, а не параметр.
|
||||
- `config.toml` — только длинной записью, иначе при отсутствии файла
|
||||
Docker молча создаст на хосте каталог `config.toml/`, и приложение
|
||||
упадёт на чтении настроек (проверено):
|
||||
|
||||
```yaml
|
||||
volumes:
|
||||
- type: bind
|
||||
source: ./config.toml
|
||||
target: /app/config.toml
|
||||
read_only: true
|
||||
bind:
|
||||
create_host_path: false
|
||||
```
|
||||
|
||||
Без файла compose сразу падает с `bind source path does not exist`.
|
||||
Поэтому `make run_docker` зависит от `env_setup`: недостающие `.env`
|
||||
и `config.toml` создаются из шаблонов, существующие не трогаются.
|
||||
Голый `docker compose up` без файла по-прежнему падает. Голый
|
||||
`docker run` монтирует его так же строго — `--mount
|
||||
type=bind,src="$PWD/config.toml",dst=/app/config.toml,readonly`, а не
|
||||
`-v`. Сам файл необязателен: без него приложение стартует на
|
||||
дефолтах.
|
||||
- Смонтированный файл должен читаться непривилегированным пользователем
|
||||
контейнера. На Docker Desktop права хоста не мешают, на Linux нужен
|
||||
режим `644` или совпадающий uid.
|
||||
- Новая переменная контейнера — строка в `.env.example` и в
|
||||
`environment` сервиса.
|
||||
- С лабы 2 compose — основной запуск стенда: API без Postgres запросы
|
||||
не обслуживает. Проверка и запуск — по README:
|
||||
`docker compose --env-file .env config --quiet`, затем
|
||||
`up -d --build`, ожидание `/health/ready`. Роли — api, postgres и
|
||||
valkey (`contracts/infrastructure.json`: Redis или Valkey на «4»).
|
||||
`compose.example.yaml` — лишь список ролей, стенд — свой
|
||||
`docker-compose.yml` (compose находит его сам, как и `compose.yaml`).
|
||||
- Образы зависимостей закреплены так же, как базовый: тег с патч-версией
|
||||
и digest индекса (`postgres:18.6-trixie@sha256:...`), не
|
||||
`postgres:18` и не `latest`. Точка монтирования volume — из
|
||||
`Config.Volumes` образа: у Postgres 18 это `/var/lib/postgresql`, а не
|
||||
`/var/lib/postgresql/data`, как у 17.
|
||||
- У каждой зависимости свой healthcheck, API ждёт `depends_on:
|
||||
condition: service_healthy`. У Postgres — `pg_isready -h 127.0.0.1`
|
||||
по TCP: при инициализации образ поднимает временный сервер только на
|
||||
сокете, и проверка через сокет сказала бы «готов» раньше времени.
|
||||
Миграции — отдельный одноразовый сервис на образе API
|
||||
(`pull_policy: never`, образ собирает `api`), API ждёт его
|
||||
`service_completed_successfully`.
|
||||
- Данные — именованные volumes. `make down` и скрипты их не удаляют;
|
||||
удаление учебных данных — отдельная явная команда в `REPORT.md`.
|
||||
- Postgres наружу — только `127.0.0.1:${POSTGRES_OUT_PORT}`, для
|
||||
console-режима. Пароль — `POSTGRES_PASSWORD` в `.env`, в приложение
|
||||
мостом (`settings.md`).
|
||||
- Valkey (сервис `valkey`, кэш карточек чатов): тот же пин тега с
|
||||
патч-версией и digest индекса, `restart: unless-stopped`, healthcheck,
|
||||
`api` ждёт `service_healthy`. Отличия от Postgres:
|
||||
- volume нет: persistence выключен в `infra/valkey/valkey.conf`
|
||||
(`save ""`, `appendonly no`), кэш после рестарта пуст, а данные —
|
||||
в Postgres. Если бы в Valkey жили сессии, persistence был бы
|
||||
обязателен: без него рестарт стёр бы их, и `make test-persistence`
|
||||
упал бы;
|
||||
- пароль — `VALKEY_PASSWORD` в `.env`, в контейнер — переменной
|
||||
окружения. Сервер получает его в `command` через `sh -c` из
|
||||
переменной контейнера (`--requirepass "$$VALKEY_PASSWORD"`), в
|
||||
compose он не литерал. Запуск — `exec docker-entrypoint.sh
|
||||
valkey-server ...`: с `sh` первым аргументом entrypoint образа не
|
||||
сбрасывает root, а так сервер работает от пользователя `valkey`;
|
||||
- healthcheck — `valkey-cli ping` с паролем из `VALKEYCLI_AUTH`
|
||||
(без `-a` в команде): `PONG` только после AUTH, и проверка
|
||||
ловит неверный пароль;
|
||||
- порт сервера — `VALKEY_PORT` (`--port`), алиас в сети —
|
||||
`VALKEY_HOST`, публикация — `127.0.0.1:${VALKEY_OUT_PORT}`, как у
|
||||
Postgres.
|
||||
- Конфигурации сервисов (`valkey.conf`, при необходимости
|
||||
`postgresql.conf`) — в `infra/<сервис>/`, монтируются read-only
|
||||
длинной записью с `create_host_path: false` (`infra/README.md`). В
|
||||
`REPORT.md` — таблица роль → сервис → версия/digest → healthcheck →
|
||||
volume → порт → способ передачи credentials.
|
||||
|
||||
## `scripts/restart.sh`
|
||||
|
||||
Hook для `make test-persistence ACTION_SCRIPT=scripts/restart.sh`
|
||||
(`tests/README.md`), по образцу `scripts/restart.example.sh`.
|
||||
|
||||
- Перезапускает API и **все** используемые хранилища: Postgres и
|
||||
Valkey. Volumes, схему и данные сохраняет: без `down -v`, `FLUSHALL`,
|
||||
повторного seed и изменения тестовых данных. Кэш Valkey после
|
||||
рестарта пуст сам: persistence у него выключен.
|
||||
- Порядок: `stop api` → `restart postgres valkey` → `up -d --wait
|
||||
postgres valkey` (те же контейнеры, ожидание healthcheck) →
|
||||
`start api`. `start api` запускает и зависимость `migrate`: повторный
|
||||
прогон миграций — no-op.
|
||||
- `#!/bin/sh`, `set -eu`, исполняемый бит в git (`chmod +x`,
|
||||
`git update-index --chmod=+x`). Возвращает 0 только после действия,
|
||||
укладывается в 90 с. Готовность ждёт сам тест. Секреты не печатает.
|
||||
- Успех теста не доказывает, что БД действительно перезапускалась. В
|
||||
`evidence/` — состояние контейнеров до и после (`docker compose ps`,
|
||||
`StartedAt` из `docker inspect`).
|
||||
|
||||
## Дальше
|
||||
|
||||
- С лабы 3: реплики API за балансировщиком; внутренние порты реплик
|
||||
наружу не публиковать. Скрипт failover volumes тоже не удаляет.
|
||||
@@ -0,0 +1,40 @@
|
||||
---
|
||||
paths:
|
||||
- "src/schemas/**"
|
||||
---
|
||||
|
||||
# DTO и enum-ы (`src/schemas/`)
|
||||
|
||||
`src/schemas/dataclasses/<domain>.py` — DTO между repo → service → api;
|
||||
`src/schemas/enums/<domain>.py` — `StrEnum` доменов. HTTP-модели
|
||||
(pydantic) лежат не здесь, а в `src/api/schemas/` (`api-layer.md`).
|
||||
|
||||
Создавать только те DTO, без которых слой не может отдать данные. Не
|
||||
плодить обёртки «на будущее».
|
||||
|
||||
| Назначение | Имя | Когда нужен |
|
||||
|---|---|---|
|
||||
| Вход на создание записи | `Create<Entity>DTO` | полей больше трёх-четырёх, иначе хватит именованных аргументов |
|
||||
| Полная запись | `<Entity>FullDTO` | сервису и API нужны все поля записи |
|
||||
| Выборка подмножества полей | `<Entity>InListDTO` | repo выбирает часть колонок |
|
||||
| Страница | `<Entity>PageDTO` | `items` и `next_cursor: str \| None` |
|
||||
|
||||
- Каждый класс — `@dataclass(frozen=True, slots=True)`, суффикс `DTO`.
|
||||
Repo отдаёт снимок строки, а не ORM-объект: изменение DTO в БД не
|
||||
попадёт, и frozen не даёт сделать вид, что попадёт. pydantic читает
|
||||
DTO через `from_attributes`.
|
||||
- Обязательные поля первыми, поля со значением по умолчанию — последними;
|
||||
для `list` / `dict` — `field(default_factory=...)`. В frozen-DTO
|
||||
коллекции — `tuple` / `frozenset`.
|
||||
- Типы доменные: `UUID`, а не `str`; `datetime` (aware UTC), а не строки;
|
||||
`enums.*`; `X | None` для nullable.
|
||||
- Имена полей `<Entity>FullDTO` совпадают с колонками модели, иначе
|
||||
`FullDTO(**row.to_dict())` сломается. Исключение — секреты: хэш
|
||||
пароля и хэш токена в `UserFullDTO` и в DTO, уходящие в API, не
|
||||
попадают. Для входа — отдельный DTO из выбранных колонок
|
||||
(`auth.md`).
|
||||
- Каждый новый класс добавляется в `__init__.py` пакета (импорт и
|
||||
`__all__`) в алфавитном порядке.
|
||||
- Короткий docstring на русском, если назначение не очевидно из имени.
|
||||
- Enum-ы — `StrEnum`. Значение хранится в БД, поэтому переименование
|
||||
значения = миграция (`migrations.md`).
|
||||
@@ -0,0 +1,92 @@
|
||||
---
|
||||
paths:
|
||||
- "src/infra/**"
|
||||
---
|
||||
|
||||
# Инфраструктура (`src/infra/`)
|
||||
|
||||
Всё, что не содержит бизнес-логики и может смениться от лабы к лабе:
|
||||
логгер, PostgreSQL (`db/`), кэш Valkey (`cache/`), дальше — S3, брокер,
|
||||
телеметрия. Бизнес-правил (уникальность, доступ, валидация) здесь нет:
|
||||
они в сервисах, атомарные операции — в repo.
|
||||
|
||||
- Клиент хранилища (engine Postgres, кэш Valkey) — глобал своего модуля
|
||||
(`db/session.py`, `cache/instance.py`): создаётся при импорте по
|
||||
`settings` (настройки читаются один раз на процесс), соединения
|
||||
открывает лениво, при первом запросе. Пакет `src/infra/<клиент>/` этот
|
||||
модуль не импортирует, модели тоже, поэтому alembic и скрипты клиента
|
||||
не создают. Закрытие (`engine.dispose()`, `cache.aclose()`) — в
|
||||
lifespan `src/main.py`. Почему не `app.state` — design change
|
||||
`postgres-storage`, решение 5.
|
||||
- Глобал импортируют только `src/main.py` (закрытие) и
|
||||
`src/api/dependencies.py`; сервисы получают сессию или клиент через
|
||||
конструктор из зависимости и сами глобал не импортируют. Процессу со
|
||||
своим пулом (worker с лабы 5) — свой вызов фабрики `create_engine`.
|
||||
- `db/`: `engine.py` — фабрики engine и сессий, `BoundedCloseConnection`,
|
||||
`ping`; `session.py` — глобалы `engine` и `session_factory`;
|
||||
`errors.py` — `is_db_unavailable`; модели — `models/`
|
||||
(`migrations.md`). Драйвер — asyncpg.
|
||||
- `cache/`: `client.py` — фабрика `create_cache` и обёртка `Cache`;
|
||||
`instance.py` — глобал `cache`. Ключи и формат значений — в repo
|
||||
(`src/core/repos/chat_cache.py`), не здесь.
|
||||
- Источник истины — PostgreSQL. SQLite, файлы и память процесса его не
|
||||
заменяют (`README.md`, п. 2). Кэш не хранит ничего, чего нет в
|
||||
Postgres: сессии в Valkey не лежат (`auth.md`).
|
||||
- Пул ограничен (`pool_size`, `max_overflow`, `pool_timeout`), у
|
||||
подключения и запроса есть таймауты (`connect_timeout_seconds`,
|
||||
серверный `statement_timeout`, срок запроса `request_timeout_seconds`).
|
||||
Это требование уровня 4; значения — поля секции `[database]`
|
||||
(`settings.md`). Пул считается на один процесс (`run-modes.md`).
|
||||
- `command_timeout` asyncpg не использовать: на таймауте он отменяет
|
||||
запрос через новое соединение и ждёт сервер без срока, и замёрзший
|
||||
Postgres держит запрос до разморозки. Срок запроса ставит
|
||||
`asyncio.timeout` в `get_db_session`, а мягкое закрытие соединения
|
||||
ограничивает `BoundedCloseConnection` (`connection_class` asyncpg).
|
||||
- Engine — с `hide_parameters=True`. `str()` у `DBAPIError` включает
|
||||
`[SQL: ...]` и `[parameters: ...]`, и эта строка уходит в журнал: в
|
||||
`warning` из `get_db_session` и в traceback ошибки 500. Без флага там
|
||||
оказались бы текст сообщений, а с `session-auth` — хэши паролей и
|
||||
токенов (`logging.md`, «Чего в логах быть не должно»).
|
||||
- `/health/ready` проверяет критичные зависимости через infra:
|
||||
`SELECT 1` в Postgres с коротким таймаутом. Valkey не проверяется: это
|
||||
кэш, без него обязательный путь идёт в Postgres. Недоступность
|
||||
критичной зависимости — 503. Какие зависимости критичны, фиксируется
|
||||
в `REPORT.md`.
|
||||
- Потеря соединения и таймауты драйвера на бизнес-запросе — 503
|
||||
`unavailable` без деталей (`api-contract.md`), не 500 и не обход
|
||||
аутентификации. Перевод — в `get_db_session`: `is_db_unavailable`
|
||||
решает, отказ ли это, сессия закрывается через `invalidate()`, в
|
||||
журнал — `warning`. Остальные `DBAPIError` (ограничения, синтаксис) —
|
||||
дефект, им положен 500.
|
||||
- Valkey (не Redis) — кэш карточки чата (спек `chat-cache`, design
|
||||
change `membership-cache`). Роль, источник истины, срок, вытеснение и
|
||||
отсутствие инвалидации — в `REPORT.md`. Клиент — redis-py
|
||||
(`redis.asyncio`):
|
||||
- **один повтор, только на обрыв**: `retry=Retry(NoBackoff(), 1,
|
||||
supported_errors=(ConnectionError,))`. По умолчанию redis-py
|
||||
повторяет команду с backoff, и замороженный Valkey держал запрос
|
||||
6 с вместо 0,2 с. Таймаут не повторяется, а обрыв повторяется один
|
||||
раз: после рестарта Valkey старое соединение пула иначе давало бы
|
||||
отказ на первой команде;
|
||||
- `Retry` — **из `redis.asyncio.retry`**. Синхронный `redis.retry.Retry`
|
||||
асинхронное соединение принимает молча, но повтор с ним не
|
||||
выполняется никогда (первая реализация так и ошиблась);
|
||||
- `BlockingConnectionPool` на `[cache] max_connections` с ожиданием не
|
||||
дольше `timeout_seconds`: обычный пул при всплеске запросов сразу
|
||||
бросает `MaxConnectionsError`, и здоровый Valkey считался бы
|
||||
отказавшим;
|
||||
- `socket_timeout` и `socket_connect_timeout` — `[cache]
|
||||
timeout_seconds`, а всю команду (пул, соединение, повтор, ответ)
|
||||
ограничивает `asyncio.timeout` того же срока в `Cache`.
|
||||
- Отказ Valkey — промах, а не 503 и не 500: `Cache.get` / `Cache.set`
|
||||
ловят `RedisError` и `OSError` (в том числе `TimeoutError` от
|
||||
`asyncio.timeout`), отдают `None` / `False`, и запрос идёт в
|
||||
Postgres. После отказа кэш пропускается на `[cache]
|
||||
retry_after_seconds` без обращений к Valkey. В журнал — один
|
||||
`warning` «Cache is unavailable» на отказ и `info` «Cache is
|
||||
available again» при первом успехе. Пароль в журнал не попадает: он
|
||||
есть только в настройках пула.
|
||||
- Клиенты внешних сервисов: адреса и секреты из `settings`
|
||||
(`.claude/rules/settings.md`), таймаут на каждый вызов, ошибки
|
||||
переводятся в доменные исключения. Логи — по `logging.md`, без
|
||||
секретов.
|
||||
@@ -0,0 +1,150 @@
|
||||
---
|
||||
paths:
|
||||
- "src/core/services/**"
|
||||
- "src/api/**"
|
||||
- "src/infra/**"
|
||||
- "src/main.py"
|
||||
---
|
||||
|
||||
# Логирование
|
||||
|
||||
Инфраструктура — `src/infra/logger.py`, по образцу bp_proxies
|
||||
(`src/core/services/logger.py` там). `get_logger()` возвращает
|
||||
`AbstractLogger` поверх structlog: JSON в stdout, уровень из
|
||||
`[app] log_level`.
|
||||
|
||||
Само попадает в запись, руками не добавлять: `request_id` из contextvar
|
||||
(ставит request-id middleware, то же значение, что в `X-Request-Id`),
|
||||
`user_id` из contextvar (ставит `get_current_user`), timestamp ISO/UTC,
|
||||
уровень, `filename` / `func_name` / `lineno`. Enum печатается как repr.
|
||||
|
||||
## Устройство `src/infra/logger.py`
|
||||
|
||||
Это перенос логгера bp_proxies
|
||||
(`~/PycharmProjects/bp_proxies/src/core/services/logger.py`, есть только
|
||||
на машине автора) с тремя отличиями, перечисленными ниже.
|
||||
|
||||
- `AbstractLogger` (ABC: `debug` / `info` / `warning` / `error` /
|
||||
`critical` / `bind`) и реализация `StructLogger` лежат в этом же
|
||||
модуле. `bind()` возвращает новый логгер с объединённым контекстом,
|
||||
исходный не меняется.
|
||||
- `get_logger()` инициализируется лениво: первый вызов выполняет
|
||||
`configure_logger()` и создаёт корневой `StructLogger`. Модули зовут
|
||||
его на уровне модуля, поэтому настройка применяется уже при импорте
|
||||
`src.main`, до `uvicorn.run`.
|
||||
- `structlog.configure_once`, процессоры по порядку:
|
||||
1. `stdlib.filter_by_level` — запись ниже уровня отбрасывается до
|
||||
остальных процессоров, включая поиск места вызова;
|
||||
2. `contextvars.merge_contextvars`, `stdlib.add_log_level`,
|
||||
`stdlib.ExtraAdder()`;
|
||||
3. `TimeStamper(fmt="iso", utc=True)`, `format_exc_info`;
|
||||
4. `CallsiteParameterAdder` (`FILENAME`, `FUNC_NAME`, `LINENO`) с
|
||||
`additional_ignores=["src.infra.logger"]`;
|
||||
5. контекстный процессор: `request_id` и `user_id` из contextvar-ов;
|
||||
6. перестановка ключей: `request_id`, `event`, `user_id` в начало;
|
||||
7. Enum → repr, UUID → строка (иначе JSONRenderer пишет `UUID('...')`),
|
||||
поэтому в kwargs можно передавать `UUID` как есть;
|
||||
8. `stdlib.ProcessorFormatter.wrap_for_formatter`.
|
||||
|
||||
`logger_factory=stdlib.LoggerFactory()`,
|
||||
`wrapper_class=stdlib.BoundLogger`, `cache_logger_on_first_use=True`.
|
||||
- `logging.config.dictConfig` с `disable_existing_loggers=False`:
|
||||
- форматтер — `ProcessorFormatter` с `remove_processors_meta` и
|
||||
`JSONRenderer()`; для записей чужих библиотек — `foreign_pre_chain`
|
||||
из `merge_contextvars`, `add_log_level`, `add_logger_name`,
|
||||
`TimeStamper`, `format_exc_info`, контекстного процессора и
|
||||
перестановки ключей;
|
||||
- handler — один `StreamHandler` в `ext://sys.stdout`;
|
||||
- root — `WARNING` с этим handler: предупреждения прочих библиотек тоже
|
||||
JSON (в bp_proxies root был без handlers);
|
||||
- `src` — уровень `[app] log_level`, этот handler,
|
||||
`propagate=False`;
|
||||
- `uvicorn` — `INFO`, этот handler, `propagate=False`;
|
||||
`uvicorn.error` — `INFO` без своего handler, пишет через `uvicorn`
|
||||
(свой handler дал бы дубли); `uvicorn.access` — выключен;
|
||||
- шумные библиотеки (`sqlalchemy.engine`, драйвер Postgres, `httpx`,
|
||||
`httpcore`) — `WARNING`: SQL с параметрами в лог не попадает.
|
||||
|
||||
### Отличия от bp_proxies
|
||||
|
||||
1. **Место вызова — через `CallsiteParameterAdder`, а не
|
||||
`inspect.stack()`.** В bp_proxies каждый метод `StructLogger` зовёт
|
||||
`inspect.stack()`, а тот читает исходники всех кадров стека. Замер
|
||||
на глубине стека 40 кадров (как у ручки FastAPI под uvicorn):
|
||||
~470 мкс только на поиск места вызова против ~3,5 мкс на всю запись
|
||||
с `CallsiteParameterAdder`. На одном event loop 2–3 строки лога на
|
||||
запрос съели бы 1–1,5 мс CPU, то есть заметную долю потолка RPS
|
||||
(замер — трек 1 лабы 1).
|
||||
2. **`request_id` в процессоре не генерируется.** В bp_proxies при
|
||||
пустом contextvar процессор создаёт случайный 8-символьный id и
|
||||
записывает его в contextvar. Здесь id запроса ставит только
|
||||
middleware, и он обязан совпасть с `X-Request-Id`. Вне запроса
|
||||
(старт, shutdown) поля нет. Фоновые задачи с лабы 5 ставят свой id
|
||||
сами, как job в bp_proxies.
|
||||
3. **uvicorn тоже пишет JSON.** В bp_proxies логгеры `uvicorn.*` не
|
||||
трогаются и пишут обычный текст. Здесь строки uvicorn об остановке
|
||||
(«Shutting down», «Waiting for application shutdown.», «Finished
|
||||
server process») доказывают на защите уровня 4, что SIGTERM
|
||||
отработал вовремя, поэтому идут в тот же JSON. Для этого
|
||||
`uvicorn.run(..., log_config=None, access_log=False)`: без
|
||||
`log_config=None` uvicorn при старте применит свой `LOGGING_CONFIG`
|
||||
поверх нашего. Access-лог пишет свой middleware (`api-layer.md`).
|
||||
|
||||
## Чего в логах быть не должно
|
||||
|
||||
Рубрика уровня 4: логи полезные, но **без содержимого сообщений**.
|
||||
|
||||
- Текст сообщений, `display_name`, `title` чата, тела запросов и ответов
|
||||
целиком. Вместо текста — идентификаторы и размеры
|
||||
(`text_length=len(text)`).
|
||||
- Пароли, токены сессий и их хэши, заголовок `Authorization` (`auth.md`);
|
||||
с лабы 3 — `Idempotency-Key` целиком; с лабы 4 — подписанные URL и
|
||||
ключи бакета.
|
||||
- Stack trace — только в лог, никогда в ответ.
|
||||
|
||||
## Где логировать
|
||||
|
||||
| Слой | Логи | Логгер модуля |
|
||||
|---|---|---|
|
||||
| `core/repos` | **никогда** | нет |
|
||||
| `core/services/<domain>.py` | в каждом методе с побочным эффектом | `module="<domain>_service"` |
|
||||
| `api/routers/v1/<domain>.py` | только заметные шаги, которых не видно из сервиса | `module="api_<domain>_router"` |
|
||||
| `api/middlewares` | access-лог: одна строка на запрос; health не логировать | `middleware="http"` |
|
||||
| `api/errors.py` | не логирует: 4xx — штатные ответы, а traceback непредвиденной ошибки пишет uvicorn (`uvicorn.error`, с `request_id` из contextvar) после повторного броска исключения Starlette | нет |
|
||||
| `infra/<client>.py` | подключение, закрытие, ошибки; запросы к внешним API (`debug`) | `module="<client>"` |
|
||||
| `main.py` | старт (host, port, режим), начало и конец shutdown | `module="startup"` |
|
||||
| чистые функции | не логируют, бросают доменные исключения | нет |
|
||||
|
||||
Строки старта и shutdown нужны на защите: по ним видно, что SIGTERM
|
||||
отработал за заявленный срок.
|
||||
|
||||
## Как логировать
|
||||
|
||||
Логгер модуля один, сразу после импортов:
|
||||
|
||||
```python
|
||||
from src.infra.logger import AbstractLogger, get_logger
|
||||
|
||||
logger: AbstractLogger = get_logger().bind(module="chat_service")
|
||||
```
|
||||
|
||||
Contextvar-ы `http_request_id` и `current_user_id` лежат в этом же
|
||||
модуле; ставят их только request-id middleware и `get_current_user`.
|
||||
|
||||
- В начале метода с побочным эффектом —
|
||||
`log = logger.bind(method="create_chat", chat_id=..., members_count=...)`.
|
||||
В `bind` идут идентификаторы, по которым лог будут искать.
|
||||
- Вложенный шаг большой операции принимает `log: AbstractLogger`
|
||||
параметром и пишет через него.
|
||||
- Сообщение — константная строка на английском: прошедшее время для
|
||||
результата («Created chat»), -ing для начала («Creating chat»).
|
||||
Переменные данные только в kwargs, не в f-string.
|
||||
- Исключения: `error=str(e)`; `exc_info=e` — только там, где нужен
|
||||
traceback непредвиденной ошибки.
|
||||
- Только `get_logger()`: без `print`, `traceback.print_exc()` и
|
||||
`logging.getLogger`.
|
||||
|
||||
Уровни: `debug` — промежуточные шаги; `info` — бизнес-событие (создан
|
||||
пользователь, чат, сообщение), старт и остановка; `warning` —
|
||||
обработано, но требует внимания; `error` — операция не выполнена,
|
||||
непредвиденное исключение. `critical` не используется.
|
||||
@@ -0,0 +1,62 @@
|
||||
---
|
||||
paths:
|
||||
- "migrations/**"
|
||||
- "alembic.ini"
|
||||
- "src/infra/db/models/**"
|
||||
---
|
||||
|
||||
# Миграции alembic и модели
|
||||
|
||||
Основа — правила bp_proxies; отличия продиктованы контрактом и
|
||||
рубрикой лабы 2.
|
||||
|
||||
- Схема — до запросов: таблицы, ограничения, индексы и транзакционные
|
||||
границы описываются в design change раньше, чем пишутся repo
|
||||
(`README.md`, «Что сделать», п. 1).
|
||||
- `alembic upgrade head` поднимает схему на пустом volume и повторно
|
||||
отрабатывает без ошибок и без дублей. Данные миграции не сеют:
|
||||
тестовых пользователей создают тесты через API.
|
||||
- Обязательно для «3»: первичные и внешние ключи (участник → чат и
|
||||
пользователь, сообщение → чат и отправитель), уникальный `username`,
|
||||
уникальная пара чат–участник. Таблица сессий, если сессии в
|
||||
Postgres, — `auth.md`.
|
||||
|
||||
- Модели — `src/infra/db/models/<domain>.py`. `Base` даёт `created_at`
|
||||
и `to_dict()`. Новая модель экспортируется в `models/__init__.py`,
|
||||
иначе autogenerate её не видит.
|
||||
- Первичный ключ — `UUID`, значение генерирует сервис (`uuid4()`):
|
||||
контракт отдаёт UUID. Автоинкремент не использовать.
|
||||
- Время — `DateTime(timezone=True)` (`timestamptz`), aware UTC: контракт
|
||||
требует `...Z`. В bp_proxies было naive UTC — здесь так нельзя.
|
||||
- Индексы под запросы контракта: `(chat_id, created_at, id)` для
|
||||
keyset-истории, уникальный `username`, участник → чаты. Индекс
|
||||
истории обосновывается запросом и `EXPLAIN (ANALYZE, BUFFERS)` на
|
||||
≥10 000 сообщениях (уровень 4), вывод — в `evidence/`.
|
||||
- Колонки типизированы `Mapped[...]`, внешние ключи — через
|
||||
`ForeignKey`.
|
||||
- Имя файла ревизии `YYYY_MM_DD_HHMM-<rev>_<slug>.py` (`file_template`
|
||||
в `alembic.ini`). Сообщение короткое, на английском, в прошедшем
|
||||
времени («added chats tables»). Пустая ревизия (`pass` в `upgrade`) —
|
||||
удалить.
|
||||
- Autogenerate не видит: новые значения enum, изменение
|
||||
`server_default`, частичные индексы (`postgresql_where`),
|
||||
переименования (сделает drop + create). Их правят руками.
|
||||
- `NOT NULL` на существующей таблице — с `server_default` или с
|
||||
backfill через `op.execute` перед `alter_column`.
|
||||
- Constraint-ы именованные, чтобы `downgrade` мог их снять. `downgrade`
|
||||
зеркалит `upgrade` в обратном порядке. Применённую ревизию не
|
||||
редактировать: новая ревизия поверх.
|
||||
- Миграции применяются до старта API: в compose — отдельный
|
||||
одноразовый сервис на образе API (`docker.md`), API ждёт
|
||||
`service_completed_successfully`; в консоли — `make run_dev` через
|
||||
`make upgrade`. Не `sh -c "alembic upgrade head && python -m src"`
|
||||
(сервер перестаёт быть PID 1) и не из lifespan: с лабы 3 реплик
|
||||
несколько.
|
||||
- `migrations/env.py` — асинхронный шаблон alembic: URL из
|
||||
`settings.database.url`, мимо ConfigParser (`%` в пароле ничего не
|
||||
ломает), журнал — JSON через `src/infra/logger.py`. Синхронный
|
||||
`env.py` с asyncpg, как в bp_proxies, на SQLAlchemy 2.1 не работает:
|
||||
флаг `async_fallback` удалён. Ревизии — обычный синхронный `op.*`.
|
||||
- В ревизиях — литералы, а не константы `src`: применённая ревизия не
|
||||
меняется вместе с кодом. Autogenerate для новой таблицы рендерит и
|
||||
`CHECK`; для существующей таблицы новые `CHECK` дописываются руками.
|
||||
@@ -0,0 +1,42 @@
|
||||
---
|
||||
paths:
|
||||
- "src/core/repos/**"
|
||||
---
|
||||
|
||||
# Слой repo (`src/core/repos/<domain>.py`)
|
||||
|
||||
Только доступ к данным. Ни бизнес-логики (проверок доступа, валидации),
|
||||
ни логов, ни внешних вызовов.
|
||||
|
||||
- Модульные `async def`, без классов. Первый параметр —
|
||||
`db_session: AsyncSession`. Остальные параметры вызывающий передаёт по
|
||||
имени.
|
||||
- **Одна атомарная операция на функцию:** максимум один
|
||||
`db_session.execute(...)`. Нужна вторая выборка — вторая функция,
|
||||
CTE, подзапрос или `.returning(...)`.
|
||||
- Запросы — только через SQLAlchemy (Core или ORM) с параметрами; SQL
|
||||
из f-строк и конкатенации запрещён (уровень 4). `text()` — только с
|
||||
bind-параметрами.
|
||||
- Уникальность проверяется в той же функции, что и вставка:
|
||||
`pg_insert(...).on_conflict_do_nothing(...).returning(...)`. При
|
||||
конфликте функция возвращает `None`, исключение бросает сервис.
|
||||
- Наружу отдаются DTO (`.claude/rules/dto.md`), а не ORM-объекты:
|
||||
`expunge` и `<Entity>FullDTO(**row.to_dict())` либо DTO из выбранных
|
||||
колонок, а не `select(Model)`.
|
||||
- Никаких `commit()` / `rollback()`: транзакцией управляет сервис.
|
||||
- Мутации возвращают осмысленный результат: созданный DTO, `bool`,
|
||||
`None` при конфликте.
|
||||
- Keyset-страница: параметры `after: tuple[datetime, UUID] | None` и
|
||||
`limit`, выборка `limit + 1` элементов, чтобы сервис узнал о следующей
|
||||
странице. Условие — `tuple_(Model.created_at, Model.id) > tuple_(...)`,
|
||||
`ORDER BY created_at, id`, `LIMIT`, по индексу
|
||||
`(chat_id, created_at, id)`. Без `OFFSET` и `count(*)`: уровень 4
|
||||
запрещает полный scan истории на каждую страницу, план подтверждается
|
||||
`EXPLAIN (ANALYZE, BUFFERS)` (`migrations.md`).
|
||||
- Опциональные фильтры и лимиты — условное дополнение выборки
|
||||
(`if limit is not None: ...`).
|
||||
- Логов в репозиториях нет: ни `get_logger`, ни `print`.
|
||||
- Repo кэша (`chat_cache.py`) — то же правило над Valkey: первый
|
||||
параметр `cache: Cache`, одна команда на функцию, ключ и формат
|
||||
значения (JSON ↔ DTO) живут здесь. Ключ включает
|
||||
`CACHE_KEY_PREFIX` (версию формата) и `cache.namespace` (имя базы).
|
||||
@@ -0,0 +1,108 @@
|
||||
---
|
||||
paths:
|
||||
- "src/main.py"
|
||||
- "src/__main__.py"
|
||||
- "src/config/settings.py"
|
||||
- "Makefile"
|
||||
- "docker-compose.yml"
|
||||
- ".env.example"
|
||||
- "config_example.toml"
|
||||
---
|
||||
|
||||
# Режимы запуска: console и docker
|
||||
|
||||
Режим задаёт `APP__RUN_MODE` (`settings.app.run_mode`, `RunModeEnum`),
|
||||
дефолт — `console`. В `.env` режим не хранится. Для docker его задают
|
||||
`ENV APP__RUN_MODE=docker` в Dockerfile (чтобы голый `docker run` из
|
||||
README слушал `0.0.0.0`) и литерал в `environment` compose; для консоли —
|
||||
цели Makefile.
|
||||
|
||||
| | console | docker |
|
||||
|---|---|---|
|
||||
| Процесс | `uv run python -m src` на хосте | `python -m src` — PID 1 контейнера |
|
||||
| uvicorn | `127.0.0.1`, `reload=True` по `src/` | `0.0.0.0`, без reload |
|
||||
| Порт | `settings.app.port`: `APP__PORT` из `.env`, без него — 8080 | `APP__PORT` из `.env` внутри (на нём же healthcheck), `APP_OUT_PORT` снаружи |
|
||||
| Хранилища | Postgres и Valkey — контейнеры compose, приложение ходит на `127.0.0.1:<*_OUT_PORT>` (`settings.md`, «Консоль и docker»); `make run_dev` сам поднимает Postgres, накатывает миграции и поднимает Valkey | всё в compose, зависимости по имени сервиса; миграции — отдельный сервис до старта API (`migrations.md`) |
|
||||
| Рестарт | reload процесса данные и сессии не теряет | рестарт API и хранилищ с volumes данные и сессии не теряет (`make test-persistence`); кэш Valkey после рестарта пуст |
|
||||
|
||||
## Точка входа
|
||||
|
||||
`python -m src` → `src/__main__.py` → `src.main:main()` →
|
||||
`uvicorn.run("src.main:app", host=..., port=..., reload=...,
|
||||
timeout_graceful_shutdown=..., log_config=None, access_log=False)`.
|
||||
Хост выбирается по режиму, как в bp_proxies. `log_config=None` нужен,
|
||||
чтобы uvicorn не перетёр JSON-логирование (`logging.md`).
|
||||
|
||||
- Worker всегда один. Состояние уже в Postgres, но масштабирование —
|
||||
задача лабы 3 (отдельные контейнеры за балансировщиком), а пул
|
||||
соединений (`infra.md`) рассчитан на один процесс.
|
||||
- SIGTERM: uvicorn перестаёт принимать новые соединения и ждёт текущие
|
||||
запросы до `timeout_graceful_shutdown` (настройка
|
||||
`[app] graceful_shutdown_seconds`, не больше 8 с). Docker шлёт SIGKILL
|
||||
через 10 с, в compose — `stop_grace_period`. Shutdown в lifespan
|
||||
только логирует и закрывает клиенты (`engine.dispose()`,
|
||||
`cache.aclose()`), долгих операций в нём нет.
|
||||
Рубрика уровня 4 требует завершения не дольше 10 с.
|
||||
|
||||
## Makefile
|
||||
|
||||
- Цели skeleton `help`, `check`, `validate`, `test`, `load`,
|
||||
`test-persistence` не менять:
|
||||
в следующей лабе `Makefile` придёт новый, и свои цели в него
|
||||
переносятся слиянием (AGENTS.md, «Переход в следующую лабу»).
|
||||
- Свои цели — отдельными секциями ниже целей skeleton, в стиле
|
||||
bp_proxies: переменные наверху (`DC=docker compose`), заголовки
|
||||
`# -------------------------`, свой `.PHONY` у каждой цели, имена в
|
||||
snake_case. Apple Container не делать.
|
||||
- Запуск и общие цели:
|
||||
- `run_dev: upgrade start_cache` — Postgres из compose и миграции,
|
||||
Valkey из compose, затем `APP__RUN_MODE=console uv run python -m
|
||||
src`;
|
||||
- `run_docker: env_setup` (недостающие `.env` и `config.toml` из
|
||||
шаблонов, затем `DOCKER_BUILDKIT=1 $(DC) build` и `$(DC) up -d`),
|
||||
к нему `stop`, `down` (volume остаётся), `logs`
|
||||
(`$(DC) logs -f --no-log-prefix api`: без префикса `api-1 |`
|
||||
каждая строка — JSON);
|
||||
- `lint` (`ruff format .` + `ruff check --fix .`, дважды),
|
||||
`env_setup` (шаблоны `.env` и `config.toml`, в новый `.env` —
|
||||
случайные `POSTGRES_PASSWORD` и `VALKEY_PASSWORD`; существующий
|
||||
`.env` не меняется, новые строки переносятся руками),
|
||||
`student_test`.
|
||||
|
||||
Оба способа запуска — `run_docker` и `run_dev` — описываются в
|
||||
`REPORT.md`. Запуска одного контейнера без compose нет: API без
|
||||
Postgres не обслуживает запросы.
|
||||
- PostgreSQL и миграции: `start_db` (`$(DC) up -d --wait postgres`),
|
||||
`stop_db`, `upgrade: start_db` (`uv run alembic upgrade head`),
|
||||
`revision: upgrade` (autogenerate, сообщение — `read -p`),
|
||||
`wipe_data` (`$(DC) down -v --remove-orphans` только после ввода
|
||||
`yes`). Volume — именованный `postgres_data` в compose; `wipe_data`
|
||||
пересоздаёт и Valkey, то есть чистит кэш.
|
||||
- Valkey: `start_cache` (`$(DC) up -d --wait valkey`), `stop_cache`.
|
||||
- `test_isolated: env_setup start_db start_cache` — образ на временной
|
||||
базе (`student-tests.md`); Valkey общий с рабочим стендом, ключи кэша
|
||||
разделены именем базы. Скрипт запускается `$(PYTHON)`, а не
|
||||
`uv run`: uv повторно пересылает SIGINT, и Ctrl+C обрывал уборку.
|
||||
- `failure_checks: env_setup` — проверки отказов на отдельном стенде,
|
||||
проект compose `<рабочий>-failures` (`student-tests.md`). От
|
||||
`start_db` не зависит: стенд свой и удаляется вместе с volume.
|
||||
`FAULT_ARGS` — аргументы pytest (`make failure_checks FAULT_ARGS='-k
|
||||
valkey'`). Скрипт тоже запускается `$(PYTHON)`. Все команды docker
|
||||
проекта отказов — только с `-p <рабочий>-failures`: `down -v` без
|
||||
него удалил бы рабочий volume.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- `make test` падает с 404 на `/health/live` вместо ошибки соединения:
|
||||
на 8080 отвечает чужой сервис. Найти его — `lsof -nP -iTCP:8080
|
||||
-sTCP:LISTEN` и `docker ps`; для своего стенда взять другой
|
||||
`APP_OUT_PORT` и `make test BASE_URL=http://localhost:<порт>`.
|
||||
- Разовая подмена внешнего порта для целей Makefile — только
|
||||
аргументом: `make run_docker APP_OUT_PORT=8090`. Внутренний
|
||||
`APP__PORT` — только в `.env`: его читают и compose, и приложение в
|
||||
console, а аргумент make поменял бы одну переменную make. Префикс
|
||||
`APP_OUT_PORT=8090 make ...` не сработает: `-include .env` перекроет
|
||||
его, и в recipe (в том числе в `docker compose`) уйдёт значение из
|
||||
`.env`.
|
||||
- Поменял `config.toml` и не видишь эффекта: значение перекрыто
|
||||
окружением или `.env` (приоритет env > .env > toml).
|
||||
@@ -0,0 +1,58 @@
|
||||
---
|
||||
paths:
|
||||
- "src/core/services/**"
|
||||
---
|
||||
|
||||
# Слой service (`src/core/services/<domain>.py`)
|
||||
|
||||
Бизнес-логика, проверки доступа, серверные значения (id, время),
|
||||
транзакции, вызовы внешних клиентов, логи.
|
||||
|
||||
- Класс `<Domain>Service`. `__init__` принимает
|
||||
`db_session: AsyncSession` и хранит его в `self`; кэш Valkey
|
||||
(`cache: Cache`), если он нужен домену, — вторым параметром
|
||||
(`ChatService`, `MessageService`). Методы принимают keyword-only
|
||||
параметры (`*,`) и вызываются только именованными аргументами.
|
||||
- Кэш карточки чата (`chat_cache_repo`, спек `chat-cache`):
|
||||
cache-aside — сначала кэш, при промахе БД и запись в кэш; новый чат
|
||||
пишется в кэш **после** `commit()`, чтобы откат не оставил в кэше
|
||||
чата, которого нет в БД. Отсутствующий чат не кэшируется. Кэшировать
|
||||
можно только неизменяемое: историю, списки и сессии — нет. Отказ
|
||||
Valkey сервис не обрабатывает: `Cache` уже вернул промах.
|
||||
- Repo: `from src.core.repos import chat as chat_repo`. Вызов —
|
||||
`db_session=self.db_session` и именованные аргументы.
|
||||
- Проверка доступа — здесь. Не участник получает то же исключение, что
|
||||
«не найден» (`ChatNotFound`): API отдаст 404 и не раскроет, что чат
|
||||
существует.
|
||||
- Ошибки — доменные исключения из `src/core/exceptions` (новое — в
|
||||
модуль домена и реэкспорт в `__init__.py`). Не `ValueError` и не
|
||||
`HTTPException`: статус и `code` назначает `src/api/errors.py`.
|
||||
- Серверные значения назначает сервис: `id = uuid4()`,
|
||||
`created_at = utcnow()` из `src/utils/utc.py`.
|
||||
- Атомарность — транзакция Postgres. Составная операция (чат вместе с
|
||||
участниками) — все вызовы repo на одном `db_session` и один
|
||||
`await self.db_session.commit()` в конце. Ошибка до commit —
|
||||
`rollback()`, и в БД не остаётся ничего. Откат составной операции —
|
||||
проверка уровня 4.
|
||||
- Коммитит только сервис, repo не коммитит. Другой сервис создаётся с
|
||||
тем же `db_session` (и тем же кэшем), чтобы остаться в одной
|
||||
транзакции.
|
||||
- Уникальность (`username`) держит ограничение БД, а не проверка
|
||||
перед вставкой: repo делает `ON CONFLICT DO NOTHING RETURNING`,
|
||||
`None` сервис превращает в доменное исключение (→ 409). Схема «сначала
|
||||
SELECT, потом INSERT» ломается на гонке регистрации даже внутри
|
||||
транзакции (READ COMMITTED), а эта гонка — проверка уровня 4.
|
||||
- Недоступность Postgres (там же хранятся сессии) — доменное
|
||||
`ServiceUnavailable` (→ 503), не 500 и никогда не пропуск запроса без
|
||||
аутентификации (`infra.md`). Недоступность Valkey — не ошибка, а
|
||||
промах кэша.
|
||||
- KDF пароля — в потоке, не в event loop (`auth.md`).
|
||||
- Курсор кодирует и разбирает сервис через `src/utils/cursor.py`:
|
||||
проверяет область (этот чат или этот пользователь) и возвращает
|
||||
`<Entity>PageDTO` с готовым `next_cursor`. Неверный курсор — доменное
|
||||
исключение (→ 400).
|
||||
- Чистые вычисления — модульные функции над классом, без обращения к
|
||||
хранилищу.
|
||||
- Read-only методы, которые лишь делегируют в repo, не логируют.
|
||||
Остальное — по `.claude/rules/logging.md`.
|
||||
- Константы (лимиты, размер страницы) — `src/utils/constants.py`.
|
||||
@@ -0,0 +1,176 @@
|
||||
---
|
||||
paths:
|
||||
- "src/config/**"
|
||||
- ".env.example"
|
||||
- "config_example.toml"
|
||||
---
|
||||
|
||||
# Настройки: `.env`, `config.toml`, `src/config/settings.py`
|
||||
|
||||
Схема из bp_proxies (`src/data/settings.py` там). Что делают режимы
|
||||
console и docker — `.claude/rules/run-modes.md`. Здесь — откуда берутся
|
||||
значения и куда класть новое.
|
||||
|
||||
## Источники `Settings`
|
||||
|
||||
- `src/config/settings.py`: `Settings(BaseSettings)` из секций-`BaseModel`
|
||||
(`App`, `Database`, `Auth`, `Cache` — Valkey). Экземпляр один —
|
||||
`settings` на уровне модуля. Импорт везде `from src.config import
|
||||
settings`. Второй `Settings()` не создавать, поля в рантайме не менять.
|
||||
- Приоритет (`settings_customise_sources`): окружение процесса → `.env`
|
||||
→ `config.toml` → дефолты. Отсутствующий файл пропускается. Без
|
||||
`.env` и `config.toml` `Settings` обязан загрузиться на дефолтах: так
|
||||
работают импорт `src`, alembic и чистый clone. Стенд лабы 2
|
||||
запускается через compose и получает значения из `.env`; без Postgres
|
||||
приложение стартует, но `/health/ready` отвечает 503.
|
||||
- Все поля живут в секциях, откуда бы ни пришло значение: секцию задаёт
|
||||
класс `Settings`, а не файл. Вложенные поля в env — через `__`,
|
||||
регистр не важен: `DATABASE__PASSWORD` попадает в
|
||||
`settings.database.password` так же, как `[database] password` из
|
||||
TOML. Переменную без префикса секции (`APP_PORT`, `POSTGRES_PASSWORD`)
|
||||
приложение не видит: она для compose.
|
||||
- Имена из контракта и skeleton (`SESSION_TTL_SECONDS`, `APP_HOST`)
|
||||
буквально не заводятся, если значение читает только приложение. Поле
|
||||
живёт в секции (`[auth] session_ttl_seconds` в `config.toml`), а
|
||||
соответствие имени описано в `REPORT.md`. Мост — только для значения,
|
||||
которое читает ещё контейнер зависимости (раздел «Мосты» ниже).
|
||||
- `extra="ignore"`: опечатка в ключе молча оставит дефолт. После правки
|
||||
проверить конкретное поле: `uv run python -c "from src.config import
|
||||
settings; print(settings.app.port)"`. Полный дамп настроек не печатать:
|
||||
в нём пароли.
|
||||
- Подмена через окружение ставится до первого импорта `src`: потом
|
||||
`settings` уже прочитан.
|
||||
|
||||
## Что где хранится
|
||||
|
||||
Критерий — кто читает значение, а не секретное ли оно.
|
||||
|
||||
| Где | Что | В git |
|
||||
|---|---|---|
|
||||
| `config.toml` | всё, что читает **только приложение**, по секциям: `log_level`, пул и таймауты `[database]`, TTL сессии, таймауты, пул и срок записей `[cache]`, секреты, которые нужны одному приложению | нет; шаблон `config_example.toml` |
|
||||
| `.env` | всё, что читает **compose** (и Makefile) и контейнеры зависимостей: порты `APP__PORT` / `APP_OUT_PORT`, `POSTGRES_*` и `VALKEY_*` (адрес, порты, учётные данные), пароли MinIO / брокера с лаб 4–5; мосты `SECTION__FIELD=${...}` для приложения, в том числе консольные адреса Postgres и Valkey | нет; шаблон `.env.example` |
|
||||
| окружение процесса | режим `APP__RUN_MODE` и разовые подмены | — |
|
||||
| `src/utils/constants.py` | лимиты контракта (3–32, 100, 4000, `limit` 1–100 / 50), пути: одинаковы на всех установках | да |
|
||||
|
||||
Схему согласовали с преподавателем 2026-09-29 (AGENTS.md, «Согласования
|
||||
с преподавателем»). Секреты в `config.toml` допустимы. Запрет
|
||||
`Dockerfile.example` касается запекания в образ (`COPY`), а
|
||||
`config.toml` в образ не копируется, его монтируют на старте
|
||||
(`docker.md`). Но почти все секреты курса — пароли
|
||||
Postgres, Valkey, MinIO, брокера — нужны ещё и контейнеру зависимости,
|
||||
а его настраивает только compose из `.env`. Поэтому такой секрет живёт
|
||||
в `.env` и попадает в приложение мостом. Если продублировать его в
|
||||
`config.toml`, как `postgres_password` в bp_proxies, получатся два
|
||||
источника, которые рано или поздно разойдутся.
|
||||
|
||||
## Имена в `.env`: параметр приложения — в формате настроек
|
||||
|
||||
Если переменная касается самого приложения, в `.env` она пишется в
|
||||
формате настроек (`SECTION__FIELD`), даже когда её читают ещё compose и
|
||||
Makefile. Пример — внутренний порт `APP__PORT`: на нём слушает
|
||||
приложение, его публикует compose, на нём работает healthcheck. Compose
|
||||
читает `${APP__PORT}` напрямую и передаёт в `environment` под тем же
|
||||
именем.
|
||||
|
||||
Имя без секции — только у того, что приложение не читает:
|
||||
`APP_OUT_PORT` (порт на хосте), `POSTGRES_*` и другие переменные
|
||||
контейнеров зависимостей. Если такое значение нужно ещё и приложению,
|
||||
оно приходит мостом (ниже).
|
||||
|
||||
Поле, которое задаётся в `.env`, в `config_example.toml` не
|
||||
дублируется: по приоритету значение из `.env` перекрыло бы toml, и
|
||||
строка там ни на что не влияла бы. Поэтому в `[app]` нет `port`.
|
||||
|
||||
`.env` читает и Makefile (`-include .env`), поэтому комментарии в нём
|
||||
пишутся только отдельными строками. make, в отличие от compose,
|
||||
оставляет пробел перед `# комментарий` в конце строки частью значения.
|
||||
|
||||
## Мосты: значение из `.env` в секцию приложения
|
||||
|
||||
Мост нужен, когда имя переменной навязано контейнером зависимости
|
||||
(`POSTGRES_PASSWORD` для образа postgres), а приложению то же значение
|
||||
нужно в своей секции. Мост — строка, которая отдаёт значение переменной
|
||||
compose полю секции:
|
||||
|
||||
- в `.env` — `DATABASE__PASSWORD=${POSTGRES_PASSWORD}`: pydantic-settings
|
||||
раскрывает `${VAR}` при чтении `.env` (проверено на 2.15), так
|
||||
значение получает приложение в console-режиме;
|
||||
- в `environment` сервиса compose — та же строка, так значение получает
|
||||
контейнер. Сам `.env` в контейнер не передаётся.
|
||||
|
||||
`docker run --env-file .env` раскрывать `${...}` не умеет и передаст
|
||||
строку буквально, поэтому стенд запускается только через compose.
|
||||
|
||||
Окружение не перекрывает мост по исходному имени. python-dotenv
|
||||
подставляет `${VAR}` сначала из самого `.env` и лишь потом из окружения,
|
||||
поэтому `POSTGRES_OUT_PORT=5545 uv run ...` оставит в `DATABASE__PORT`
|
||||
значение из файла (проверено на таком же мосте срока сессии, change
|
||||
`session-auth`). Разовая подмена —
|
||||
только по имени поля: `DATABASE__PORT=5545`.
|
||||
|
||||
## Консоль и docker из одного `.env`
|
||||
|
||||
Переключение консоль ↔ docker не требует правки файлов и
|
||||
комментирования блоков, как в bp_proxies (design change
|
||||
`postgres-storage`, решение 7):
|
||||
|
||||
- консоль: приложение на хосте читает `.env`, мосты
|
||||
`DATABASE__HOST=127.0.0.1`, `DATABASE__PORT=${POSTGRES_OUT_PORT}` и
|
||||
учётные данные из `POSTGRES_*`; для Valkey —
|
||||
`CACHE__HOST=127.0.0.1`, `CACHE__PORT=${VALKEY_OUT_PORT}`,
|
||||
`CACHE__PASSWORD=${VALKEY_PASSWORD}`;
|
||||
- docker: `.env` в контейнер не попадает, адрес и порт приходят из
|
||||
`environment` compose — `DATABASE__HOST: ${POSTGRES_HOST}`,
|
||||
`DATABASE__PORT: ${POSTGRES_PORT}`, `CACHE__HOST: ${VALKEY_HOST}`,
|
||||
`CACHE__PORT: ${VALKEY_PORT}` в общем якоре `x-app-env`.
|
||||
|
||||
Адреса и порты Postgres и Valkey в compose — только переменные `.env`,
|
||||
литерал — лишь адрес публикации `127.0.0.1` (`docker.md`).
|
||||
|
||||
Существующий `.env` `make env_setup` не меняет. Новая переменная из
|
||||
`.env.example` (с `membership-cache` — строки `VALKEY_*` и `CACHE__*`)
|
||||
переносится в рабочий `.env` руками; без `VALKEY_PASSWORD` compose
|
||||
останавливается с сообщением об этом.
|
||||
|
||||
`.env.example` skeleton lab2 предлагает «логические» имена: `APP_HOST`,
|
||||
`APP_PORT`, `APP_ENV`, `SESSION_TTL_SECONDS`, `DATABASE_URL_FILE`,
|
||||
`SESSION_STORE`, `CACHE_URL_FILE`; шапка шаблона просит сопоставить их
|
||||
с реальными в `REPORT.md`. `SESSION_TTL_SECONDS` называют ещё контракт и
|
||||
рубрика, но ни одна публичная проверка его не читает. Срок сессии читает
|
||||
только приложение, поэтому это `[auth] session_ttl_seconds` в
|
||||
`config.toml`, а короткий срок для проверки истечения —
|
||||
`AUTH__SESSION_TTL_SECONDS=2` в окружении. Мост с контрактным именем
|
||||
ничего бы не дал: по абзацу выше окружение его не перекрывает. Пароли
|
||||
Postgres и Valkey приходят мостами из `POSTGRES_PASSWORD` и
|
||||
`VALKEY_PASSWORD`, а не строкой подключения в файле (`DATABASE_URL_FILE`,
|
||||
`CACHE_URL_FILE`). `SESSION_STORE` — PostgreSQL, отдельной настройки
|
||||
нет. Соответствие переменных реальной конфигурации описать в
|
||||
`REPORT.md` (раздел «Архитектура и решения»).
|
||||
|
||||
В настройки идёт только то, что отличается между установками, либо
|
||||
секрет. Остальное — константа.
|
||||
|
||||
## Новое поле или секция
|
||||
|
||||
1. Поле с типом и безопасным дефолтом: `Settings` загружается без
|
||||
файлов.
|
||||
Секрет — `""` и проверка при старте там, где он нужен. Единицы —
|
||||
коротким комментарием (`# секунды`).
|
||||
2. Новая секция — класс `<Name>(BaseModel)` и поле
|
||||
`<name>: <Name> = <Name>()` в `Settings`. Имя поля одновременно имя
|
||||
секции TOML и префикс env.
|
||||
3. Строка в `config_example.toml` с плейсхолдером и в рабочем
|
||||
`config.toml`. Значения из `config.toml` не печатать в ответ и лог.
|
||||
4. Значение нужно и compose, и приложению:
|
||||
- параметр самого приложения (порт) — переменная `SECTION__FIELD` в
|
||||
`.env.example` с комментарием и в `environment` сервиса compose
|
||||
(`docker.md`);
|
||||
- значение с именем, которое навязывает контейнер зависимости
|
||||
(пароль Postgres), — переменная и мост в `.env.example`, мост в
|
||||
`environment` сервиса compose.
|
||||
|
||||
В обоих случаях в `config_example.toml` поле не дублировать.
|
||||
5. Строка подключения — `@property` секции (`Database.url`): вызывающий
|
||||
код URL сам не собирает.
|
||||
6. Когда появятся `config_example.toml` и `config.toml`, добавить
|
||||
`config.toml` в `.gitignore` и `.dockerignore`.
|
||||
@@ -0,0 +1,116 @@
|
||||
---
|
||||
paths:
|
||||
- "student-tests/**"
|
||||
---
|
||||
|
||||
# Собственные тесты (`student-tests/`)
|
||||
|
||||
В bp_proxies тесты запрещены. Здесь они обязательны для уровня 4
|
||||
(`README.md`), и каждый должен запускаться одной командой. Лаба 2
|
||||
требует автоматических проверок:
|
||||
|
||||
- истечения сессии при коротком `SESSION_TTL_SECONDS`, logout, неверного
|
||||
пароля;
|
||||
- недоступности Postgres и Redis/Valkey: ограниченная ошибка или
|
||||
корректный обход кэша, и никогда запрос как от анонимного;
|
||||
- гонки регистрации одного `username` (ровно один 201, остальные 409) и
|
||||
отката составной операции.
|
||||
|
||||
Проверки лабы 1 остаются: возможности прежних лаб сохраняются
|
||||
(`README.md`, «Что должно быть в PR»). Это неверный JSON, чужой чат,
|
||||
пустое сообщение, дубликат `username`, обход нескольких страниц истории
|
||||
и гонка: 10 клиентов параллельно отправляют 100 сообщений, и в истории
|
||||
ровно 100 уникальных. Команду и результат сохранить.
|
||||
|
||||
## Как писать
|
||||
|
||||
- Black-box по HTTP против запущенного сервера (`BASE_URL`, по умолчанию
|
||||
`http://localhost:8080`), как публичный smoke. Тест не импортирует
|
||||
`src` и не поднимает приложение сам: те же тесты проверяют и
|
||||
контейнер, и следующие лабы.
|
||||
- pytest + httpx в dev-группе uv, запуск — `make student_test`.
|
||||
- Каждый тест создаёт своих пользователей с уникальным `username`
|
||||
(uuid-суффикс): состояние сервера общее, а удалять данные API не умеет.
|
||||
- Проверять не только статус, но и форму: `{"error": {...}}` с
|
||||
`code`, `request_id` совпадает с `X-Request-Id`, у успешных ответов
|
||||
нет лишних полей. Семантика — `.claude/rules/api-contract.md`.
|
||||
- Тест гонок — реальная параллельность, а не цикл: потоки за
|
||||
`threading.Barrier`, у каждого свой `Api` (своё соединение). Тест
|
||||
требует, чтобы одновременно в полёте было ≥ 2 запросов, иначе гонка
|
||||
не доказана. Проверяются количество и уникальность `id`, а также
|
||||
отсутствие потерь при обходе всех страниц.
|
||||
- Обычный прогон — `make test_isolated` (`student-tests/run_isolated.py`):
|
||||
образ из рабочего дерева на временной базе `test_<db>` с Valkey
|
||||
стенда (ключи кэша разделены именем базы), публичный smoke и весь
|
||||
набор против отдельного контейнера, затем уборка при любом исходе.
|
||||
Его вывод — evidence набора против контейнера.
|
||||
`make student_test` — против любого запущенного стенда (`BASE_URL`),
|
||||
он оставляет данные в рабочей базе.
|
||||
- Проверкам, которым нужен особый стенд (TTL 2 с, остановленные или
|
||||
замороженные Postgres и Valkey, сбой БД посреди транзакции), обычный
|
||||
прогон не подходит. Это **проверки отказов**: маркер `fault`, модуль
|
||||
`test_failures.py`, команда `make failure_checks` (change
|
||||
`failure-checks`). Попадание в кэш по HTTP не отличить от чтения из
|
||||
БД: такие сценарии `chat-cache` — исключения с evidence.
|
||||
- Как устроен `make failure_checks` (`student-tests/run_failures.py`):
|
||||
- тот же `docker-compose.yml` под проектом `<рабочий>-failures` с
|
||||
override `failures.compose.yml`: свои Postgres и Valkey со своим
|
||||
volume, их порты не публикуются;
|
||||
- два API на свободных портах `127.0.0.1`: обычный (`BASE_URL`) и
|
||||
«тесный» (`FAULT_TIGHT_BASE_URL`: срок сессии 2 с, пул 1, короткие
|
||||
таймауты);
|
||||
- `pytest -m fault`, затем удаление стенда с volume при любом
|
||||
исходе. Рабочий стенд не трогается;
|
||||
- **два прогона одновременно не запускать** (терминал, IDE, агент):
|
||||
уборка хвоста в начале второго делает `down -v` стенда первого, и
|
||||
оба падают с конфликтом имён контейнеров. Блокировки нет намеренно.
|
||||
- Тесты `fault` сами docker не трогают. На стенд они действуют только
|
||||
через фикстуру `stand` — hook `student-tests/fault_hook.py`, как
|
||||
`make test-persistence` вызывает `ACTION_SCRIPT`. Маркер `fault`
|
||||
выбирает тесты, фикстура `stand` действует на стенд: имена разные
|
||||
намеренно. Действия: `stop` / `start` /
|
||||
`pause` / `unpause`, `flush-cache`, `cache-hits`, `cache-has-chat`,
|
||||
`fail-members` (триггер, который роняет вставку участников),
|
||||
`count-chats`. Hook работает только с проектом из `FAULT_PROJECT` и
|
||||
отказывается работать с проектом рабочего стенда.
|
||||
- Тест `fault`, который останавливает или замораживает хранилище,
|
||||
делает это в `with outage(...)`: в `finally` хранилище возвращается,
|
||||
и упавшая проверка не ломает следующие. Границы времени — с запасом
|
||||
0,3–0,5 с, но на порядок ниже «плохого» поведения (6 с повторов
|
||||
redis-py, 8 с зависшего запроса).
|
||||
- `addopts` содержит `-m 'not fault'`: `make student_test` и
|
||||
`make test_isolated` тесты `fault` собирают (их сценарии видит сверка
|
||||
покрытия), но не выполняют. Запуск `pytest -m fault` без
|
||||
`make failure_checks` останавливается до первого теста с кодом 2.
|
||||
- Пароли и токены тестов синтетические, не печатаются и не попадают в
|
||||
`evidence/` (`evidence/README.md`).
|
||||
- `tests/` — публичные проверки skeleton: не править, не ослаблять,
|
||||
свои тесты туда не класть.
|
||||
- Вывод прогона (команда, дата, commit, результат) — в `evidence/` и
|
||||
строкой в таблицу доказательств `REPORT.md`.
|
||||
|
||||
## Как устроен набор
|
||||
|
||||
- **Идентификация — только `Actor.headers()`** (`api_client.py`):
|
||||
`Authorization: Bearer <token>`. Токен `Actor` получает при входе:
|
||||
регистрация с паролем, затем `POST /auth/sessions` по Basic. Тесты
|
||||
передают `actor=`; заголовок руками собирает только
|
||||
`test_identification.py` (Basic, битый и чужой Bearer, `X-User-Id`).
|
||||
`Actor.unregistered()` — токен, которого нет на сервере.
|
||||
- **Форма ответа — через `contract.py`**, без ручного сравнения ключей:
|
||||
`assert_ok(resp, status, "<Schema>")` для успеха, `assert_error(resp,
|
||||
status)` для ошибки (`code` берётся из статуса). Хелперы `Api`
|
||||
(`register`, `create_chat`, `send_message`, обход страниц) уже
|
||||
проверяют схемы.
|
||||
- **Каждый тест сценария спека помечен** `@pytest.mark.spec("<capability>",
|
||||
"<Сценарий>")`, имя — дословно из `#### Scenario:`. Новый сценарий в
|
||||
основном спеке без теста роняет `test_coverage.py`. Если его нельзя
|
||||
проверить по HTTP даже на стенде отказов, добавить запись в
|
||||
`EXCLUDED` (`spec_coverage.py`) с причиной и способом проверки.
|
||||
Сценарии тестов `fault` сверка считает покрытыми и печатает их число.
|
||||
- Модуль сверки называется `spec_coverage.py`, а не `coverage.py`:
|
||||
каталог набора стоит в `pythonpath`, и `coverage.py` затенил бы
|
||||
пакет `coverage` (pytest-cov, coverage-runner IDE).
|
||||
- Новые пользователи и чаты — фикстуры `alice`, `bob`, `eve`, `chat` из
|
||||
`conftest.py`: у каждого теста свои. `eve` не состоит ни в одном чате
|
||||
фикстур.
|
||||
@@ -0,0 +1,243 @@
|
||||
---
|
||||
name: run-mtusi-messenger
|
||||
description: Запустить, остановить, прогнать и подёргать API мессенджера MTUSI (FastAPI, PostgreSQL, Valkey, лаба 2) — на хосте или в Docker. Use when asked to run / start / stop the server or the container, run the smoke test, `make test`, `make student_test` or `make test_isolated`, check that an API change works on a live server, send a request to an endpoint, reproduce a bug over HTTP, check the container, or call services directly without HTTP.
|
||||
---
|
||||
|
||||
REST API мессенджера (пользователи, чаты, сообщения) — сервер на
|
||||
FastAPI/uvicorn, данные в PostgreSQL из compose, карточки чатов
|
||||
кэшируются в Valkey из compose. Агент управляет им через
|
||||
`.claude/skills/run-mtusi-messenger/driver.py`: он поднимает Postgres,
|
||||
накатывает миграции и поднимает Valkey (`make upgrade start_cache`),
|
||||
запускает свой экземпляр сервера в фоне, гоняет сценарий по HTTP,
|
||||
публичный smoke и собственные тесты, шлёт одиночные запросы и
|
||||
останавливает сервер. Против контейнера
|
||||
(`make run_docker`) работают те же команды драйвера, кроме
|
||||
`start`/`stop`. Только стандартная библиотека Python.
|
||||
|
||||
Все пути — от корня репозитория. Проверено на macOS (arm64), uv 0.12,
|
||||
Python 3.12 из `.python-version`, Docker Desktop 29.8.
|
||||
|
||||
Аутентификация лабы 2: регистрация с `password`, вход
|
||||
`POST /api/v1/auth/sessions` по `Authorization: Basic`, дальше —
|
||||
`Authorization: Bearer <token>`. `X-User-Id` доступа не даёт. Пароль —
|
||||
Argon2id, около 30 мс на регистрацию и вход, поэтому `flow` и
|
||||
`student-tests` идут дольше, чем на лабе 1.
|
||||
|
||||
## Setup
|
||||
|
||||
```bash
|
||||
uv sync --all-extras # venv с ruff и dev-группой (pytest, httpx, валидатор)
|
||||
make env_setup # .env (случайные POSTGRES_PASSWORD и VALKEY_PASSWORD) и config.toml, существующие не трогает
|
||||
```
|
||||
|
||||
Нужен запущенный Docker: Postgres и Valkey живут в compose. Без
|
||||
Postgres сервер стартует, но `/health/ready` отвечает 503; без Valkey
|
||||
всё работает, но мимо кэша (`warning` «Cache is unavailable» в логе).
|
||||
`driver.py start` сам делает `make upgrade start_cache`. В `.env`,
|
||||
созданном до `membership-cache`, нет строк Valkey: их переносят из
|
||||
`.env.example` руками, иначе compose падает с `VALKEY_PASSWORD is
|
||||
empty`.
|
||||
|
||||
## Run (agent path)
|
||||
|
||||
```bash
|
||||
D=.claude/skills/run-mtusi-messenger/driver.py
|
||||
python3 $D all # start → flow → tests/smoke.py → student-tests → stop
|
||||
```
|
||||
|
||||
По шагам, когда между ними нужно что-то сделать (поправить код,
|
||||
посмотреть лог, послать свой запрос):
|
||||
|
||||
```bash
|
||||
python3 $D start # make upgrade start_cache, затем фон; ждёт /health/ready до 30 с
|
||||
python3 $D status # listeners: [pid reloader, pid worker], ready: True
|
||||
python3 $D flow # ~50 проверок: регистрация с паролем, вход, 409, неверный пароль,
|
||||
# 401 с WWW-Authenticate, X-User-Id игнорируется, чат, 5 сообщений,
|
||||
# пагинация limit=2 по курсору, чужой → 404, 400-е, logout
|
||||
python3 $D req POST /api/v1/users --data '{"username":"zoe_demo","display_name":"Зоя","password":"Zoe-password-1"}'
|
||||
python3 $D req POST /api/v1/auth/sessions --basic zoe_demo:Zoe-password-1
|
||||
python3 $D req GET /api/v1/users/me --token <token из ответа выше>
|
||||
python3 $D smoke # публичный tests/smoke.py против этого порта
|
||||
python3 $D student # make student_test BASE_URL=http://localhost:<port> — 103 теста, ~12 с
|
||||
python3 $D stop
|
||||
```
|
||||
|
||||
| команда | что делает |
|
||||
|---|---|
|
||||
| `start` | `make upgrade start_cache`, затем `APP__RUN_MODE=console APP__PORT=<port> uv run python -m src` в своей группе процессов |
|
||||
| `status` | кто слушает порт, отвечает ли `/health/ready`; код 1, если никого |
|
||||
| `flow` | сквозной сценарий; `[FAIL]` в строке и код 1 при провале; в конце печатает id alice/bob/eve/chat и синтетический токен alice |
|
||||
| `req METHOD PATH [--token T \| --basic USER:PASS] [--data JSON]` | один запрос: статус, `x-request-id`, `www-authenticate` у 401, тело; код 2 при статусе ≥ 400 |
|
||||
| `smoke` | `tests/smoke.py --base-url http://localhost:<port>` |
|
||||
| `student` | `make student_test BASE_URL=http://localhost:<port>` (pytest по `student-tests/`); код 1, если каталога нет |
|
||||
| `stop` | SIGTERM всей группе; ждёт, пока порт освободится. Чужой сервер и контейнер не трогает |
|
||||
| `all` | всё подряд (`student` — если есть `student-tests/`), `stop` в `finally` |
|
||||
|
||||
- Порт по умолчанию **18080**, другой — `--port N` **перед** командой:
|
||||
`python3 $D --port 18081 start`.
|
||||
- Лог сервера (JSON, одна строка на запрос) — `/tmp/mtusi-api-<port>.log`,
|
||||
pid группы — `/tmp/mtusi-api-<port>.pid`.
|
||||
- `make test BASE_URL=http://localhost:18080` работает так же, как
|
||||
`driver.py smoke`.
|
||||
|
||||
## Run: контейнер (compose)
|
||||
|
||||
Образ `mtusi-messenger:lab2`, compose-сервисы `postgres`, `valkey`,
|
||||
`migrate` (одноразовые миграции) и `api`. Внешний порт — аргументом
|
||||
make, чтобы не столкнуться с 8080:
|
||||
|
||||
```bash
|
||||
make run_docker APP_OUT_PORT=18090 # build + up -d: postgres, valkey → migrate → api
|
||||
docker compose ps -a --format '{{.Name}} {{.Ports}} {{.Status}}'
|
||||
python3 $D --port 18090 flow # те же проверки против контейнера
|
||||
docker compose logs --no-log-prefix api | tail -5 # JSON-строки, без -f
|
||||
docker compose exec valkey sh -c 'valkey-cli -p "$VALKEY_PORT" --scan --pattern "messenger:*" | head'
|
||||
# ключи кэша; пароль — из VALKEYCLI_AUTH контейнера
|
||||
scripts/restart.sh # рестарт API, Postgres и Valkey: данные и токены остаются, кэш пуст
|
||||
make test-persistence ACTION_SCRIPT=scripts/restart.sh # то же публичной проверкой
|
||||
make down # удалить контейнеры, volume с данными остаётся
|
||||
make wipe_data # удалить и данные: только после ввода yes
|
||||
```
|
||||
|
||||
`make run_docker` сам создаёт недостающие `.env` и `config.toml`
|
||||
(`env_setup`) и монтирует `config.toml` только для чтения. Готовность —
|
||||
`docker inspect -f '{{.State.Health.Status}}' $(docker compose ps -q api)`
|
||||
→ `healthy`.
|
||||
|
||||
## Direct invocation (без HTTP)
|
||||
|
||||
Для правок в `src/core/` сервисы вызываются поверх сессии БД, сервер не
|
||||
нужен, но Postgres с миграциями нужен (`make upgrade`).
|
||||
`APP__LOG_LEVEL=WARNING` убирает JSON-логи сервисов из вывода:
|
||||
|
||||
```bash
|
||||
make upgrade
|
||||
APP__LOG_LEVEL=WARNING uv run python - <<'EOF'
|
||||
import asyncio
|
||||
import uuid
|
||||
from src.core.services import SessionService, UserService
|
||||
from src.infra.db.session import engine, session_factory
|
||||
|
||||
async def main():
|
||||
async with session_factory() as db_session:
|
||||
username = f"alice_{uuid.uuid4().hex[:6]}"
|
||||
await UserService(db_session=db_session).register(
|
||||
username=username,
|
||||
display_name="Alice",
|
||||
password="Alice-password-1",
|
||||
)
|
||||
sessions = SessionService(db_session=db_session)
|
||||
issued = await sessions.login(username=username, password="Alice-password-1")
|
||||
print(await sessions.authenticate(token=issued.token))
|
||||
await engine.dispose()
|
||||
|
||||
asyncio.run(main())
|
||||
EOF
|
||||
```
|
||||
|
||||
`ChatService` и `MessageService` создаются с кэшем вторым параметром:
|
||||
`ChatService(db_session=db_session, cache=cache)`, где `cache` — из
|
||||
`src.infra.cache.instance` (`await cache.aclose()` в конце, нужен
|
||||
`make start_cache`). Все методы keyword-only, commit делает сам сервис. Ошибки — доменные
|
||||
исключения из `src.core.exceptions` (базовый `DomainError`), не
|
||||
HTTP-коды: `authenticate(token="x")` бросает `Unauthenticated`, неверный
|
||||
пароль в `login` — `InvalidCredentials`. Созданное так остаётся в рабочей
|
||||
базе.
|
||||
|
||||
## Run (human path)
|
||||
|
||||
```bash
|
||||
make run_dev # Postgres + миграции, Valkey, затем 127.0.0.1:8080, reload по src/; Ctrl-C
|
||||
```
|
||||
|
||||
Блокирует терминал — агенту не подходит, используй `driver.py start`.
|
||||
|
||||
## Test
|
||||
|
||||
```bash
|
||||
make check # офлайн-структура skeleton
|
||||
make test_isolated # образ на временной базе: smoke + student-tests, уборка
|
||||
make failure_checks # проверки отказов (~45 с) на отдельном стенде <рабочий>-failures
|
||||
make failure_checks FAULT_ARGS='-k valkey' # только часть проверок отказов
|
||||
python3 $D all # живой сервер + flow + smoke + student-tests
|
||||
make lint # ruff; затрагивает и driver.py
|
||||
```
|
||||
|
||||
Ожидаемо: `PASS: offline skeleton structure...`, `FAILED: none` у
|
||||
`flow`, smoke — `PASS: lab2 public API scenario...`, student — все
|
||||
прошли (12 тестов `fault` — `deselected`), `All checks passed!`; `all`,
|
||||
`test_isolated` и `failure_checks` — код 0.
|
||||
|
||||
Проверки отказов (`student-tests/test_failures.py`, маркер `fault`)
|
||||
останавливают и замораживают Postgres и Valkey, поэтому идут только на
|
||||
своём стенде: `make failure_checks` поднимает проект compose
|
||||
`<рабочий>-failures` со своими хранилищами и volume и удаляет его после
|
||||
прогона. Рабочий стенд на 8080 при этом не трогается. `pytest -m fault`
|
||||
напрямую останавливается с кодом 2: нет hook стенда.
|
||||
|
||||
## Gotchas
|
||||
|
||||
- **На 8080 обычно уже работает `make run_dev` пользователя.** Поэтому
|
||||
драйвер по умолчанию на 18080. `driver.py --port 8080 stop` чужой
|
||||
сервер не убьёт (нет pid-файла → `left running`, код 1) — и не надо:
|
||||
это процесс пользователя.
|
||||
- **Экземпляр драйвера пишет в ту же рабочую базу**, что `make run_dev` и
|
||||
`make run_docker`: тестовые пользователи и чаты там остаются. Чистый
|
||||
прогон — `make test_isolated` (временная база `test_<db>`), чистый
|
||||
стенд — `make wipe_data`.
|
||||
- **Правка файла в `src/` перезапускает worker** (`WatchFiles detected
|
||||
changes ... Reloading...`), задевает и `make run_dev` на 8080. Данные
|
||||
и сессии в Postgres остаются, прежние токены работают.
|
||||
- **`lsof` на порт показывает два PID** — reloader и worker делят один
|
||||
сокет. Убивать по `lsof -t | xargs kill` бессмысленно: reloader
|
||||
поднимет worker снова. Драйвер шлёт SIGTERM группе процессов; SIGTERM
|
||||
на обёртку `uv run` тоже гасит всё дерево.
|
||||
- **`uv run` и `uv sync` без `--all-extras` удаляют ruff из `.venv`**
|
||||
(`Would uninstall ruff`): ruff в extra `dev`. `make lint` берёт
|
||||
глобальный ruff, PyCharm — из `.venv`: после `make upgrade` или
|
||||
`driver.py start` при необходимости `uv sync --all-extras`.
|
||||
- **`make lint` форматирует и `.claude/skills/`** — ruff в
|
||||
`pyproject.toml` исключает только `tests` и `scripts`. Драйвер написан
|
||||
под 79 колонок и COM812; при правке проверять
|
||||
`ruff format --check .claude/skills/run-mtusi-messenger/driver.py`.
|
||||
- **`.env` задаёт `APP__PORT=8080`, но драйвер его перекрывает**:
|
||||
`start` передаёт `APP__PORT=<port>` в окружении, а окружение важнее
|
||||
`.env`. `APP_OUT_PORT` приложение не читает — это порт публикации
|
||||
контейнера.
|
||||
- **`driver.py stop` контейнер не останавливает** (`not ours (no pid
|
||||
file)`, код 1) — это правильно, гасить его `make down`. `status` для
|
||||
контейнера показывает один PID — процесс Docker Desktop, а не uvicorn.
|
||||
- **`make logs` висит** (`logs -f`) — агенту нужен
|
||||
`docker compose logs --no-log-prefix api` без `-f`.
|
||||
- **`req` без `--token` на защищённом пути даёт 401 `unauthorized`** с
|
||||
`www-authenticate: Bearer realm="messenger"` — это не сломанный
|
||||
сервер, а контракт: аутентификация раньше доступа. Токен — из ответа
|
||||
`req POST /api/v1/auth/sessions --basic USER:PASS` или последняя строка
|
||||
`flow`.
|
||||
- **Короткий срок сессии для проверки истечения** — окружением
|
||||
`AUTH__SESSION_TTL_SECONDS=2 python3 $D start`: окружение важнее
|
||||
`.env` и `config.toml`.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- **`port 8080 is not ours (no pid file); left running`** — `stop` на
|
||||
порту, который поднимал не драйвер. Свой экземпляр гасить `stop` на его
|
||||
порту; чужой не трогать. Чей он — `lsof -nP -iTCP:8080 -sTCP:LISTEN`,
|
||||
затем `ps -o pid,ppid,etime,command -p <pid>`.
|
||||
- **`make upgrade failed` в `start`** — не запущен Docker или занят порт
|
||||
Postgres `POSTGRES_OUT_PORT` (5433): `docker ps`, `lsof -nP
|
||||
-iTCP:5433 -sTCP:LISTEN`.
|
||||
- **`/health/ready` отвечает 503, `/health/live` — 200** — Postgres
|
||||
недоступен: `docker compose ps postgres`, `make start_db`. Запросы к
|
||||
API в это время получают 503 `unavailable`, после возврата Postgres
|
||||
проходят без рестарта сервера.
|
||||
- **В логе `warning` «Cache is unavailable»** — Valkey остановлен или
|
||||
завис (рестарт Valkey отказом не считается: клиент один раз
|
||||
переоткрывает соединение): `docker compose ps valkey`, `make
|
||||
start_cache`. Ответы при этом те же (из Postgres), `/health/ready` —
|
||||
200; через `[cache] retry_after_seconds` (5 с) после возврата Valkey —
|
||||
`info` «Cache is available again».
|
||||
- **`VALKEY_PASSWORD is empty, copy Valkey lines from .env.example`** у
|
||||
любой команды compose — `.env` создан до `membership-cache`: перенести
|
||||
строки `VALKEY_*` и `CACHE__*` из `.env.example`, пароль — `openssl
|
||||
rand -hex 16`.
|
||||
@@ -0,0 +1,478 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Драйвер API мессенджера для агента: запуск, сценарий, запросы, остановка.
|
||||
|
||||
Только стандартная библиотека. Запускать из корня репозитория:
|
||||
|
||||
python3 .claude/skills/run-mtusi-messenger/driver.py [--port N] <cmd>
|
||||
|
||||
Команды:
|
||||
start `make upgrade start_cache` (Postgres из compose и миграции,
|
||||
Valkey), затем поднять `python -m src` в фоне (console,
|
||||
reload) и дождаться /health/ready; лог и pid —
|
||||
/tmp/mtusi-api-<port>.{log,pid}
|
||||
status кто слушает порт и что отвечает /health/ready
|
||||
flow сквозной сценарий по HTTP с проверками; код выхода 1 при провале
|
||||
req один запрос: req METHOD PATH [--token T | --basic USER:PASS]
|
||||
[--data JSON]
|
||||
smoke публичный tests/smoke.py против этого порта
|
||||
student собственные тесты student-tests/ (make student_test) против
|
||||
этого порта
|
||||
stop остановить свой экземпляр на порту
|
||||
all start → flow → smoke → student (если есть student-tests/) → stop
|
||||
|
||||
Порт по умолчанию 18080, а не 8080: на 8080 обычно висит `make run_dev`
|
||||
пользователя, и его процесс трогать не надо. Экземпляр драйвера пишет в
|
||||
ту же рабочую базу Postgres, что и `make run_dev`. flow, req, smoke и
|
||||
student работают с любым сервером на порту, в том числе с контейнером
|
||||
(`make run_docker APP_OUT_PORT=<port>`).
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import base64
|
||||
import contextlib
|
||||
import json
|
||||
import os
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
import uuid
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[3]
|
||||
DEFAULT_PORT = 18080
|
||||
USERS = "/api/v1/users"
|
||||
CHATS = "/api/v1/chats"
|
||||
SESSIONS = "/api/v1/auth/sessions"
|
||||
BASIC_CHALLENGE = 'Basic realm="messenger", charset="UTF-8"'
|
||||
BEARER_CHALLENGE = 'Bearer realm="messenger"'
|
||||
|
||||
|
||||
def paths(port: int) -> tuple[Path, Path]:
|
||||
return (
|
||||
Path(f"/tmp/mtusi-api-{port}.log"),
|
||||
Path(f"/tmp/mtusi-api-{port}.pid"),
|
||||
)
|
||||
|
||||
|
||||
def base_url(port: int) -> str:
|
||||
return f"http://127.0.0.1:{port}"
|
||||
|
||||
|
||||
def basic(username: str, password: str) -> str:
|
||||
"""Значение `Authorization: Basic` из username и пароля в UTF-8."""
|
||||
raw = f"{username}:{password}".encode()
|
||||
return "Basic " + base64.b64encode(raw).decode("ascii")
|
||||
|
||||
|
||||
def call(
|
||||
port: int,
|
||||
method: str,
|
||||
path: str,
|
||||
*,
|
||||
token: str | None = None,
|
||||
authorization: str | None = None,
|
||||
extra: dict[str, str] | None = None,
|
||||
body: object = None,
|
||||
raw: bytes | None = None,
|
||||
) -> tuple[int, dict[str, str], object]:
|
||||
data = raw
|
||||
headers = {"Accept": "application/json"}
|
||||
if body is not None:
|
||||
data = json.dumps(body).encode()
|
||||
if data is not None:
|
||||
headers["Content-Type"] = "application/json"
|
||||
if token is not None:
|
||||
headers["Authorization"] = f"Bearer {token}"
|
||||
if authorization is not None:
|
||||
headers["Authorization"] = authorization
|
||||
headers.update(extra or {})
|
||||
request = urllib.request.Request(
|
||||
base_url(port) + path,
|
||||
data=data,
|
||||
method=method,
|
||||
headers=headers,
|
||||
)
|
||||
try:
|
||||
with urllib.request.urlopen(request, timeout=5) as response:
|
||||
status = response.status
|
||||
hdrs = dict(response.headers)
|
||||
payload = response.read()
|
||||
except urllib.error.HTTPError as error:
|
||||
status, hdrs, payload = error.code, dict(error.headers), error.read()
|
||||
hdrs = {key.lower(): value for key, value in hdrs.items()}
|
||||
try:
|
||||
parsed = json.loads(payload) if payload else None
|
||||
except json.JSONDecodeError:
|
||||
parsed = payload.decode(errors="replace")
|
||||
return status, hdrs, parsed
|
||||
|
||||
|
||||
def listener_pids(port: int) -> list[int]:
|
||||
out = subprocess.run(
|
||||
["lsof", "-nP", f"-iTCP:{port}", "-sTCP:LISTEN", "-t"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
).stdout
|
||||
return [int(pid) for pid in out.split()]
|
||||
|
||||
|
||||
def is_ready(port: int) -> bool:
|
||||
try:
|
||||
status, _, _ = call(port, "GET", "/health/ready")
|
||||
except OSError:
|
||||
return False
|
||||
return status == 200
|
||||
|
||||
|
||||
def cmd_start(port: int) -> int:
|
||||
log_path, pid_path = paths(port)
|
||||
if listener_pids(port):
|
||||
if is_ready(port):
|
||||
print(f"already up on {base_url(port)}")
|
||||
return 0
|
||||
print(f"port {port} is busy:", listener_pids(port))
|
||||
return 1
|
||||
# без Postgres сервис стартует, но /health/ready отвечает 503; без
|
||||
# Valkey работает, но мимо кэша
|
||||
upgrade = subprocess.run(
|
||||
["make", "upgrade", "start_cache"],
|
||||
cwd=ROOT,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
if upgrade.returncode != 0:
|
||||
print("make upgrade start_cache failed:")
|
||||
print((upgrade.stdout + upgrade.stderr)[-2000:])
|
||||
return 1
|
||||
env = os.environ | {"APP__RUN_MODE": "console", "APP__PORT": str(port)}
|
||||
with log_path.open("wb") as log:
|
||||
proc = subprocess.Popen(
|
||||
["uv", "run", "python", "-m", "src"],
|
||||
cwd=ROOT,
|
||||
env=env,
|
||||
stdout=log,
|
||||
stderr=subprocess.STDOUT,
|
||||
# своя группа процессов: stop гасит uv, reloader и worker разом
|
||||
start_new_session=True,
|
||||
)
|
||||
pid_path.write_text(str(proc.pid))
|
||||
deadline = time.monotonic() + 30
|
||||
while time.monotonic() < deadline:
|
||||
if proc.poll() is not None:
|
||||
print(f"server exited with {proc.returncode}; log: {log_path}")
|
||||
print(log_path.read_text()[-2000:])
|
||||
return 1
|
||||
if is_ready(port):
|
||||
print(f"up on {base_url(port)} pgid={proc.pid} log={log_path}")
|
||||
return 0
|
||||
time.sleep(0.25)
|
||||
print(f"not ready after 30s; log: {log_path}")
|
||||
return 1
|
||||
|
||||
|
||||
def cmd_stop(port: int) -> int:
|
||||
_, pid_path = paths(port)
|
||||
if not pid_path.exists():
|
||||
# экземпляр не наш (например, make run_dev): не трогаем
|
||||
if listener_pids(port):
|
||||
print(f"port {port} is not ours (no pid file); left running")
|
||||
return 1
|
||||
print(f"nothing on {port}")
|
||||
return 0
|
||||
with contextlib.suppress(ProcessLookupError):
|
||||
os.killpg(int(pid_path.read_text()), signal.SIGTERM)
|
||||
pid_path.unlink()
|
||||
deadline = time.monotonic() + 12
|
||||
while listener_pids(port) and time.monotonic() < deadline:
|
||||
time.sleep(0.2)
|
||||
if listener_pids(port):
|
||||
print(f"still listening on {port}:", listener_pids(port))
|
||||
return 1
|
||||
print(f"stopped {port}")
|
||||
return 0
|
||||
|
||||
|
||||
def cmd_status(port: int) -> int:
|
||||
pids = listener_pids(port)
|
||||
print("listeners:", pids or "none")
|
||||
if pids:
|
||||
print("ready:", is_ready(port))
|
||||
return 0 if pids else 1
|
||||
|
||||
|
||||
def cmd_req(port: int, args: argparse.Namespace) -> int:
|
||||
body = json.loads(args.data) if args.data is not None else None
|
||||
authorization = None
|
||||
if args.basic is not None:
|
||||
username, _, password = args.basic.partition(":")
|
||||
authorization = basic(username, password)
|
||||
status, hdrs, payload = call(
|
||||
port,
|
||||
args.method.upper(),
|
||||
args.path,
|
||||
token=args.token,
|
||||
authorization=authorization,
|
||||
body=body,
|
||||
)
|
||||
print(status, "x-request-id:", hdrs.get("x-request-id"))
|
||||
if "www-authenticate" in hdrs:
|
||||
print("www-authenticate:", hdrs["www-authenticate"])
|
||||
print(json.dumps(payload, ensure_ascii=False, indent=2))
|
||||
return 0 if status < 400 else 2
|
||||
|
||||
|
||||
class Flow:
|
||||
def __init__(self, port: int) -> None:
|
||||
self.port = port
|
||||
self.failures = 0
|
||||
|
||||
def check(self, label: str, ok: bool, detail: object = "") -> None:
|
||||
mark = "ok " if ok else "FAIL"
|
||||
print(f"[{mark}] {label}" + (f" {detail}" if detail else ""))
|
||||
if not ok:
|
||||
self.failures += 1
|
||||
|
||||
def expect(
|
||||
self,
|
||||
label: str,
|
||||
method: str,
|
||||
path: str,
|
||||
status: int,
|
||||
challenge: str | None = None,
|
||||
**kwargs: object,
|
||||
) -> object:
|
||||
"""Запрос + проверка статуса, X-Request-Id, формата ошибки и,
|
||||
если задан, `WWW-Authenticate`."""
|
||||
got, hdrs, payload = call(self.port, method, path, **kwargs)
|
||||
request_id = hdrs.get("x-request-id")
|
||||
ok = got == status and bool(request_id)
|
||||
detail = str(got)
|
||||
if got >= 400:
|
||||
error = {}
|
||||
if isinstance(payload, dict):
|
||||
error = payload.get("error", {})
|
||||
ok = ok and error.get("request_id") == request_id
|
||||
detail = f"{got} {error.get('code')}"
|
||||
if challenge is not None:
|
||||
ok = ok and hdrs.get("www-authenticate") == challenge
|
||||
detail += f" {hdrs.get('www-authenticate')}"
|
||||
shown = path if len(path) <= 60 else path[:57] + "..."
|
||||
self.check(f"{method} {shown} -> {status} ({label})", ok, detail)
|
||||
return payload
|
||||
|
||||
|
||||
def cmd_flow(port: int) -> int:
|
||||
flow = Flow(port)
|
||||
tag = uuid.uuid4().hex[:8]
|
||||
flow.expect("live", "GET", "/health/live", 200)
|
||||
flow.expect("ready", "GET", "/health/ready", 200)
|
||||
|
||||
me_path = f"{USERS}/me"
|
||||
ids, tokens, logins = {}, {}, {}
|
||||
for name in ("alice", "bob", "eve"):
|
||||
username, password = f"{name}_{tag}", f"Pw-{name}-{uuid.uuid4().hex}"
|
||||
body = {
|
||||
"username": username,
|
||||
"display_name": f"{name} ✨",
|
||||
"password": password,
|
||||
}
|
||||
user = flow.expect("register", "POST", USERS, 201, body=body)
|
||||
flow.check("no password in User", "password" not in user)
|
||||
session = flow.expect(
|
||||
"login",
|
||||
"POST",
|
||||
SESSIONS,
|
||||
201,
|
||||
authorization=basic(username, password),
|
||||
)
|
||||
ids[name], tokens[name] = user["id"], session["token"]
|
||||
logins[name] = (username, password)
|
||||
alice, bob, eve = tokens["alice"], tokens["bob"], tokens["eve"]
|
||||
dup = {
|
||||
"username": f"alice_{tag}",
|
||||
"display_name": "again",
|
||||
"password": "Another-password-1",
|
||||
}
|
||||
flow.expect("duplicate username", "POST", USERS, 409, body=dup)
|
||||
no_password = {"username": f"nopw_{tag}", "display_name": "x"}
|
||||
flow.expect("no password", "POST", USERS, 400, body=no_password)
|
||||
|
||||
username, password = logins["alice"]
|
||||
wrong = basic(username, "Wrong-password-1")
|
||||
flow.expect(
|
||||
"wrong password",
|
||||
"POST",
|
||||
SESSIONS,
|
||||
401,
|
||||
challenge=BASIC_CHALLENGE,
|
||||
authorization=wrong,
|
||||
)
|
||||
me = flow.expect("me", "GET", me_path, 200, token=alice)
|
||||
flow.check("me.id == alice", me.get("id") == ids["alice"])
|
||||
flow.expect("no token", "GET", me_path, 401, challenge=BEARER_CHALLENGE)
|
||||
flow.expect(
|
||||
"Basic on business endpoint",
|
||||
"GET",
|
||||
me_path,
|
||||
401,
|
||||
challenge=BEARER_CHALLENGE,
|
||||
authorization=basic(username, password),
|
||||
)
|
||||
flow.expect(
|
||||
"only X-User-Id",
|
||||
"GET",
|
||||
me_path,
|
||||
401,
|
||||
challenge=BEARER_CHALLENGE,
|
||||
extra={"X-User-Id": ids["alice"]},
|
||||
)
|
||||
spoofed = flow.expect(
|
||||
"X-User-Id ignored",
|
||||
"GET",
|
||||
me_path,
|
||||
200,
|
||||
token=alice,
|
||||
extra={"X-User-Id": ids["eve"]},
|
||||
)
|
||||
flow.check("still alice", spoofed.get("id") == ids["alice"])
|
||||
flow.expect(
|
||||
"unknown token",
|
||||
"GET",
|
||||
me_path,
|
||||
401,
|
||||
challenge=BEARER_CHALLENGE,
|
||||
token=uuid.uuid4().hex * 2,
|
||||
)
|
||||
|
||||
body = {"title": "Проект 🚀", "member_ids": [ids["alice"], ids["bob"]]}
|
||||
chat = flow.expect("new chat", "POST", CHATS, 201, token=alice, body=body)
|
||||
chat_path = f"{CHATS}/{chat['id']}"
|
||||
msgs = f"{chat_path}/messages"
|
||||
body = {"title": "x", "member_ids": [ids["alice"]]}
|
||||
flow.expect("not a member", "POST", CHATS, 400, token=eve, body=body)
|
||||
|
||||
texts = ["привет", "hi 👋", "третье", "четвёртое", "пятое"]
|
||||
for index, text in enumerate(texts):
|
||||
sender = alice if index % 2 == 0 else bob
|
||||
body = {"text": text}
|
||||
flow.expect("send", "POST", msgs, 201, token=sender, body=body)
|
||||
blank = {"text": " "}
|
||||
flow.expect("blank text", "POST", msgs, 400, token=alice, body=blank)
|
||||
spoof = {"text": "x", "sender_id": ids["alice"]}
|
||||
flow.expect("sender_id", "POST", msgs, 400, token=alice, body=spoof)
|
||||
|
||||
seen, cursor, pages = [], None, 0
|
||||
while pages < 10:
|
||||
query = "?limit=2" + (f"&cursor={cursor}" if cursor else "")
|
||||
page = flow.expect("page", "GET", msgs + query, 200, token=bob)
|
||||
seen += [item["text"] for item in page["items"]]
|
||||
cursor, pages = page["next_cursor"], pages + 1
|
||||
if cursor is None:
|
||||
break
|
||||
flow.check("history order via cursor", seen == texts, f"{pages} pages")
|
||||
flow.check("created_at ends with Z", chat["created_at"].endswith("Z"))
|
||||
|
||||
flow.expect("outsider reads chat", "GET", chat_path, 404, token=eve)
|
||||
flow.expect("outsider reads history", "GET", msgs, 404, token=eve)
|
||||
hi = {"text": "hi"}
|
||||
flow.expect("outsider posts", "POST", msgs, 404, token=eve, body=hi)
|
||||
flow.expect("no token beats 404", "GET", chat_path, 401)
|
||||
flow.expect("limit=0", "GET", msgs + "?limit=0", 400, token=alice)
|
||||
flow.expect("bad cursor", "GET", msgs + "?cursor=zzz", 400, token=alice)
|
||||
flow.expect("chat_id not uuid", "GET", f"{CHATS}/nope", 400, token=alice)
|
||||
flow.expect("malformed json", "POST", USERS, 400, raw=b"{not json")
|
||||
flow.expect("unknown path", "GET", "/nope", 404)
|
||||
chats = flow.expect("list chats", "GET", CHATS, 200, token=bob)
|
||||
listed = [item["id"] for item in chats["items"]]
|
||||
flow.check("bob sees the chat", chat["id"] in listed)
|
||||
|
||||
flow.expect("logout", "DELETE", f"{SESSIONS}/current", 204, token=eve)
|
||||
flow.expect(
|
||||
"token after logout",
|
||||
"GET",
|
||||
me_path,
|
||||
401,
|
||||
challenge=BEARER_CHALLENGE,
|
||||
token=eve,
|
||||
)
|
||||
|
||||
print(
|
||||
f"\nalice={ids['alice']}\nbob={ids['bob']}\neve={ids['eve']}"
|
||||
f"\nchat={chat['id']}"
|
||||
# синтетический токен локального стенда: для `req --token`
|
||||
f"\nalice_token={alice}",
|
||||
)
|
||||
print("FAILED:", flow.failures or "none")
|
||||
return 1 if flow.failures else 0
|
||||
|
||||
|
||||
def cmd_smoke(port: int) -> int:
|
||||
return subprocess.call(
|
||||
[
|
||||
sys.executable,
|
||||
"tests/smoke.py",
|
||||
"--base-url",
|
||||
f"http://localhost:{port}",
|
||||
],
|
||||
cwd=ROOT,
|
||||
)
|
||||
|
||||
|
||||
def cmd_student(port: int) -> int:
|
||||
if not (ROOT / "student-tests").is_dir():
|
||||
print("no student-tests/ in this checkout")
|
||||
return 1
|
||||
return subprocess.call(
|
||||
["make", "student_test", f"BASE_URL=http://localhost:{port}"],
|
||||
cwd=ROOT,
|
||||
)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||
parser.add_argument("--port", type=int, default=DEFAULT_PORT)
|
||||
sub = parser.add_subparsers(dest="cmd", required=True)
|
||||
for name in ("start", "stop", "status", "flow", "smoke", "student", "all"):
|
||||
sub.add_parser(name)
|
||||
req = sub.add_parser("req")
|
||||
req.add_argument("method")
|
||||
req.add_argument("path")
|
||||
auth = req.add_mutually_exclusive_group()
|
||||
auth.add_argument("--token", help="Bearer-токен сессии")
|
||||
auth.add_argument("--basic", help="USER:PASS для POST /auth/sessions")
|
||||
req.add_argument("--data")
|
||||
args = parser.parse_args()
|
||||
port = args.port
|
||||
|
||||
if args.cmd == "all":
|
||||
if cmd_start(port) != 0:
|
||||
return 1
|
||||
try:
|
||||
flow_rc = cmd_flow(port)
|
||||
smoke_rc = cmd_smoke(port)
|
||||
student_rc = 0
|
||||
if (ROOT / "student-tests").is_dir():
|
||||
student_rc = cmd_student(port)
|
||||
finally:
|
||||
cmd_stop(port)
|
||||
return flow_rc or smoke_rc or student_rc
|
||||
if args.cmd == "req":
|
||||
return cmd_req(port, args)
|
||||
handlers = {
|
||||
"start": cmd_start,
|
||||
"stop": cmd_stop,
|
||||
"status": cmd_status,
|
||||
"flow": cmd_flow,
|
||||
"smoke": cmd_smoke,
|
||||
"student": cmd_student,
|
||||
}
|
||||
return handlers[args.cmd](port)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -18,3 +18,26 @@ __pycache__
|
||||
node_modules
|
||||
evidence
|
||||
.DS_Store
|
||||
|
||||
# свои: Dockerfile копирует только pyproject.toml, uv.lock, src/,
|
||||
# alembic.ini и migrations/
|
||||
# паттерн без **/ действует только в корне контекста
|
||||
**/__pycache__
|
||||
**/*.py[cod]
|
||||
**/.DS_Store
|
||||
config.toml
|
||||
.claude
|
||||
openspec
|
||||
graphify-out
|
||||
tests
|
||||
student-tests
|
||||
bench
|
||||
contracts
|
||||
scripts
|
||||
examples
|
||||
infra
|
||||
*.md
|
||||
Makefile
|
||||
.ruff_cache
|
||||
.idea
|
||||
.python-version
|
||||
|
||||
+59
-11
@@ -1,11 +1,59 @@
|
||||
# Copy to .env for your LOCAL synthetic test environment; never commit .env.
|
||||
# These are logical interface suggestions; map actual framework names in REPORT.md.
|
||||
APP_HOST=0.0.0.0
|
||||
APP_PORT=8080
|
||||
APP_ENV=lab
|
||||
SESSION_TTL_SECONDS=3600
|
||||
# Choose credentials locally. File paths contain no secret values.
|
||||
DATABASE_URL_FILE=/run/secrets/database_url
|
||||
# Optional on 3, required use on 4 in lab2; Redis OR Valkey:
|
||||
SESSION_STORE=postgres
|
||||
CACHE_URL_FILE=/run/secrets/cache_url
|
||||
# Шаблон .env: `make env_setup` создаёт из него .env, не перезаписывая
|
||||
# существующий файл, и подставляет случайные POSTGRES_PASSWORD и
|
||||
# VALKEY_PASSWORD. В существующий .env новые строки переносятся руками.
|
||||
# .env не коммитить. .env читают compose, Makefile и приложение
|
||||
# (pydantic-settings); в контейнеры он не попадает.
|
||||
# Параметры приложения — в формате настроек SECTION__FIELD, без секции —
|
||||
# только то, что приложение не читает. Комментарии — только отдельными
|
||||
# строками: make оставляет хвостовой комментарий частью значения.
|
||||
# Соответствие переменным skeleton (APP_HOST, APP_PORT, APP_ENV,
|
||||
# SESSION_TTL_SECONDS, DATABASE_URL_FILE, SESSION_STORE, CACHE_URL_FILE) —
|
||||
# в REPORT.md, «Архитектура и решения».
|
||||
|
||||
# порт сервиса ([app] port): на нём слушает приложение, его же
|
||||
# публикует compose, на нём же healthcheck
|
||||
APP__PORT=8080
|
||||
# порт на 127.0.0.1 хоста, куда публикуется сервис; приложение его
|
||||
# не читает
|
||||
APP_OUT_PORT=8080
|
||||
|
||||
# PostgreSQL. POSTGRES_USER, POSTGRES_PASSWORD и POSTGRES_DB читает и
|
||||
# образ postgres; пароль задаётся только при первом создании volume.
|
||||
# Пустой пароль образ postgres не принимает: make env_setup подставляет
|
||||
# случайный
|
||||
POSTGRES_USER=messenger
|
||||
POSTGRES_PASSWORD=
|
||||
POSTGRES_DB=messenger
|
||||
# адрес и порт Postgres внутри сети compose: по ним ходят API и миграции
|
||||
# в docker, порт слушает сам сервер (PGPORT)
|
||||
POSTGRES_HOST=postgres
|
||||
POSTGRES_PORT=5432
|
||||
# порт на 127.0.0.1 хоста, куда публикуется Postgres: к нему подключается
|
||||
# приложение в console
|
||||
POSTGRES_OUT_PORT=5433
|
||||
# мосты для console: приложение на хосте берёт значения отсюда, в docker
|
||||
# их задаёт environment compose
|
||||
DATABASE__HOST=127.0.0.1
|
||||
DATABASE__PORT=${POSTGRES_OUT_PORT}
|
||||
DATABASE__USER=${POSTGRES_USER}
|
||||
DATABASE__PASSWORD=${POSTGRES_PASSWORD}
|
||||
DATABASE__NAME=${POSTGRES_DB}
|
||||
|
||||
# Valkey — кэш карточек чатов. Пароль читают и сервер (--requirepass), и
|
||||
# приложение; пустой make env_setup заменяет случайным
|
||||
VALKEY_PASSWORD=
|
||||
# адрес и порт Valkey внутри сети compose: по ним ходит API в docker,
|
||||
# порт слушает сам сервер
|
||||
VALKEY_HOST=valkey
|
||||
VALKEY_PORT=6379
|
||||
# порт на 127.0.0.1 хоста, куда публикуется Valkey: к нему подключается
|
||||
# приложение в console
|
||||
VALKEY_OUT_PORT=6380
|
||||
# мосты для console: в docker их задаёт environment compose
|
||||
CACHE__HOST=127.0.0.1
|
||||
CACHE__PORT=${VALKEY_OUT_PORT}
|
||||
CACHE__PASSWORD=${VALKEY_PASSWORD}
|
||||
|
||||
# make test_isolated: порт на 127.0.0.1, куда публикуется тестовый
|
||||
# контейнер API
|
||||
TEST_APP_PORT=18088
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
config.toml
|
||||
secrets/
|
||||
certs/private/
|
||||
*.key
|
||||
@@ -28,5 +29,10 @@ coverage/
|
||||
.DS_Store
|
||||
.idea/
|
||||
.vscode/
|
||||
graphify-out/
|
||||
# make bench_quick: самопроверка стенда, не результат
|
||||
evidence/bench/quick-*/
|
||||
# сравнения пробных меток
|
||||
evidence/compare/*quick-*
|
||||
# Keep small, sanitized evidence summaries in evidence/ under version control.
|
||||
# Inspect git diff --cached: ignore rules are not a secret scanner.
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
# Исключения из графа graphify, синтаксис gitignore, поверх .gitignore
|
||||
# (.env, config.toml, .venv и кэши он уже убирает). В графе остаются
|
||||
# код src/, свои файлы запуска и конфигурации и документы, которые
|
||||
# описывают код: AGENTS.md, .claude/rules/, openspec/specs/, contracts/
|
||||
# README.md и openapi.json. Состав — openspec, capability
|
||||
# code-knowledge-graph. Ведущий / привязывает паттерн к корню: без него
|
||||
# README.md выкинул бы и contracts/README.md.
|
||||
|
||||
# проверки, скрипты и заготовки skeleton
|
||||
/tests/
|
||||
/scripts/
|
||||
/examples/
|
||||
/Dockerfile.example
|
||||
/lab.json
|
||||
/requirements-dev.txt
|
||||
/contracts/examples.json
|
||||
/contracts/infrastructure.json
|
||||
|
||||
# инструментарий агента. settings.local.json git игнорирует через
|
||||
# глобальный excludesfile, а его graphify не читает
|
||||
/.claude/commands/
|
||||
/.claude/skills/
|
||||
/.claude/settings.local.json
|
||||
|
||||
# изменения OpenSpec, текущие и архивные: поведение — в openspec/specs/
|
||||
/openspec/changes/
|
||||
|
||||
# отчёт, доказательства и документы курса
|
||||
/REPORT.md
|
||||
/evidence/
|
||||
/README.md
|
||||
/COURSE.md
|
||||
/CONTRIBUTING.md
|
||||
/MAINTAINERS.md
|
||||
/.github/
|
||||
|
||||
# артефакты самого graphify
|
||||
/graphify-out/
|
||||
@@ -0,0 +1 @@
|
||||
3.12
|
||||
@@ -0,0 +1,413 @@
|
||||
# MTUSI Messenger
|
||||
|
||||
REST API мессенджера (пользователи, чаты, история сообщений). Этот код
|
||||
переносится через все семь лабораторных курса и на каждой обрастает
|
||||
инфраструктурой. Текущая работа — **лаба 2** (`lab.json`): PostgreSQL
|
||||
как источник истины, вход по Basic → Bearer-сессия, на «4» — Redis или
|
||||
Valkey (выбран Valkey — кэш карточек чатов), на «5» — трек 2 (план
|
||||
запроса и восстановление). Код перенесён из лабы 1 (commit `7b775a2`,
|
||||
её правила — `git show 7b775a2:.claude/rules/<файл>`). Переход на lab2
|
||||
завершён changes OpenSpec, они в `openspec/changes/archive/`. Стек:
|
||||
Python 3.12, uv, FastAPI, pydantic v2, pydantic-settings, structlog
|
||||
(JSON в stdout), redis-py (клиент Valkey).
|
||||
|
||||
Репозиторий — fork skeleton преподавателя. Задание, контракт и публичные
|
||||
проверки уже лежат в нём. Реализацию, Dockerfile, compose, собственные
|
||||
тесты и `REPORT.md` пишем мы.
|
||||
|
||||
## Обязательные правила
|
||||
|
||||
- Контракт и skeleton не менять: `contracts/`, `tests/`, `scripts/`
|
||||
(кроме своего `scripts/restart.sh` по образцу `restart.example.sh`),
|
||||
`lab.json`, `README.md`, `COURSE.md`, `CONTRIBUTING.md`,
|
||||
`MAINTAINERS.md`, `.github/`, `compose.example.yaml`,
|
||||
`infra/README.md`, цели `check` / `validate` / `test` / `load` /
|
||||
`test-persistence` в `Makefile`. Если публичный тест упал, чиним
|
||||
приложение, а не тест. Если в контракте противоречие — сказать
|
||||
пользователю (это вопрос преподавателю), не выбирать трактовку самому.
|
||||
Ответ преподавателя записать в «Согласования с преподавателем».
|
||||
- Git не трогать без явной просьбы: никаких commit, push, checkout,
|
||||
reset, stash. Смотреть можно (`git status`, `git diff`, `git log`).
|
||||
Замер или evidence для отчёта снимается с закоммиченного кода, но
|
||||
коммит — только после подтверждения пользователя: показать изменения,
|
||||
предложить сообщение, ждать ок (`.claude/rules/bench.md`, «Измеренное
|
||||
состояние — commit»).
|
||||
- Перед завершением задачи с кодом — `make lint`. Правки API проверять на
|
||||
запущенном сервере (`make run_dev` или контейнер, затем `make test` и
|
||||
`make student_test`), а не «на глаз».
|
||||
- Тесты пишем, но только black-box по HTTP в `student-tests/`
|
||||
(`.claude/rules/student-tests.md`). В bp_proxies тесты были запрещены,
|
||||
здесь они часть рубрики уровня 4.
|
||||
- Упавший тест — сначала разбор, потом правка. Воспроизвести падение,
|
||||
прочитать вывод и назвать причину: дефект приложения, ошибка в самом
|
||||
тесте или стенд (чужой сервис на порту, старый образ, не тот
|
||||
`BASE_URL`). Только после этого что-то менять, а в итоге задачи
|
||||
сказать, в чём была причина.
|
||||
- Если тест упал, чинится код, а не тест. Упавший тест из
|
||||
`student-tests/` правится только в крайнем случае:
|
||||
- поведение меняется намеренно: так записано в дельте спека
|
||||
OpenSpec change или в контракте новой лабы. Тест правится вместе со
|
||||
спеком;
|
||||
- тест ошибочен сам: противоречит спеку или контракту либо зависит от
|
||||
случайного (порядок тестов, время, чужие данные на стенде). В итоге
|
||||
задачи назвать, чему именно он противоречит.
|
||||
|
||||
«Тест красный» — не причина его править. Нельзя ослаблять проверку,
|
||||
подгонять ожидание под фактический ответ, ставить `skip` / `xfail`
|
||||
или удалять тест, чтобы прогон позеленел. Дефект приложения вне
|
||||
текущей задачи записывается в `KNOWN_ISSUES.md` (правило ниже), а
|
||||
тест остаётся как есть. Если причина неясна или правка теста спорная —
|
||||
остановиться и спросить.
|
||||
- Лаба 2: источник истины — PostgreSQL, SQLite его не заменяет.
|
||||
Пользователи, чаты, участники, сообщения и ещё действующие сессии
|
||||
переживают рестарт API и хранилищ без удаления volumes. Basic — только
|
||||
на `POST /auth/sessions`, остальное — Bearer; `X-User-Id` доступа не
|
||||
даёт; пароли — только через password KDF (`auth.md`). Valkey — на
|
||||
«4», кэш карточки чата: источник истины — PostgreSQL, отказ Valkey —
|
||||
обход кэша, а не ошибка (`infra.md`). uvicorn с одним worker:
|
||||
реплики — лаба 3.
|
||||
- `.env`, `config.toml`, секреты, токены и реальные данные не попадают ни
|
||||
в git, ни в образ. В `evidence/` и `REPORT.md` — только обезличенные
|
||||
выводы команд.
|
||||
- Найденный попутно дефект не чинить без просьбы: записать в
|
||||
`KNOWN_ISSUES.md` (завести при первой находке) с путём и предложением
|
||||
правки.
|
||||
- OpenSpec: если команде `/opsx:*` подходит больше одного изменения
|
||||
(change) — несколько активных в `openspec/changes/`, имя совпало
|
||||
частично, из контекста подходят несколько, — не выполнять её для всех
|
||||
подряд и не выбирать самому. Спросить, для какого изменения запустить:
|
||||
варианты — каждое по имени, последним — «все». То же при нескольких
|
||||
подходящих спеках (capability).
|
||||
|
||||
## Согласования с преподавателем
|
||||
|
||||
Договорённости, которых нет в skeleton. Каждую упомянуть в `REPORT.md`
|
||||
и перенести в следующую лабу вместе с этим файлом, если она ещё
|
||||
действует.
|
||||
|
||||
| Дата | Договорённость | Где учтено |
|
||||
|---|---|---|
|
||||
| 2026-09-26 | Лабы можно делать на FastAPI, несмотря на расхождения с контрактом (лишний 422, другой порядок кодов ошибок). Публичный smoke при этом должен проходить | `.claude/rules/api-contract.md`, раздел «FastAPI» |
|
||||
| 2026-09-29 | Конфиг через pydantic-settings: окружение → `.env` → `config.toml` → дефолты. `config.toml` не в git и не в образе, монтируется read-only при запуске. Это подходит под «конфигурация приходит из окружения» (README лабы 1, п. 3) и п. 6 `Dockerfile.example`. Требование «только env» — упрощение курса, `config.toml` можно использовать | `.claude/rules/settings.md`, `.claude/rules/docker.md` |
|
||||
|
||||
## Задание и контракт: важные файлы
|
||||
|
||||
| Файл | Что в нём |
|
||||
|---|---|
|
||||
| `README.md` | задание лабы: рубрика 3/4/5, сценарий и вопросы защиты, что приложить к PR |
|
||||
| `COURSE.md` | карта семи лаб, три объявленных перехода API (1→2, 2→3, 4→5), правила честных измерений |
|
||||
| `contracts/openapi.json` | нормативный OpenAPI 3.1: пути, схемы, коды ответов |
|
||||
| `contracts/README.md` | нормативная семантика: формат ошибок, валидация, пагинация, Basic → Bearer-сессии, TTL и отзыв; разделы lab3+ — на будущее |
|
||||
| `contracts/examples.json`, `infrastructure.json` | примеры тел (проверяет `make validate`); роли инфраструктуры лабы: api, postgres, Redis/Valkey на «4» |
|
||||
| `lab.json` | номер лабы; по нему `tests/client.py` выбирает профиль (с лабы 2 — Basic при входе, дальше Bearer) |
|
||||
| `tests/smoke.py`, `tests/client.py` | публичный сквозной сценарий `make test`; что он проверяет и чего нет — `tests/README.md` |
|
||||
| `tests/resilience.py` | `make test-persistence`: данные и прежний токен после restart hook |
|
||||
| `tests/load.py` | closed-loop нагрузка POST сообщений (`make load`); для трека 5 одного его мало |
|
||||
| `scripts/check_contract.py`, `scripts/validate_openapi.py` | `make check` / `make validate` |
|
||||
| `scripts/restart.example.sh` | образец restart hook; свой — `scripts/restart.sh`: перезапуск API и всех хранилищ без удаления volumes |
|
||||
| `compose.example.yaml` | список ролей с пустым `services`, не стенд; свой стенд — свой compose-файл |
|
||||
| `infra/README.md` | куда класть конфигурации сервисов и что сопоставить в `REPORT.md` |
|
||||
| `REPORT.md` | отчёт: запуск из чистого clone, архитектура, доказательства по каждому критерию, эксперименты, ИИ и источники |
|
||||
| `evidence/` | сохранённые выводы проверок и измерений (что можно класть — `evidence/README.md`) |
|
||||
| `CONTRIBUTING.md` | fork/PR, имя ветки, что переносить в следующую лабу |
|
||||
| `.github/pull_request_template.md` | шаблон PR; CI `workflows/contracts.yml` проверяет только контракт, приложение не запускает |
|
||||
| `Dockerfile.example` | опорные шаги Dockerfile, не рабочий файл |
|
||||
| `.env.example` | шаблон `.env`; «логические» имена skeleton lab2 перечислены в шапке, их соответствие — в `REPORT.md` (`settings.md`) |
|
||||
| `examples/requests.http` | ручные запросы для HTTP-клиента IDE |
|
||||
|
||||
## Где лежат инструкции
|
||||
|
||||
Четыре уровня, не дублировать их друг в друге:
|
||||
|
||||
- **`AGENTS.md`** (этот файл): инварианты, команды, карта кода.
|
||||
`CLAUDE.md` импортирует его.
|
||||
- **`.claude/rules/*.md`**: правила по слоям. Подгружаются автоматически,
|
||||
когда открыт файл из `paths:` во фронтматтере. Проект пишется с нуля,
|
||||
а при создании файла через Write правило само не подгрузится. Поэтому
|
||||
перед созданием первого файла слоя его правило нужно прочитать руками.
|
||||
|
||||
| Файл | Действует на |
|
||||
|---|---|
|
||||
| `api-contract.md` | `src/api/**`, `src/core/**`, `src/schemas/**`, `student-tests/**`: что требует контракт и где FastAPI по умолчанию его нарушает |
|
||||
| `api-layer.md` | `src/api/**`, `src/main.py`: роутеры, зависимости, middlewares, обработчики ошибок |
|
||||
| `service-layer.md` | `src/core/services/**` |
|
||||
| `repo-layer.md` | `src/core/repos/**` |
|
||||
| `dto.md` | `src/schemas/**` |
|
||||
| `infra.md` | `src/infra/**`: логгер, PostgreSQL (engine, пул, таймауты), readiness, кэш Valkey (повтор только на обрыв, срок на команду, обход при отказе) и другие клиенты |
|
||||
| `auth.md` | `src/**/session.py`, сервис пользователей, `dependencies.py`, `errors.py`, идентификация в `student-tests/`: пароль и KDF, разбор Basic, токен, срок и отзыв сессии |
|
||||
| `logging.md` | сервисы, API, инфраструктура, `src/main.py`: где и как логировать, чего в логах быть не должно |
|
||||
| `settings.md` | `src/config/**`, `.env.example`, `config_example.toml`: источники настроек, что куда класть |
|
||||
| `run-modes.md` | точки входа, `Makefile`, compose, шаблоны конфигов: console и docker, uvicorn, SIGTERM |
|
||||
| `docker.md` | `Dockerfile`, `docker-compose.yml`, `.dockerignore`, `scripts/restart.sh`, `infra/**`: мультистейдж, non-root, пины, healthcheck, стенд compose, volumes, restart hook |
|
||||
| `student-tests.md` | `student-tests/**`: обязательные проверки уровня 4, black-box по HTTP, особый стенд |
|
||||
| `bench.md` | `bench/**`: нагрузочный стенд на Postgres (проект compose `mtusi-bench`), что не меняется между метками замеров, граница чёрного ящика и планы запроса, сравнение меток, коммиты измеренных состояний |
|
||||
| `migrations.md` | `migrations/**`, `alembic.ini`, `src/infra/db/models/**`: схема до запросов, ограничения, индексы, повторный запуск миграций |
|
||||
|
||||
- **`openspec/`** (схема `spec-driven`, язык артефактов — русский, см.
|
||||
`openspec/config.yaml`): что система делает и зачем.
|
||||
`specs/<capability>/spec.md` — текущее поведение, `changes/<change>/` —
|
||||
предложения (`proposal.md`, `design.md`, `tasks.md`, дельты спеков),
|
||||
`changes/archive/` — внедрённые. Крупную работу ведут командами
|
||||
`/opsx:propose` → `/opsx:apply` → `/opsx:verify` → `/opsx:archive`
|
||||
(ещё `explore`, `update`, `sync`). Команды в `.claude/commands/opsx/`
|
||||
ставит `openspec update`, руками их не править. Спеки не пересказывают
|
||||
контракт и правила: в `tasks.md` ссылаться на `contracts/` и
|
||||
`.claude/rules/`, а не копировать их.
|
||||
- **Граф кода** (`graphify-out/`, CLI graphify; локальный, не в git и
|
||||
не в образе, состав — `.graphifyignore`): для вопросов о структуре и
|
||||
связях — где используется, кто вызывает, что затронет правка.
|
||||
Команды: `graphify query "<вопрос>"`, `graphify path "A" "B"`,
|
||||
`graphify explain "X"`, `graphify affected "X"`. Граф — подсказка, а
|
||||
не источник правды: до обновления он отстаёт от кода.
|
||||
- Перед правкой — Read файла, как без графа: иначе правило слоя из
|
||||
`.claude/rules/` не подгрузится. Граф этого не заменяет.
|
||||
- Граф строится без LLM: код — по AST, markdown — по структуре
|
||||
(разделы становятся узлами). Раздел правила или спеки связан
|
||||
(`references`, INFERRED) с символами кода, упомянутыми в его тексте
|
||||
в обратных кавычках. Полной карты «правило → код» в графе нет — она
|
||||
в таблице выше и в `paths:` правил.
|
||||
- `query` ищет узлы по подстроке метки. В запрос — имена символов
|
||||
кода (`"ChatService ChatNotFound chat"`), а не пересказ вопроса:
|
||||
тогда в ответе и код, и разделы правил и спек.
|
||||
- В граф не попадают `.json` / `.yaml` / `.yml` (`contracts/openapi.json`,
|
||||
`docker-compose.yml`), `Dockerfile`, `Makefile` и шаблоны конфигов:
|
||||
их CLI не разбирает. По ним — `grep`.
|
||||
- Только CLI `graphify update .`. Не запускать скилл `/graphify` и
|
||||
`graphify extract`: семантический разбор документов через LLM
|
||||
стоит сотни тысяч токенов, а следующий `graphify update .` всё равно
|
||||
заменяет его структурным. Не запускать `graphify install`,
|
||||
`graphify claude install`, `graphify hook install` и `graphify
|
||||
watch`: первые два пишут секцию в `CLAUDE.md` и PreToolUse-хук на
|
||||
Read, остальные пересобирают граф без спроса.
|
||||
|
||||
## Окружение и команды
|
||||
|
||||
- Python 3.12 (`.python-version`), зависимости через uv (`uv sync`,
|
||||
`uv run ...`), lock в `uv.lock`. ruff глобальный
|
||||
(`/opt/homebrew/bin/ruff`, им же пользуется PyCharm), в проекте он в
|
||||
extra `dev`.
|
||||
- Конфиг: `.env` (то, что читают compose и контейнеры зависимостей) +
|
||||
`config.toml` (то, что читает только приложение). Читает их
|
||||
`src/config/settings.py` (pydantic-settings), все поля — в секциях.
|
||||
Приоритет: окружение > `.env` > `config.toml` > дефолты. Параметры
|
||||
приложения в `.env` пишутся в формате настроек (`APP__PORT`), без
|
||||
секции — только то, что приложение не читает (`APP_OUT_PORT`).
|
||||
`config.toml` в образ не копируется, а монтируется на старте. Режим
|
||||
`APP__RUN_MODE` (`console` / `docker`) в `.env` не хранится.
|
||||
Подробно — `settings.md`, `docker.md` и `run-modes.md`.
|
||||
- Точка входа: `python -m src` (`src/__main__.py` → `src/main.py`), порт
|
||||
8080.
|
||||
- `make test` ходит на `http://localhost:8080`. Если там отвечает чужой
|
||||
сервис, smoke упадёт с 404 на `/health/live` вместо ошибки соединения.
|
||||
Проверить, кто занял порт: `lsof -nP -iTCP:8080 -sTCP:LISTEN`,
|
||||
`docker ps`.
|
||||
- graphify (граф кода, «Где лежат инструкции») — вне проекта, в
|
||||
`uv tool`, версия закреплена:
|
||||
- CLI: `uv tool install --python 3.12 'graphifyy==0.9.72'`. Без
|
||||
`--python 3.12` uv берёт free-threaded 3.14t, и установка падает на
|
||||
сборке `tree-sitter-rust`.
|
||||
- Сборка и обновление — одна команда `graphify update .` в корне:
|
||||
без LLM и токенов, около секунды, работает и в чистом clone. Граф
|
||||
обновляется вручную, после заметной работы (новый слой, закрыт
|
||||
change). Попутно `update` кладёт копию прошлого графа в
|
||||
`graphify-out/<дата>/` и называет кластеры по центральному узлу.
|
||||
|
||||
| Команда | Что делает |
|
||||
|---|---|
|
||||
| `make check` | офлайн-проверка структуры skeleton, JSON и синтаксиса Python-проверок |
|
||||
| `make validate PYTHON=.venv/bin/python` | полная валидация OpenAPI и примеров (валидатор стоит в dev-группе uv) |
|
||||
| `make test [BASE_URL=...]` | публичный smoke против запущенного сервера |
|
||||
| `make load` | нагрузка из `tests/load.py`; параметры — `tests/README.md` |
|
||||
| `make test-persistence ACTION_SCRIPT=scripts/restart.sh` | сохранность: создаёт данные и сессию, вызывает restart hook, проверяет те же данные прежним токеном (`tests/README.md`) |
|
||||
| `make run_dev` | `make upgrade` (Postgres из compose и миграции) и `make start_cache`, затем `APP__RUN_MODE=console uv run python -m src`: 127.0.0.1:8080, reload |
|
||||
| `make lint` | `ruff format` + `ruff check --fix`, дважды: так нужно из-за COM812; `tests/` и `scripts/` skeleton исключены в `[tool.ruff]` |
|
||||
| `make env_setup` | `.env.example` → `.env` со случайными `POSTGRES_PASSWORD` и `VALKEY_PASSWORD`, `config_example.toml` → `config.toml`; существующие файлы не перезаписывает (новые строки шаблона переносятся руками) |
|
||||
| `make run_docker` | `make env_setup` (только недостающие файлы) + `docker compose build` + `up -d`: postgres, valkey → migrate → api; `config.toml` и `infra/valkey/valkey.conf` монтируются read-only |
|
||||
| `make stop` / `make down` | остановить / удалить контейнеры compose; volume с данными остаётся |
|
||||
| `make logs` | журнал API, каждая строка — JSON (`--no-log-prefix`) |
|
||||
| `make start_db` / `make stop_db` | Postgres стенда: `up -d --wait postgres` / `stop postgres` |
|
||||
| `make start_cache` / `make stop_cache` | Valkey стенда: `up -d --wait valkey` / `stop valkey`; volume нет, кэш после рестарта пуст |
|
||||
| `make upgrade` | `start_db` + `uv run alembic upgrade head` с хоста (`127.0.0.1:POSTGRES_OUT_PORT`) |
|
||||
| `make revision` | `upgrade` + `alembic revision --autogenerate`, сообщение спрашивает `read -p` |
|
||||
| `make wipe_data` | `down -v` — удалить данные стенда (и кэш); только после ввода `yes` |
|
||||
| `make test_isolated [KEEP_TEST_DB=1]` | образ на временной базе `test_<db>` с Valkey стенда (ключи разделены именем базы): сборка, миграции, отдельный контейнер API на `TEST_APP_PORT`, `make test` + `make student_test`, уборка при любом исходе (`student-tests.md`) |
|
||||
| `make student_test [BASE_URL=...]` | собственные тесты `student-tests/` (pytest) против запущенного сервера, кроме проверок отказов (`-m 'not fault'`); сервер недоступен — код 2 и одна строка с адресом |
|
||||
| `make failure_checks [FAULT_ARGS=...]` | проверки отказов (`pytest -m fault`, ~45 с) на отдельном стенде: проект `<рабочий>-failures` со своими Postgres и Valkey, обычный и «тесный» API (срок 2 с, пул 1), hook `student-tests/fault_hook.py`; стенд и его volume удаляются при любом исходе, рабочий не трогается (`student-tests.md`) |
|
||||
| `make bench [BENCH_LABEL=...]` | полная матрица 10k / 100k / 500k читаемого чата плюс 100 000 сообщений в 1 110 фоновых чатах разного размера (~35 мин, оценка по `bench_quick`) на своём проекте compose `mtusi-bench` (API, Postgres, Valkey с лимитами, без портов хоста и без `.env` рабочего стенда); на каждый размер — свежий стенд, `VACUUM (ANALYZE)`, планы запроса истории (`auto_explain`) по уровням чатов с вариантами индекса и запроса, в конце — пробы стоимости записи по вариантам. Результаты в `evidence/bench/<метка>/`, занятая метка — отказ. Перед запуском — подготовка хоста (`bench.md`) |
|
||||
| `make bench_quick` | самопроверка стенда на 1k / 5k / 10k и 3 500 фоновых сообщений (~3 мин), метка `quick-<время>`, в git не идёт |
|
||||
| `make bench_restore [RESTORE_LABEL=...]` | трек 2, восстановление (~20 мин, метка `restore` по умолчанию): тот же стенд и данные, без матрицы прогонов; на каждый размер — `pg_dump` во время записи через HTTP, активность после backup, `pg_restore -j` в новый контейнер Postgres на новом volume, сверка обеих баз построчно, переключение API, проверки через HTTP до и после `FLUSHALL`; время dump / restore / RTO и потерянные сообщения — в `summary.md` |
|
||||
| `make bench_restore_quick` | то же на 1k / 5k / 10k (~1,5 мин), метка `quick-restore-<время>`, в git не идёт; сценарий защиты трека 2 |
|
||||
| `make bench_ab BEFORE=... AFTER=... REAPPLY=<commit>` | «до» и «после» одного изменения подряд (два прогона `bench`): `bench` для `BEFORE`, commit доказательств, `git revert` commit отката `REAPPLY`, `bench` для `AFTER`. Нужно чистое рабочее дерево; сама делает два коммита |
|
||||
| `make bench_compare BEFORE=... AFTER=... [AA=...]` | дельта двух меток `make bench` по ячейкам матрицы; метки с разной методикой не сравнивает; с `AA` (метка того же кода, что `BEFORE`) отделяет эффект от шума. Результат в `evidence/compare/<до>__<после>.md` |
|
||||
|
||||
Разовая подмена внешнего порта — аргументом make:
|
||||
`make run_docker APP_OUT_PORT=8090`, затем
|
||||
`make test BASE_URL=http://localhost:8090`. Префикс окружения
|
||||
(`APP_OUT_PORT=8090 make ...`) не работает: Makefile подключает `.env`
|
||||
(`run-modes.md`, Troubleshooting).
|
||||
|
||||
## Карта кода
|
||||
|
||||
Файлы домена называются одинаково во всех слоях (`user`, `chat`,
|
||||
`message`, `session` и т.д.).
|
||||
|
||||
```
|
||||
src/
|
||||
__main__.py # python -m src → main.main()
|
||||
main.py # FastAPI app: lifespan, middlewares, обработчики ошибок, uvicorn.run
|
||||
config/settings.py # Settings (pydantic-settings), экземпляр settings
|
||||
api/
|
||||
routers/health.py # /health/live, /health/ready: вне версии, без идентификации
|
||||
routers/v1/<domain>.py # ручки под /api/v1, сборка в routers/v1/__init__.py
|
||||
schemas/<domain>.py # pydantic-модели запросов и ответов = схемы контракта
|
||||
dependencies.py # сессия БД, фабрики сервисов (с кэшем), разбор Basic, текущая сессия по Bearer, пагинация
|
||||
errors.py # доменное исключение → статус + code (+ WWW-Authenticate), формат ошибки контракта
|
||||
middlewares/ # X-Request-Id и access-лог; с лабы 3 — X-Instance-Id
|
||||
core/
|
||||
repos/<domain>.py # атомарный доступ к хранилищу, модульные функции
|
||||
repos/chat_cache.py # карточка чата в Valkey: ключ с именем базы, JSON ↔ ChatFullDTO
|
||||
services/<domain>.py # <Domain>Service: логика, проверки доступа, id и время, логи; чаты и сообщения — с кэшем
|
||||
exceptions/<domain>.py # доменные исключения, реэкспорт в __init__.py
|
||||
infra/
|
||||
logger.py # structlog, get_logger(), contextvar-ы request_id / user_id
|
||||
password.py # Argon2id в потоке со своим лимитом, фиктивный хэш для неизвестного username
|
||||
db/engine.py # фабрики engine и сессий, BoundedCloseConnection, ping
|
||||
db/session.py # глобалы engine и session_factory процесса API
|
||||
db/errors.py # is_db_unavailable: какие ошибки драйвера — 503
|
||||
db/models/ # модели SQLAlchemy (Base с created_at и to_dict)
|
||||
cache/client.py # create_cache (redis-py: повтор только на обрыв, блокирующий пул), Cache: срок на команду, отказ — промах и пропуск
|
||||
cache/instance.py # глобал cache процесса API
|
||||
schemas/
|
||||
dataclasses/<domain>.py # DTO между repo → service → api
|
||||
enums/<domain>.py # StrEnum доменов, RunModeEnum
|
||||
utils/
|
||||
constants.py # лимиты контракта, размер страницы, префиксы путей
|
||||
utc.py # utcnow() (aware UTC), формат RFC 3339 с Z
|
||||
cursor.py # непрозрачный keyset-курсор: кодирование и разбор
|
||||
student-tests/ # black-box тесты по HTTP (уровень 4): make student_test
|
||||
conftest.py # BASE_URL, проверка доступности, фикстуры alice/bob/eve/chat и stand/tight_api, сбор маркеров spec, стоп без hook
|
||||
api_client.py # Api поверх httpx; Actor.headers() — единственное место идентификации
|
||||
contract.py # тела по схемам contracts/openapi.json, форматы id и created_at, assert_error
|
||||
spec_coverage.py # исключения (сценарии, которые не проверить по HTTP) и сверка покрытия
|
||||
test_rubric.py, test_race.py # обязательные сценарии и гонки уровня 4
|
||||
test_<capability>.py # сценарии основных спеков, маркер @pytest.mark.spec
|
||||
test_failures.py # проверки отказов (маркер fault): только make failure_checks
|
||||
run_isolated.py # make test_isolated: образ на временной базе test_<db> (stdlib)
|
||||
run_failures.py # make failure_checks: стенд <рабочий>-failures, два API, pytest -m fault, уборка (stdlib)
|
||||
fault_hook.py # hook стенда отказов: stop/start/pause/unpause, кэш, триггер сбоя участников (stdlib)
|
||||
failures.compose.yml # override стенда отказов: без публикации портов
|
||||
bench/ # нагрузочный стенд на API + Postgres + Valkey: make bench / make bench_quick
|
||||
run.py # оркестратор: стенд compose, фоновые чаты и расписание наполнения, матрица, обслуживание БД, планы и варианты, пробы записи, backup и восстановление во второе хранилище со сверкой, метрики, runs.csv / summary.md / meta.json
|
||||
bench.compose.yml # override стенда mtusi-bench: имена, лимиты BENCH_*, без портов и config.toml, auto_explain
|
||||
bench.env # подстановки compose стенда вместо .env рабочего стенда (без паролей)
|
||||
k6/ # сценарии k6: prepare (вход по Basic, фоновые чаты), prefill (по расписанию), cursors, plan_cursors (страницы плана фоновых чатов), explain, read, tail, write, after_backup и restore_check (этап восстановления); lib.js — Bearer и хелперы
|
||||
compare.py # make bench_compare: дельта двух меток, уровень шума, эффект или шум
|
||||
ab.py # make bench_ab: прогоны «до» и «после» одного изменения подряд
|
||||
migrations/, alembic.ini # ревизии alembic, async env.py; применяет одноразовый сервис compose
|
||||
infra/ # конфигурации сервисов стенда; README.md — skeleton
|
||||
valkey/valkey.conf # лимит памяти и LRU, persistence выключен
|
||||
scripts/restart.sh # restart hook для make test-persistence, по restart.example.sh: api, postgres, valkey
|
||||
Dockerfile # builder (uv sync --locked) → runtime: .venv + src + миграции, UID 10001, healthcheck
|
||||
docker-compose.yml # postgres, valkey, migrate, api; адреса и порты из .env, volume postgres_data
|
||||
.dockerignore
|
||||
config_example.toml, .env.example
|
||||
evidence/storage/ # отказы БД, пул, statement_timeout, рестарт, порты Postgres, свежий clone
|
||||
evidence/migrations/ # миграции с нуля и повторно, ошибка миграции
|
||||
evidence/auth/ # пароли и токены в БД, срок сессии, TTL из конфига
|
||||
evidence/cache/ # попадания в кэш, отказ Valkey, FLUSHALL и рестарт
|
||||
evidence/tests/ # выводы make test_isolated, make student_test и make failure_checks для REPORT.md
|
||||
evidence/bench/<метка>/ # результаты make bench / bench_restore: паспорт, прогоны, наполнение, сводка (планы, стоимость записи, восстановление), планы explain-<размер>.txt, сырые итоги k6
|
||||
evidence/compare/ # таблицы make bench_compare: <до>__<после>.md
|
||||
KNOWN_ISSUES.md # найденные попутно дефекты, не исправленные без просьбы
|
||||
```
|
||||
|
||||
## Архитектура в двух словах
|
||||
|
||||
- Поток однонаправленный. Роутер (зависимости, модели API) → сервис
|
||||
(логика, проверки доступа, id и время, логи) → repo (одна атомарная
|
||||
операция над хранилищем, отдаёт DTO) → PostgreSQL через
|
||||
`AsyncSession` (`src/infra/db/`). Подробности — в правилах слоёв.
|
||||
- Отличия от bp_proxies. Из `core/` вынесены инфраструктура
|
||||
(`src/infra/`: логгер, хранилища, клиенты), утилиты (`src/utils/`),
|
||||
настройки (`src/config/` вместо `src/data/`) и HTTP-модели
|
||||
(`src/api/schemas/` вместо `schemas/pydantic/`). В `core/` остались
|
||||
доменные слои: repos, services, exceptions. Бота, loader и контроллера
|
||||
нет; фоновая работа появится в лабе 5 отдельным worker.
|
||||
- Ошибки: сервис бросает доменное исключение. `src/api/errors.py` одной
|
||||
таблицей переводит его в статус и `code` и отдаёт тело
|
||||
`{"error": {...}}` с `request_id`. `HTTPException` в сервисах и ручках
|
||||
не используется.
|
||||
- Конкурентность: все ручки и зависимости — `async def`, один event
|
||||
loop, один worker. Атомарность и защиту от гонок дают транзакции и
|
||||
ограничения Postgres (уникальность, `ON CONFLICT`), транзакцией
|
||||
управляет сервис. На лабе 1 ту же роль играло отсутствие `await`
|
||||
внутри repo-функции над `MemoryStore`. KDF пароля — в потоке, чтобы
|
||||
не останавливать event loop.
|
||||
- Request id генерирует middleware. Тот же id уходит в заголовок
|
||||
`X-Request-Id`, в `request_id` тела ошибки и в каждую строку лога.
|
||||
|
||||
## Соглашения по коду
|
||||
|
||||
- ruff: 79 символов, py312, набор правил в `pyproject.toml` (isort,
|
||||
bugbear, comprehensions, unused-arguments, pyupgrade, simplify,
|
||||
quotes). Кавычки как в файле (quote-style preserve), trailing comma
|
||||
обязательна.
|
||||
- Типизация везде: `X | None`, `list[...]`, `UUID` и `datetime` вместо
|
||||
строк. Методы сервисов keyword-only (`*,`); repo и сервисы вызываются
|
||||
только именованными аргументами.
|
||||
- Комментарии и докстринги короткие, на русском. Сообщения логов и
|
||||
тексты ошибок API (`error.message`) — на английском.
|
||||
- Константы (лимиты контракта, размер страницы, пути) — в
|
||||
`src/utils/constants.py`, не литералами в коде.
|
||||
- Время только через `utcnow()` из `src/utils/utc.py`: aware UTC. В
|
||||
bp_proxies был naive UTC, здесь контракт требует `...Z`, а с лабы 2 —
|
||||
`timestamptz`.
|
||||
- Коммиты (когда попросят): английский, conventional style
|
||||
(`feat: ...`, `fix: ...`, `refactor: ...`).
|
||||
|
||||
## Дорожная карта лаб
|
||||
|
||||
Каждая лаба — отдельный skeleton-репозиторий; переходы API — `COURSE.md`
|
||||
нового skeleton. Что меняется в коде:
|
||||
|
||||
| Лаба | Что появляется | Где в коде |
|
||||
|---|---|---|
|
||||
| 1 | in-memory API, Dockerfile | `infra/memory.py`, `X-User-Id` в `get_current_user` |
|
||||
| 2 | PostgreSQL, Basic → Bearer-сессия; Valkey на «4» | `infra/db/`, `migrations/`, repo на `AsyncSession`; `password` при регистрации (KDF); `get_current_user` на Bearer; `SESSION_TTL_SECONDS`; кэш карточки чата — `infra/cache/`, `repos/chat_cache.py` |
|
||||
| 3 | балансировщик, ≥2 реплики, идемпотентность | middleware `X-Instance-Id`; `Idempotency-Key` на POST сообщения; никакого состояния в памяти процесса |
|
||||
| 4 | приватный S3, вложения | клиент в `infra/`, домен `attachment` |
|
||||
| 5 | брокер, worker, превью | отдельная точка входа worker; загрузка отвечает 202 |
|
||||
| 6 | OTel Collector, Grafana | телеметрия в `infra/` |
|
||||
| 7 | Argon2id, TLS/mTLS, OpenBao | HTTPS, секреты из OpenBao |
|
||||
|
||||
## Переход в следующую лабу
|
||||
|
||||
По `CONTRIBUTING.md`: fork нового skeleton, ветка
|
||||
`solution/<group>-<surname>`, затем перенести своё.
|
||||
|
||||
- Переносить: `src/`, `student-tests/`, `migrations/`, `Dockerfile`,
|
||||
`docker-compose.yml`, `infra/valkey/` (без `infra/README.md`
|
||||
skeleton), `pyproject.toml`, `uv.lock`, `.python-version`,
|
||||
`config_example.toml`, `AGENTS.md`, `CLAUDE.md`, `.claude/`,
|
||||
`openspec/`, `.graphifyignore`, `bench/`, `KNOWN_ISSUES.md`.
|
||||
- Сливать, а не копировать поверх: `Makefile`, `.env.example`,
|
||||
`.gitignore`, `.dockerignore`. Берём версию нового skeleton (в ней
|
||||
новые цели и проверки) и дописываем свои секции.
|
||||
- Не копировать: `.git`, `.env`, `config.toml`, volumes, `README.md`,
|
||||
`COURSE.md`, `tests/`, `contracts/`, `lab.json`, `REPORT.md`,
|
||||
`evidence/` (доказательства остаются в репозитории своей лабы),
|
||||
`graphify-out/` (граф собирается заново).
|
||||
- Сначала прочитать переходы API в `COURSE.md` и `contracts/README.md`
|
||||
нового skeleton, потом править код. Обновить этот файл: номер лабы,
|
||||
таблицу важных файлов, новые правила.
|
||||
|
||||
## Ветки и PR
|
||||
|
||||
Git — только по просьбе. Когда просят, порядок такой:
|
||||
|
||||
- Работа идёт в ветке `solution/bvt2301-safronov` от ветки skeleton.
|
||||
- PR — в исходный репозиторий преподавателя. Заголовок
|
||||
`ЛР N — Группа — Фамилия — на 3/4/5`, тело — по
|
||||
`.github/pull_request_template.md`. Перед PR выполнить `make check`,
|
||||
`make test` на собранном из чистого clone образе и заполнить
|
||||
`REPORT.md`, включая использование ИИ.
|
||||
@@ -0,0 +1,5 @@
|
||||
@AGENTS.md
|
||||
|
||||
Правила по слоям лежат в `.claude/rules/` и подгружаются сами только при
|
||||
чтении файла из их `paths:`. Проект пишется с нуля: перед созданием
|
||||
первого файла слоя прочитать его правило руками (таблица в AGENTS.md).
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
# Образ API мессенджера (лаба 2): сервер и миграции. Правила —
|
||||
# .claude/rules/docker.md.
|
||||
# Пины: тег + digest индекса (amd64 и arm64). Обновление версии — новый
|
||||
# тег и digest из `docker buildx imagetools inspect <тег>`.
|
||||
|
||||
# builder: зависимости строго по uv.lock в /app/.venv
|
||||
FROM python:3.12.14-slim-trixie@sha256:f77ac9e44ae96ef2c90b8053ea08c31f8be030f824196b0ae4db6d462c84e51f AS builder
|
||||
|
||||
COPY --from=ghcr.io/astral-sh/uv:0.12.17@sha256:10787c682e4184e4f290de1171fd4703dc63de99221f10fe1c99002ce7fa9acc /uv /bin/uv
|
||||
|
||||
ENV UV_COMPILE_BYTECODE=1 \
|
||||
UV_LINK_MODE=copy \
|
||||
UV_PYTHON_DOWNLOADS=never \
|
||||
UV_PROJECT_ENVIRONMENT=/app/.venv
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY pyproject.toml uv.lock ./
|
||||
# --locked: lock не совпадает с pyproject.toml — сборка падает;
|
||||
# --no-install-project: src/ сюда не копируется, запуск из /app
|
||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||
uv sync --locked --no-dev --no-install-project
|
||||
|
||||
|
||||
# runtime: интерпретатор базового образа, .venv и src/, без uv
|
||||
FROM python:3.12.14-slim-trixie@sha256:f77ac9e44ae96ef2c90b8053ea08c31f8be030f824196b0ae4db6d462c84e51f AS runtime
|
||||
|
||||
RUN groupadd --system --gid 10001 app \
|
||||
&& useradd --system --uid 10001 --gid app --no-create-home \
|
||||
--home-dir /nonexistent --shell /usr/sbin/nologin app
|
||||
|
||||
ENV PATH=/app/.venv/bin:$PATH \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
APP__RUN_MODE=docker
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# код и .venv принадлежат root: пользователю app — только чтение
|
||||
COPY --from=builder /app/.venv /app/.venv
|
||||
COPY src ./src
|
||||
# сервис migrate compose запускает этот же образ: alembic upgrade head
|
||||
COPY alembic.ini ./
|
||||
COPY migrations ./migrations
|
||||
|
||||
USER app
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
# порт — тот же APP__PORT, что слушает приложение (по умолчанию 8080)
|
||||
HEALTHCHECK --interval=10s --timeout=3s --start-period=10s \
|
||||
--start-interval=1s --retries=3 \
|
||||
CMD ["python", "-c", "import os, urllib.request; urllib.request.urlopen('http://127.0.0.1:%s/health/ready' % os.environ.get('APP__PORT', '8080'), timeout=2)"]
|
||||
|
||||
# exec-форма: сервер — PID 1 и сам получает SIGTERM
|
||||
CMD ["python", "-m", "src"]
|
||||
@@ -0,0 +1,6 @@
|
||||
# Известные дефекты
|
||||
|
||||
Найдены попутно, не исправлены без отдельной просьбы (AGENTS.md).
|
||||
Исправленные удаляются отсюда, история — в git.
|
||||
|
||||
Открытых дефектов нет.
|
||||
@@ -24,3 +24,205 @@ load:
|
||||
test-persistence:
|
||||
@test -n "$(ACTION_SCRIPT)" || (echo "Set ACTION_SCRIPT to your implemented executable restart hook"; exit 2)
|
||||
$(PYTHON) tests/resilience.py --mode persistence --action-script "$(ACTION_SCRIPT)" --base-url "$(BASE_URL)" $(TLS_ARGS)
|
||||
|
||||
|
||||
# -------------------------
|
||||
# Приложение на хосте (свои цели; цели skeleton выше не менять)
|
||||
# -------------------------
|
||||
|
||||
# Postgres из compose и миграции, Valkey из compose, затем сервис на
|
||||
# хосте: 127.0.0.1:APP__PORT, reload по src/
|
||||
.PHONY: run_dev
|
||||
run_dev: upgrade start_cache
|
||||
APP__RUN_MODE=console uv run python -m src
|
||||
|
||||
# шаблоны копируются только если файла ещё нет: локальные значения
|
||||
# не затираются. В новый .env подставляются случайные пароли Postgres и
|
||||
# Valkey: в шаблоне они пустые, общего пароля стенда в git нет
|
||||
.PHONY: env_setup
|
||||
env_setup:
|
||||
@test -f .env || sed \
|
||||
-e "s/^POSTGRES_PASSWORD=$$/POSTGRES_PASSWORD=$$(openssl rand -hex 16)/" \
|
||||
-e "s/^VALKEY_PASSWORD=$$/VALKEY_PASSWORD=$$(openssl rand -hex 16)/" \
|
||||
.env.example > .env
|
||||
@test -f config.toml || cp config_example.toml config.toml
|
||||
@echo "env ready: .env, config.toml"
|
||||
|
||||
|
||||
# -------------------------
|
||||
# Docker targets
|
||||
# -------------------------
|
||||
|
||||
# порты — из того же .env, что читает compose; без .env — 8080
|
||||
-include .env
|
||||
APP__PORT ?= 8080
|
||||
APP_OUT_PORT ?= 8080
|
||||
DC=docker compose
|
||||
|
||||
# стенд: postgres, valkey -> migrate -> api. env_setup создаёт
|
||||
# недостающие .env и config.toml из шаблонов: без config.toml compose не
|
||||
# запустится (bind с create_host_path: false), без паролей — тоже
|
||||
.PHONY: run_docker
|
||||
run_docker: env_setup
|
||||
DOCKER_BUILDKIT=1 $(DC) build
|
||||
$(DC) up -d
|
||||
|
||||
.PHONY: stop
|
||||
stop:
|
||||
$(DC) stop
|
||||
|
||||
# контейнеры удаляются, volume с данными остаётся (удаление — wipe_data)
|
||||
.PHONY: down
|
||||
down:
|
||||
$(DC) down
|
||||
|
||||
# без префикса "api-1 |": каждая строка — JSON
|
||||
.PHONY: logs
|
||||
logs:
|
||||
$(DC) logs -f --no-log-prefix api
|
||||
|
||||
|
||||
# -------------------------
|
||||
# PostgreSQL и миграции
|
||||
# -------------------------
|
||||
|
||||
# Postgres стенда; --wait ждёт его healthcheck
|
||||
.PHONY: start_db
|
||||
start_db: env_setup
|
||||
$(DC) up -d --wait postgres
|
||||
|
||||
.PHONY: stop_db
|
||||
stop_db:
|
||||
$(DC) stop postgres
|
||||
|
||||
# миграции с хоста: 127.0.0.1:POSTGRES_OUT_PORT из .env
|
||||
.PHONY: upgrade
|
||||
upgrade: start_db
|
||||
uv run alembic upgrade head
|
||||
|
||||
# новая ревизия autogenerate; база сначала доводится до head, иначе
|
||||
# autogenerate сравнит модели не с той схемой
|
||||
.PHONY: revision
|
||||
revision: upgrade
|
||||
@read -p "Сообщение миграции (англ., прошедшее время): " msg; \
|
||||
uv run alembic revision --autogenerate -m "$$msg"
|
||||
|
||||
# удалить контейнеры стенда и volume с данными: только после ввода yes
|
||||
.PHONY: wipe_data
|
||||
wipe_data:
|
||||
@read -p "Удалить все данные стенда (volume Postgres)? Введите yes: " answer; \
|
||||
if [ "$$answer" = "yes" ]; then \
|
||||
$(DC) down -v --remove-orphans; \
|
||||
else \
|
||||
echo "cancelled, nothing removed"; exit 1; \
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------
|
||||
# Valkey (кэш карточек чатов)
|
||||
# -------------------------
|
||||
|
||||
# Valkey стенда; --wait ждёт его healthcheck. Volume нет: кэш после
|
||||
# рестарта пуст, данные — в PostgreSQL
|
||||
.PHONY: start_cache
|
||||
start_cache: env_setup
|
||||
$(DC) up -d --wait valkey
|
||||
|
||||
.PHONY: stop_cache
|
||||
stop_cache:
|
||||
$(DC) stop valkey
|
||||
|
||||
|
||||
# -------------------------
|
||||
# Load benchmark
|
||||
# -------------------------
|
||||
|
||||
BENCH_LABEL ?= baseline
|
||||
# macOS не засыпает на время замера (сон ставит ВМ Docker на паузу посреди
|
||||
# прогона): -u будит из DarkWake полностью, -i и -s не дают уснуть до
|
||||
# конца; на других ОС caffeinate нет, и префикс пустой
|
||||
KEEP_AWAKE := $(shell command -v caffeinate >/dev/null 2>&1 && echo caffeinate -isu)
|
||||
|
||||
# полная матрица на своём проекте compose mtusi-bench (API, PostgreSQL,
|
||||
# Valkey, без портов хоста), с фоновыми чатами разного размера, вариантами
|
||||
# плана и пробами записи, ~35 мин; метка не должна существовать;
|
||||
# результаты и планы запроса истории — evidence/bench/$(BENCH_LABEL)/,
|
||||
# ход — строки в терминале и progress.json
|
||||
.PHONY: bench
|
||||
bench:
|
||||
$(KEEP_AWAKE) uv run python bench/run.py --profile full --label $(BENCH_LABEL)
|
||||
|
||||
# самопроверка стенда на малых размерах, ~3 мин; результат в git не идёт
|
||||
.PHONY: bench_quick
|
||||
bench_quick:
|
||||
$(KEEP_AWAKE) uv run python bench/run.py --profile quick --label quick-$(shell date -u +%Y%m%dT%H%M%SZ)
|
||||
|
||||
RESTORE_LABEL ?= restore
|
||||
|
||||
# трек 2: backup под записью, восстановление в новое хранилище, сверка БД и
|
||||
# через HTTP, кэш до и после FLUSHALL — на 10k / 100k / 500k с фоновыми
|
||||
# чатами, без матрицы прогонов, ~20 мин; результат —
|
||||
# evidence/bench/$(RESTORE_LABEL)/
|
||||
.PHONY: bench_restore
|
||||
bench_restore:
|
||||
$(KEEP_AWAKE) uv run python bench/run.py --profile restore --label $(RESTORE_LABEL)
|
||||
|
||||
# то же на малых размерах (самопроверка, сценарий защиты), ~1,5 мин; в git
|
||||
# не идёт
|
||||
.PHONY: bench_restore_quick
|
||||
bench_restore_quick:
|
||||
$(KEEP_AWAKE) uv run python bench/run.py --profile restore_quick --label quick-restore-$(shell date -u +%Y%m%dT%H%M%SZ)
|
||||
|
||||
# дельта двух меток по ячейкам матрицы: BEFORE и AFTER обязательны, AA —
|
||||
# метка того же кода, что BEFORE, для уровня шума; результат —
|
||||
# evidence/compare/$(BEFORE)__$(AFTER).md
|
||||
.PHONY: bench_compare
|
||||
bench_compare:
|
||||
uv run python bench/compare.py --before "$(BEFORE)" --after "$(AFTER)" --aa "$(AA)"
|
||||
|
||||
# «до» и «после» подряд в одной сессии, два прогона bench: bench для
|
||||
# BEFORE, commit доказательств, git revert commit REAPPLY (возврат
|
||||
# откаченного изменения), затем bench для AFTER. Сам делает два коммита;
|
||||
# рабочее дерево должно быть чистым
|
||||
.PHONY: bench_ab
|
||||
bench_ab:
|
||||
uv run python bench/ab.py --before "$(BEFORE)" --after "$(AFTER)" --reapply "$(REAPPLY)"
|
||||
|
||||
|
||||
# -------------------------
|
||||
# Common targets
|
||||
# -------------------------
|
||||
|
||||
# собственные black-box тесты против запущенного сервера (BASE_URL)
|
||||
.PHONY: student_test
|
||||
student_test:
|
||||
BASE_URL=$(BASE_URL) uv run pytest
|
||||
|
||||
# образ на временной базе test_<POSTGRES_DB>: сборка, миграции, отдельный
|
||||
# контейнер api на 127.0.0.1:TEST_APP_PORT, make test и make student_test,
|
||||
# затем уборка при любом исходе. KEEP_TEST_DB=1 оставляет базу для разбора.
|
||||
# Valkey общий с рабочим стендом: ключи кэша разделены именем базы.
|
||||
# $(PYTHON), а не uv run: uv повторно шлёт SIGINT, и Ctrl+C обрывал уборку
|
||||
.PHONY: test_isolated
|
||||
test_isolated: env_setup start_db start_cache
|
||||
$(PYTHON) student-tests/run_isolated.py $(if $(KEEP_TEST_DB),--keep-db,)
|
||||
|
||||
# проверки отказов (pytest -m fault) на отдельном стенде: свой проект
|
||||
# compose <рабочий>-failures со своими Postgres и Valkey, обычный и
|
||||
# «тесный» API, hook student-tests/fault_hook.py; стенд и его volume
|
||||
# удаляются при любом исходе, рабочий стенд не затрагивается.
|
||||
# FAULT_ARGS — дополнительные аргументы pytest, например -k "Valkey"
|
||||
.PHONY: failure_checks
|
||||
failure_checks: env_setup
|
||||
$(PYTHON) student-tests/run_failures.py $(FAULT_ARGS)
|
||||
|
||||
.PHONY: lint
|
||||
lint:
|
||||
@ruff format .
|
||||
@echo "code formatted"
|
||||
@ruff check --fix .
|
||||
@echo "code checked and fixed if needed"
|
||||
@ruff format .
|
||||
@echo "code formatted"
|
||||
@ruff check --fix .
|
||||
@echo "code checked and fixed if needed"
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
# Миграции alembic, правила — .claude/rules/migrations.md.
|
||||
# URL подключения migrations/env.py берёт из настроек приложения (секция
|
||||
# [database]), поэтому sqlalchemy.url здесь нет. Секций logging тоже нет:
|
||||
# журнал идёт через src/infra/logger.py в JSON, как у сервиса.
|
||||
|
||||
[alembic]
|
||||
script_location = %(here)s/migrations
|
||||
# имя ревизии: YYYY_MM_DD_HHMM-<rev>_<slug>.py
|
||||
file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
|
||||
truncate_slug_length = 40
|
||||
# импорт src из корня репозитория и из /app в образе
|
||||
prepend_sys_path = .
|
||||
path_separator = os
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
"""Два прогона подряд: «до» и «после» одного изменения, в одной сессии.
|
||||
|
||||
Запуск — `make bench_ab BEFORE=<метка> AFTER=<метка> REAPPLY=<commit>`.
|
||||
В рабочем дереве должен лежать код «до», а изменение — быть
|
||||
закоммиченным и откаченным отдельным commit; `REAPPLY` — commit отката.
|
||||
Скрипт снимает стенд «до», коммитит его результаты, возвращает изменение
|
||||
(`git revert` commit отката) и снимает «после». Между прогонами на хосте
|
||||
нет другой работы. Только stdlib. Методика — design change
|
||||
`perf-bottleneck-fix`, решения 7 и 9; без разложения внутри процесса —
|
||||
design change `bench-postgres`, решение 8.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def git(*args: str) -> subprocess.CompletedProcess[str]:
|
||||
return subprocess.run(
|
||||
["git", "-C", str(ROOT), *args],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
|
||||
|
||||
def problems(args: argparse.Namespace) -> list[str]:
|
||||
"""Что мешает начать; пустой список — можно запускать."""
|
||||
found = []
|
||||
for name in (args.before, args.after):
|
||||
if not re.fullmatch(r"[A-Za-z0-9._-]+", name or ""):
|
||||
found.append(f"bad label {name!r}: use [A-Za-z0-9._-]")
|
||||
continue
|
||||
path = ROOT / "evidence" / "bench" / name
|
||||
if path.exists():
|
||||
found.append(f"{path.relative_to(ROOT)} already exists")
|
||||
if args.before == args.after:
|
||||
found.append("BEFORE and AFTER must be different labels")
|
||||
if git("status", "--porcelain").stdout.strip():
|
||||
# иначе стенд запишет в паспорт dirty: true
|
||||
found.append("working tree is not clean: commit or remove changes")
|
||||
if git("cat-file", "-e", f"{args.reapply}^{{commit}}").returncode != 0:
|
||||
found.append(f"commit {args.reapply!r} not found")
|
||||
elif git("merge-base", "--is-ancestor", args.reapply, "HEAD").returncode:
|
||||
found.append(f"commit {args.reapply} is not in the current branch")
|
||||
return found
|
||||
|
||||
|
||||
def steps(args: argparse.Namespace) -> list[list[str]]:
|
||||
return [
|
||||
["make", "bench", f"BENCH_LABEL={args.before}"],
|
||||
["git", "add", f"evidence/bench/{args.before}"],
|
||||
["git", "commit", "-m", f"docs: add {args.before} bench evidence"],
|
||||
["git", "revert", "--no-edit", args.reapply],
|
||||
["make", "bench", f"BENCH_LABEL={args.after}"],
|
||||
]
|
||||
|
||||
|
||||
def main(argv: list[str]) -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||
parser.add_argument("--before", default="")
|
||||
parser.add_argument("--after", default="")
|
||||
parser.add_argument("--reapply", default="")
|
||||
parser.add_argument("--dry-run", action="store_true")
|
||||
args = parser.parse_args(argv)
|
||||
if not (args.before and args.after and args.reapply):
|
||||
print(
|
||||
"usage: make bench_ab BEFORE=<label> AFTER=<label> "
|
||||
"REAPPLY=<revert commit>",
|
||||
flush=True,
|
||||
)
|
||||
return 2
|
||||
found = problems(args)
|
||||
if found:
|
||||
print("bench_ab refused:\n " + "\n ".join(found), flush=True)
|
||||
return 2
|
||||
plan = steps(args)
|
||||
if args.dry_run:
|
||||
print("\n".join(" ".join(step) for step in plan), flush=True)
|
||||
return 0
|
||||
started = time.monotonic()
|
||||
for number, step in enumerate(plan, 1):
|
||||
print(f"\n=== [{number}/{len(plan)}] {' '.join(step)}", flush=True)
|
||||
code = subprocess.run(step, cwd=ROOT, check=False).returncode
|
||||
if code != 0:
|
||||
print(
|
||||
f"\nbench_ab stopped: step {number} exited with {code}; "
|
||||
"later steps were not run",
|
||||
flush=True,
|
||||
)
|
||||
return 1
|
||||
minutes = (time.monotonic() - started) / 60
|
||||
head = git("rev-parse", "--short", "HEAD").stdout.strip()
|
||||
print(
|
||||
f"\nbench_ab done in {minutes:.0f} min: labels {args.before} and "
|
||||
f"{args.after}, HEAD {head}",
|
||||
flush=True,
|
||||
)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
@@ -0,0 +1,53 @@
|
||||
# Override стенда make bench (bench/run.py): тот же docker-compose.yml под
|
||||
# проектом mtusi-bench, со своими volume, сетью и лимитами. Пины, healthcheck
|
||||
# хранилищ, valkey.conf и миграции — из основного файла. Подстановки — из
|
||||
# bench/bench.env, а не из .env рабочего стенда; пароли и BENCH_* передаёт
|
||||
# run.py (поля Profile), без них стенд не поднимается. Решения 1, 2, 5 design
|
||||
# change bench-postgres; что не меняется между метками — .claude/rules/bench.md.
|
||||
services:
|
||||
postgres:
|
||||
container_name: mtusi-bench-postgres
|
||||
# упавший контейнер не поднимается сам: прогон помечается stand_down
|
||||
restart: "no"
|
||||
# auto_explain загружен, но выключен (log_min_duration = -1): run.py
|
||||
# включает его только на этапе плана, между прогонами
|
||||
command: ["postgres", "-c", "shared_preload_libraries=auto_explain"]
|
||||
ports: !reset []
|
||||
cpus: ${BENCH_DB_CPUS:?run make bench}
|
||||
mem_limit: ${BENCH_DB_MEMORY:?run make bench}
|
||||
memswap_limit: ${BENCH_DB_MEMORY:?run make bench}
|
||||
|
||||
valkey:
|
||||
container_name: mtusi-bench-valkey
|
||||
restart: "no"
|
||||
ports: !reset []
|
||||
cpus: ${BENCH_CACHE_CPUS:?run make bench}
|
||||
mem_limit: ${BENCH_CACHE_MEMORY:?run make bench}
|
||||
memswap_limit: ${BENCH_CACHE_MEMORY:?run make bench}
|
||||
|
||||
migrate:
|
||||
image: mtusi-messenger:bench
|
||||
# без config.toml рабочего стенда: настройки — окружение и дефолты
|
||||
volumes: !reset []
|
||||
|
||||
api:
|
||||
container_name: mtusi-bench-api
|
||||
image: mtusi-messenger:bench
|
||||
restart: "no"
|
||||
ports: !reset []
|
||||
volumes: !reset []
|
||||
# проверка раз в несколько секунд — лишний CPU внутри лимита API
|
||||
healthcheck:
|
||||
disable: true
|
||||
environment:
|
||||
# размер 500k с наполнением идёт ~25 мин; на медленном хосте срок
|
||||
# 3600 с по умолчанию мог бы истечь посреди прогона и дать 401
|
||||
AUTH__SESSION_TTL_SECONDS: ${BENCH_SESSION_TTL_SECONDS:?run make bench}
|
||||
cpus: ${BENCH_APP_CPUS:?run make bench}
|
||||
mem_limit: ${BENCH_APP_MEMORY:?run make bench}
|
||||
memswap_limit: ${BENCH_APP_MEMORY:?run make bench}
|
||||
|
||||
networks:
|
||||
default:
|
||||
# k6 подключается к сети стенда по имени (docker run --network)
|
||||
name: mtusi-bench
|
||||
@@ -0,0 +1,11 @@
|
||||
# Подстановки compose для стенда make bench вместо .env рабочего стенда
|
||||
# (docker compose --env-file bench/bench.env). Только несекретные имена и
|
||||
# порты внутри сети стенда: пароли генерирует bench/run.py на каждый
|
||||
# прогон, лимиты и срок сессии приходят из Profile (BENCH_*).
|
||||
POSTGRES_USER=bench
|
||||
POSTGRES_DB=bench
|
||||
POSTGRES_HOST=postgres
|
||||
POSTGRES_PORT=5432
|
||||
VALKEY_HOST=valkey
|
||||
VALKEY_PORT=6379
|
||||
APP__PORT=8080
|
||||
@@ -0,0 +1,455 @@
|
||||
"""Сравнение двух меток стенда: дельта по ячейкам матрицы.
|
||||
|
||||
Запуск — `make bench_compare BEFORE=<метка> AFTER=<метка> [AA=<метка>]`.
|
||||
Читает `runs.csv` и `meta.json` из `evidence/bench/<метка>/`, пишет
|
||||
`evidence/compare/<до>__<после>.md`. Только stdlib, docker и приложение
|
||||
не нужны. Метки с разной методикой не сравниваются (с лабы 2 методика
|
||||
включает и хранилища: design change `bench-postgres`, решение 8). Правило
|
||||
«эффект или шум» — design change `perf-bottleneck-fix`, решение 7.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import csv
|
||||
import json
|
||||
import re
|
||||
import statistics
|
||||
import sys
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
BENCH_DIR = ROOT / "evidence" / "bench"
|
||||
OUT_DIR = ROOT / "evidence" / "compare"
|
||||
SCENARIOS = ("read", "write")
|
||||
# ячейка матрицы: сценарий, размер истории, число клиентов
|
||||
type CellKey = tuple[str, int, int]
|
||||
|
||||
|
||||
class CompareError(Exception):
|
||||
"""Метки нельзя сравнить: сообщение для человека."""
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Label:
|
||||
name: str
|
||||
meta: dict[str, Any]
|
||||
runs: list[dict[str, str]]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Stat:
|
||||
"""Повторы одной ячейки: RPS, CPU на запрос, медианы задержек."""
|
||||
|
||||
rps: list[float]
|
||||
cpu_us: float
|
||||
p50: float
|
||||
p95: float
|
||||
p99: float
|
||||
|
||||
@property
|
||||
def median(self) -> float:
|
||||
return statistics.median(self.rps)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Row:
|
||||
key: CellKey
|
||||
before: Stat
|
||||
after: Stat
|
||||
|
||||
@property
|
||||
def delta(self) -> float:
|
||||
"""Изменение медианы RPS, %."""
|
||||
return (self.after.median / self.before.median - 1) * 100
|
||||
|
||||
@property
|
||||
def overlap(self) -> bool:
|
||||
"""Пересекаются ли разбросы min–max повторов двух меток."""
|
||||
return min(self.before.rps) <= max(self.after.rps) and min(
|
||||
self.after.rps,
|
||||
) <= max(self.before.rps)
|
||||
|
||||
|
||||
def human(n: int) -> str:
|
||||
if n >= 1_000_000 and n % 1_000_000 == 0:
|
||||
return f"{n // 1_000_000}M"
|
||||
if n >= 1000 and n % 1000 == 0:
|
||||
return f"{n // 1000}k"
|
||||
return str(n)
|
||||
|
||||
|
||||
def load(name: str) -> Label:
|
||||
if not re.fullmatch(r"[A-Za-z0-9._-]+", name):
|
||||
raise CompareError(f"bad label {name!r}: use [A-Za-z0-9._-]")
|
||||
directory = BENCH_DIR / name
|
||||
for file in ("meta.json", "runs.csv"):
|
||||
if not (directory / file).is_file():
|
||||
raise CompareError(
|
||||
f"{(directory / file).relative_to(ROOT)} not found",
|
||||
)
|
||||
meta = json.loads((directory / "meta.json").read_text(encoding="utf-8"))
|
||||
with (directory / "runs.csv").open(encoding="utf-8", newline="") as file:
|
||||
runs = list(csv.DictReader(file))
|
||||
return Label(name=name, meta=meta, runs=runs)
|
||||
|
||||
|
||||
def flatten(prefix: str, value: Any, into: dict[str, Any]) -> None:
|
||||
"""Вложенные словари паспорта → плоские ключи `a.b.c`."""
|
||||
if isinstance(value, dict):
|
||||
for key, inner in value.items():
|
||||
flatten(f"{prefix}.{key}", inner, into)
|
||||
else:
|
||||
into[prefix] = value
|
||||
|
||||
|
||||
def methodology(label: Label) -> dict[str, Any]:
|
||||
"""Параметры, которые у сравнимых меток обязаны совпадать.
|
||||
|
||||
Профиль, лимиты всех контейнеров стенда, образ генератора, образы и
|
||||
настройки PostgreSQL и Valkey, окружение приложения (решение 8 design
|
||||
change `bench-postgres`). У Valkey настройки — `maxmemory*` из
|
||||
`valkey.conf`: правку конфигурации образ не покажет.
|
||||
"""
|
||||
meta = label.meta
|
||||
stand = meta.get("stand", {})
|
||||
flat: dict[str, Any] = {}
|
||||
flatten("profile", meta.get("profile", {}), flat)
|
||||
flatten("limits", meta.get("limits", {}), flat)
|
||||
for name, value in (
|
||||
("generator.image", meta.get("generator", {}).get("image")),
|
||||
("stand.postgres.image", stand.get("postgres", {}).get("image")),
|
||||
("stand.valkey.image", stand.get("valkey", {}).get("image")),
|
||||
):
|
||||
if value is not None:
|
||||
flat[name] = value
|
||||
flatten(
|
||||
"stand.postgres.settings",
|
||||
stand.get("postgres", {}).get("settings", {}),
|
||||
flat,
|
||||
)
|
||||
for key, value in stand.get("valkey", {}).items():
|
||||
if key.startswith("maxmemory"):
|
||||
flat[f"stand.valkey.{key}"] = value
|
||||
flatten("stand.app_env", stand.get("app_env", {}), flat)
|
||||
return flat
|
||||
|
||||
|
||||
def check_methodology(first: Label, second: Label) -> list[str]:
|
||||
"""Отказ при различии; возвращает параметры, записанные в одной метке."""
|
||||
a, b = methodology(first), methodology(second)
|
||||
differs = [
|
||||
f"{key}: {first.name} = {a[key]!r}, {second.name} = {b[key]!r}"
|
||||
for key in sorted(a.keys() & b.keys())
|
||||
if a[key] != b[key]
|
||||
]
|
||||
if differs:
|
||||
raise CompareError(
|
||||
f"labels {first.name} and {second.name} were measured with "
|
||||
"different methodology:\n " + "\n ".join(differs),
|
||||
)
|
||||
return [
|
||||
f"`{key}` записан только в `{(first if key in a else second).name}`: "
|
||||
"совпадение не проверено"
|
||||
for key in sorted(a.keys() ^ b.keys())
|
||||
]
|
||||
|
||||
|
||||
def notes(label: Label) -> list[str]:
|
||||
"""Что мешает считать метку чистым замером."""
|
||||
meta = label.meta
|
||||
found = []
|
||||
if meta.get("status") != "complete":
|
||||
found.append(f"статус {meta.get('status')}: {meta.get('reason')}")
|
||||
if meta.get("git", {}).get("dirty"):
|
||||
found.append("незакоммиченные изменения (`dirty: true`)")
|
||||
if meta.get("overrides"):
|
||||
found.append(f"отладочные переопределения {meta['overrides']}")
|
||||
found += [f"хост: {text}" for text in meta.get("host_warnings", [])]
|
||||
if meta.get("other_containers"):
|
||||
found.append(
|
||||
"посторонние контейнеры: " + ", ".join(meta["other_containers"]),
|
||||
)
|
||||
flagged = [
|
||||
run["run"]
|
||||
for run in label.runs
|
||||
if run.get("flags")
|
||||
or run.get("requests_failed", "0") not in ("0", "")
|
||||
or run.get("check_failed", "0") not in ("0", "")
|
||||
]
|
||||
if flagged:
|
||||
found.append("прогоны с пометками или ошибками: " + ", ".join(flagged))
|
||||
return [f"`{label.name}`: {text}" for text in found]
|
||||
|
||||
|
||||
def cells(label: Label) -> dict[CellKey, Stat]:
|
||||
grouped: dict[CellKey, list[dict[str, str]]] = {}
|
||||
for run in label.runs:
|
||||
if not run["rps"] or float(run["rps"]) <= 0:
|
||||
continue
|
||||
key = (run["scenario"], int(run["size"]), int(run["concurrency"]))
|
||||
grouped.setdefault(key, []).append(run)
|
||||
|
||||
def median(rows: list[dict[str, str]], column: str) -> float:
|
||||
return statistics.median(float(row[column]) for row in rows)
|
||||
|
||||
return {
|
||||
key: Stat(
|
||||
rps=[float(row["rps"]) for row in rows],
|
||||
cpu_us=statistics.median(
|
||||
float(row["app_cpu_cores"]) / float(row["rps"]) * 1e6
|
||||
for row in rows
|
||||
),
|
||||
p50=median(rows, "p50_ms"),
|
||||
p95=median(rows, "p95_ms"),
|
||||
p99=median(rows, "p99_ms"),
|
||||
)
|
||||
for key, rows in grouped.items()
|
||||
}
|
||||
|
||||
|
||||
def compare(before: Label, after: Label) -> tuple[list[Row], list[str]]:
|
||||
"""Строки по общим ячейкам и замечания о ячейках одной метки."""
|
||||
first, second = cells(before), cells(after)
|
||||
rows = [
|
||||
Row(key=key, before=first[key], after=second[key])
|
||||
for key in first
|
||||
if key in second
|
||||
]
|
||||
lonely = [
|
||||
f"ячейка {key[0]} {human(key[1])} × {key[2]} есть только в "
|
||||
f"`{(before if key in first else after).name}`"
|
||||
for key in sorted(first.keys() ^ second.keys())
|
||||
]
|
||||
repeats = [
|
||||
f"ячейка {row.key[0]} {human(row.key[1])} × {row.key[2]}: повторов "
|
||||
f"{len(row.before.rps)} и {len(row.after.rps)}"
|
||||
for row in rows
|
||||
if len(row.before.rps) != len(row.after.rps)
|
||||
]
|
||||
return rows, lonely + repeats
|
||||
|
||||
|
||||
def noise_floor(rows: list[Row]) -> dict[str, Row]:
|
||||
"""Ячейка с наибольшим изменением медианы RPS в каждом сценарии."""
|
||||
floor: dict[str, Row] = {}
|
||||
for row in rows:
|
||||
worst = floor.get(row.key[0])
|
||||
if worst is None or abs(row.delta) > abs(worst.delta):
|
||||
floor[row.key[0]] = row
|
||||
return floor
|
||||
|
||||
|
||||
def passport_rows(labels: list[Label]) -> list[str]:
|
||||
def field(title: str, value: Any) -> str:
|
||||
return (
|
||||
f"| {title} | " + " | ".join(value(x.meta) for x in labels) + " |"
|
||||
)
|
||||
|
||||
def host(meta: dict[str, Any]) -> str:
|
||||
start = meta.get("host_state", {}).get("start", {})
|
||||
return f"swap {start.get('swap_used_mib')} МиБ, {start.get('power')}"
|
||||
|
||||
def versions(meta: dict[str, Any]) -> str:
|
||||
found = meta.get("app_image", {}).get("versions", {})
|
||||
return ", ".join(f"{name} {ver}" for name, ver in found.items())
|
||||
|
||||
return [
|
||||
"| | " + " | ".join(f"`{x.name}`" for x in labels) + " |",
|
||||
"|---|" + "---|" * len(labels),
|
||||
field("Commit", lambda m: f"`{m.get('git', {}).get('commit')}`"),
|
||||
field("Начало прогона", lambda m: str(m.get("started_at"))),
|
||||
field("Статус", lambda m: str(m.get("status"))),
|
||||
field("Версии в образе", versions),
|
||||
field("Хост в начале", host),
|
||||
]
|
||||
|
||||
|
||||
def scenario_table(
|
||||
rows: list[Row],
|
||||
floor: dict[str, Row] | None,
|
||||
) -> list[str]:
|
||||
lines = [
|
||||
"| Размер | Клиенты | RPS до | RPS после | Δ RPS | Вывод | "
|
||||
"CPU на запрос, мкс | Δ CPU, мкс | p50, мс | p95, мс | p99, мс |",
|
||||
"|---|---|---|---|---|---|---|---|---|---|---|",
|
||||
]
|
||||
for row in rows:
|
||||
before, after = row.before, row.after
|
||||
if floor is None:
|
||||
verdict = (
|
||||
"разбросы пересекаются"
|
||||
if row.overlap
|
||||
else "разбросы не пересекаются"
|
||||
)
|
||||
elif not row.overlap and abs(row.delta) > abs(floor[row.key[0]].delta):
|
||||
verdict = "эффект"
|
||||
else:
|
||||
verdict = "в пределах шума"
|
||||
lines.append(
|
||||
f"| {human(row.key[1])} | {row.key[2]} | "
|
||||
f"{before.median:.0f} ({min(before.rps):.0f}–"
|
||||
f"{max(before.rps):.0f}) | "
|
||||
f"{after.median:.0f} ({min(after.rps):.0f}–"
|
||||
f"{max(after.rps):.0f}) | "
|
||||
f"{row.delta:+.1f}% | {verdict} | "
|
||||
f"{before.cpu_us:.0f} → {after.cpu_us:.0f} | "
|
||||
f"{after.cpu_us - before.cpu_us:+.0f} | "
|
||||
f"{before.p50:.2f} → {after.p50:.2f} | "
|
||||
f"{before.p95:.2f} → {after.p95:.2f} | "
|
||||
f"{before.p99:.2f} → {after.p99:.2f} |",
|
||||
)
|
||||
deltas = [row.delta for row in rows]
|
||||
lines += [
|
||||
"",
|
||||
f"Δ RPS по ячейкам: от {min(deltas):+.1f}% до {max(deltas):+.1f}%, "
|
||||
f"медиана {statistics.median(deltas):+.1f}%.",
|
||||
]
|
||||
return lines
|
||||
|
||||
|
||||
def memory_table(before: Label, after: Label) -> list[str]:
|
||||
def sizes(label: Label) -> dict[int, dict[str, Any]]:
|
||||
return {item["size"]: item for item in label.meta.get("sizes", [])}
|
||||
|
||||
first, second = sizes(before), sizes(after)
|
||||
lines = [
|
||||
"| Размер | Байт RSS на сообщение до | после | "
|
||||
"RSS после наполнения до, МиБ | после | "
|
||||
"Байт в БД на сообщение до | после |",
|
||||
"|---|---|---|---|---|---|---|",
|
||||
]
|
||||
for size in sorted(first.keys() & second.keys()):
|
||||
a, b = first[size], second[size]
|
||||
lines.append(
|
||||
f"| {human(size)} | {a.get('bytes_per_message')} | "
|
||||
f"{b.get('bytes_per_message')} | {a.get('rss_after_mib')} | "
|
||||
f"{b.get('rss_after_mib')} | {a.get('db_bytes_per_message')} | "
|
||||
f"{b.get('db_bytes_per_message')} |",
|
||||
)
|
||||
return lines
|
||||
|
||||
|
||||
def render(
|
||||
before: Label,
|
||||
after: Label,
|
||||
aa: Label | None,
|
||||
command: str,
|
||||
) -> str:
|
||||
unverified = check_methodology(before, after)
|
||||
rows, remarks = compare(before, after)
|
||||
if not rows:
|
||||
raise CompareError("labels have no common matrix cells")
|
||||
labels = [before, after]
|
||||
floor = None
|
||||
if aa is not None:
|
||||
unverified += check_methodology(aa, before)
|
||||
aa_rows, aa_remarks = compare(aa, before)
|
||||
floor = noise_floor(aa_rows)
|
||||
missing = [s for s in {row.key[0] for row in rows} if s not in floor]
|
||||
if missing:
|
||||
raise CompareError(
|
||||
f"label {aa.name} has no cells for {', '.join(missing)}",
|
||||
)
|
||||
remarks += aa_remarks
|
||||
labels.append(aa)
|
||||
remarks = (
|
||||
unverified + [text for x in labels for text in notes(x)] + remarks
|
||||
)
|
||||
lines = [
|
||||
f"# Сравнение меток: `{before.name}` → `{after.name}`",
|
||||
"",
|
||||
f"- Команда: `{command}`",
|
||||
"- «До» и «после» — медиана повторов ячейки, в скобках min–max. "
|
||||
"Δ RPS — отношение медиан минус единица.",
|
||||
"- CPU на запрос — `app_cpu_cores / rps`, медиана по повторам; "
|
||||
"задержки — медианы по повторам, «до → после».",
|
||||
]
|
||||
if aa is None:
|
||||
lines.append(
|
||||
"- Уровень шума не задан (`AA`): вывод говорит только, "
|
||||
"пересекаются ли разбросы повторов.",
|
||||
)
|
||||
else:
|
||||
lines += [
|
||||
f"- Уровень шума — наибольшее по ячейкам сценария изменение "
|
||||
f"медианы RPS между `{aa.name}` и `{before.name}`. Он имеет "
|
||||
"смысл, только если код приложения в этих метках одинаков; "
|
||||
"это проверяется по git, команда этого не видит.",
|
||||
"- «Эффект» — разбросы повторов не пересекаются и изменение "
|
||||
"медианы больше уровня шума сценария; иначе «в пределах шума».",
|
||||
]
|
||||
lines += [
|
||||
"",
|
||||
"## Метки",
|
||||
"",
|
||||
*passport_rows(labels),
|
||||
"",
|
||||
"## Замечания",
|
||||
"",
|
||||
]
|
||||
lines += [f"- {text}" for text in dict.fromkeys(remarks)] or ["Нет."]
|
||||
if floor is not None and aa is not None:
|
||||
lines += [
|
||||
"",
|
||||
"## Уровень шума",
|
||||
"",
|
||||
f"| Сценарий | Наибольшее изменение RPS, `{aa.name}` → "
|
||||
f"`{before.name}` | Ячейка |",
|
||||
"|---|---|---|",
|
||||
]
|
||||
lines += [
|
||||
f"| {scenario} | {abs(floor[scenario].delta):.1f}% | "
|
||||
f"{human(floor[scenario].key[1])} × {floor[scenario].key[2]} |"
|
||||
for scenario in SCENARIOS
|
||||
if scenario in floor
|
||||
]
|
||||
for scenario in SCENARIOS:
|
||||
selected = [row for row in rows if row.key[0] == scenario]
|
||||
if selected:
|
||||
lines += [
|
||||
"",
|
||||
f"## Сценарий `{scenario}`",
|
||||
"",
|
||||
*scenario_table(selected, floor),
|
||||
]
|
||||
lines += ["", "## Память", "", *memory_table(before, after)]
|
||||
return "\n".join(lines) + "\n"
|
||||
|
||||
|
||||
def main(argv: list[str]) -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||
parser.add_argument("--before", default="")
|
||||
parser.add_argument("--after", default="")
|
||||
parser.add_argument("--aa", default="")
|
||||
args = parser.parse_args(argv)
|
||||
if not args.before or not args.after:
|
||||
print(
|
||||
"both labels are required: "
|
||||
"make bench_compare BEFORE=<label> AFTER=<label> [AA=<label>]",
|
||||
flush=True,
|
||||
)
|
||||
return 2
|
||||
command = f"make bench_compare BEFORE={args.before} AFTER={args.after}"
|
||||
if args.aa:
|
||||
command += f" AA={args.aa}"
|
||||
try:
|
||||
text = render(
|
||||
load(args.before),
|
||||
load(args.after),
|
||||
load(args.aa) if args.aa else None,
|
||||
command,
|
||||
)
|
||||
except CompareError as exc:
|
||||
print(f"compare failed: {exc}", flush=True)
|
||||
return 1
|
||||
out = OUT_DIR / f"{args.before}__{args.after}.md"
|
||||
out.parent.mkdir(parents=True, exist_ok=True)
|
||||
out.write_text(text, encoding="utf-8")
|
||||
print(text, flush=True)
|
||||
print(f"saved to {out.relative_to(ROOT)}", flush=True)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
@@ -0,0 +1,42 @@
|
||||
// Активность после backup (трек 2, восстановление): новый пользователь
|
||||
// с паролем входит по Basic, создаёт чат с читателем и пишет в него одно
|
||||
// сообщение. После восстановления из backup всего этого в базе быть не
|
||||
// должно, а карточка чата остаётся в кэше. Итог — after.json в рабочем
|
||||
// каталоге (токен только там, оркестратор удаляет его в конце прогона).
|
||||
import http from "k6/http";
|
||||
import { fail } from "k6";
|
||||
|
||||
import { API, WORK_DIR, authHeaders, createChat, register } from "./lib.js";
|
||||
|
||||
const fixture = JSON.parse(open(`${WORK_DIR}/fixture.json`));
|
||||
|
||||
export const options = {
|
||||
vus: 1,
|
||||
iterations: 1,
|
||||
setupTimeout: "60s",
|
||||
};
|
||||
|
||||
export function setup() {
|
||||
const stamp = Date.now().toString(36);
|
||||
const late = register(`b${stamp}_late`, "Bench after backup");
|
||||
const chatId = createChat(
|
||||
late.token,
|
||||
"bench after backup",
|
||||
[late.id, fixture.readerId],
|
||||
);
|
||||
const res = http.post(
|
||||
`${API}/chats/${chatId}/messages`,
|
||||
JSON.stringify({ text: "written after backup" }),
|
||||
{ headers: authHeaders(late.token) },
|
||||
);
|
||||
if (res.status !== 201) {
|
||||
fail(`message after backup: ${res.status} ${res.body}`);
|
||||
}
|
||||
return { userId: late.id, token: late.token, chatId };
|
||||
}
|
||||
|
||||
export default function () {}
|
||||
|
||||
export function handleSummary(data) {
|
||||
return { [`${WORK_DIR}/after.json`]: JSON.stringify(data.setup_data) };
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
// Пул курсоров сценария read: проход истории читаемого чата страницами по
|
||||
// WALK_LIMIT и равномерная выборка до POOL_SIZE курсоров. В пул идут
|
||||
// только позиции, после которых есть ещё PAGE_LIMIT сообщений, чтобы
|
||||
// каждая страница read была полной.
|
||||
import http from "k6/http";
|
||||
import { fail } from "k6";
|
||||
|
||||
import { API, PAGE_LIMIT, WORK_DIR, authHeaders } from "./lib.js";
|
||||
|
||||
const fixture = JSON.parse(open(`${WORK_DIR}/fixture.json`));
|
||||
const WALK_LIMIT = Number(__ENV.WALK_LIMIT || 100);
|
||||
const POOL_SIZE = Number(__ENV.POOL_SIZE || 1000);
|
||||
|
||||
export const options = {
|
||||
vus: 1,
|
||||
iterations: 1,
|
||||
setupTimeout: "30m",
|
||||
};
|
||||
|
||||
export function setup() {
|
||||
const url = `${API}/chats/${fixture.readChatId}/messages`;
|
||||
const params = { headers: authHeaders(fixture.tokens[fixture.readerId]) };
|
||||
const positions = [];
|
||||
let cursor = null;
|
||||
let walked = 0;
|
||||
for (;;) {
|
||||
const query = cursor === null
|
||||
? `?limit=${WALK_LIMIT}`
|
||||
: `?limit=${WALK_LIMIT}&cursor=${encodeURIComponent(cursor)}`;
|
||||
const res = http.get(url + query, params);
|
||||
if (res.status !== 200) {
|
||||
fail(`history page after ${walked}: ${res.status} ${res.body}`);
|
||||
}
|
||||
const body = res.json();
|
||||
walked += body.items.length;
|
||||
if (body.next_cursor === null) {
|
||||
break;
|
||||
}
|
||||
positions.push({ after: walked, cursor: body.next_cursor });
|
||||
cursor = body.next_cursor;
|
||||
}
|
||||
const eligible = positions.filter((p) => walked - p.after >= PAGE_LIMIT);
|
||||
const step = Math.max(1, eligible.length / POOL_SIZE);
|
||||
const pool = [];
|
||||
for (let i = 0; i < eligible.length && pool.length < POOL_SIZE; i += step) {
|
||||
pool.push(eligible[Math.floor(i)]);
|
||||
}
|
||||
return {
|
||||
walked,
|
||||
eligible: eligible.length,
|
||||
first_after: pool.length ? pool[0].after : null,
|
||||
last_after: pool.length ? pool[pool.length - 1].after : null,
|
||||
// позиции курсоров пула: сколько сообщений до каждого (для плана)
|
||||
afters: pool.map((p) => p.after),
|
||||
cursors: pool.map((p) => p.cursor),
|
||||
};
|
||||
}
|
||||
|
||||
export default function () {}
|
||||
|
||||
export function handleSummary(data) {
|
||||
return { [`${WORK_DIR}/cursors.json`]: JSON.stringify(data.setup_data) };
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// Этап плана: страницы истории из plan_pages.json подряд, пока в Postgres
|
||||
// стенда включён auto_explain. Для читаемого чата и первого чата каждого
|
||||
// фонового уровня — первая, средняя и последняя полная страница (у
|
||||
// короткого чата — первая). Порядок запросов = порядок планов в журнале:
|
||||
// оркестратор сопоставляет их по нему.
|
||||
import http from "k6/http";
|
||||
import { check, fail } from "k6";
|
||||
|
||||
import { API, PAGE_LIMIT, WORK_DIR, authHeaders } from "./lib.js";
|
||||
|
||||
const fixture = JSON.parse(open(`${WORK_DIR}/fixture.json`));
|
||||
const pages = JSON.parse(open(`${WORK_DIR}/plan_pages.json`));
|
||||
|
||||
export const options = {
|
||||
vus: 1,
|
||||
iterations: 1,
|
||||
};
|
||||
|
||||
export default function () {
|
||||
const params = { headers: authHeaders(fixture.tokens[fixture.readerId]) };
|
||||
for (const page of pages) {
|
||||
const name = `${page.chat} ${page.page}`;
|
||||
const query = page.cursor === null
|
||||
? `?limit=${PAGE_LIMIT}`
|
||||
: `?limit=${PAGE_LIMIT}&cursor=${encodeURIComponent(page.cursor)}`;
|
||||
const res = http.get(`${API}/chats/${page.chat_id}/messages${query}`, params);
|
||||
const ok = check(res, {
|
||||
[`${name} 200`]: (r) => r.status === 200,
|
||||
[`${name} ${page.items} items`]: (r) =>
|
||||
r.status === 200 && r.json("items.#") === page.items,
|
||||
});
|
||||
if (!ok) {
|
||||
fail(`explain page ${name}: ${res.status}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// итог не нужен: планы оркестратор берёт из журнала Postgres
|
||||
export function handleSummary() {
|
||||
return {};
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
// Общие хелперы сценариев стенда: адрес, идентификация, текст, генератор
|
||||
// случайных чисел, запись итога. Не Node.js: только встроенные модули k6.
|
||||
import encoding from "k6/encoding";
|
||||
import http from "k6/http";
|
||||
import { check, fail } from "k6";
|
||||
|
||||
export const BASE_URL = __ENV.BASE_URL || "http://mtusi-bench-api:8080";
|
||||
export const API = `${BASE_URL}/api/v1`;
|
||||
// каталог метки (сырые итоги) и рабочий каталог (фикстура, курсоры)
|
||||
export const OUT_DIR = __ENV.OUT_DIR || "/out";
|
||||
export const WORK_DIR = __ENV.WORK_DIR || "/work";
|
||||
|
||||
export const TEXT_LENGTH = Number(__ENV.TEXT_LENGTH || 64);
|
||||
export const PAGE_LIMIT = Number(__ENV.PAGE_LIMIT || 50);
|
||||
|
||||
// перцентили в итоге; подметрика expected_response:true — только успехи
|
||||
export const SUMMARY_TREND_STATS = [
|
||||
"avg", "min", "med", "p(50)", "p(95)", "p(99)", "max",
|
||||
];
|
||||
export const SUCCESS_DURATION = "http_req_duration{expected_response:true}";
|
||||
// порог всегда выполняется: он нужен, чтобы подметрика попала в итог
|
||||
export const SUMMARY_THRESHOLDS = { [SUCCESS_DURATION]: ["max>=0"] };
|
||||
|
||||
// идентификация, как Actor.headers() в student-tests: Bearer-токен сессии
|
||||
export function authHeaders(token) {
|
||||
return {
|
||||
Authorization: `Bearer ${token}`,
|
||||
"Content-Type": "application/json",
|
||||
};
|
||||
}
|
||||
|
||||
// синтетический пароль из двух UUID v4 WebCrypto (73 символа, контракт —
|
||||
// 12–128): только в памяти prepare.js, в фикстуру и результаты не попадает
|
||||
function syntheticPassword() {
|
||||
return `${crypto.randomUUID()}-${crypto.randomUUID()}`;
|
||||
}
|
||||
|
||||
// синтетический текст ровно TEXT_LENGTH ASCII-символов
|
||||
export function syntheticText(tag, n) {
|
||||
const prefix = `${tag}-${n}-`;
|
||||
return prefix + "x".repeat(Math.max(0, TEXT_LENGTH - prefix.length));
|
||||
}
|
||||
|
||||
// mulberry32: воспроизводимая последовательность из 32-битного зерна
|
||||
export function mulberry32(seed) {
|
||||
let a = seed >>> 0;
|
||||
return function () {
|
||||
a = (a + 0x6d2b79f5) >>> 0;
|
||||
let t = a;
|
||||
t = Math.imul(t ^ (t >>> 15), t | 1);
|
||||
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
||||
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
||||
};
|
||||
}
|
||||
|
||||
// регистрация с паролем и вход по Basic: { id, token } пользователя
|
||||
export function register(username, displayName) {
|
||||
const password = syntheticPassword();
|
||||
const res = http.post(
|
||||
`${API}/users`,
|
||||
JSON.stringify({ username, display_name: displayName, password }),
|
||||
{ headers: { "Content-Type": "application/json" } },
|
||||
);
|
||||
if (!check(res, { "register 201": (r) => r.status === 201 })) {
|
||||
fail(`register ${username}: ${res.status} ${res.body}`);
|
||||
}
|
||||
const basic = encoding.b64encode(`${username}:${password}`);
|
||||
const login = http.post(`${API}/auth/sessions`, null, {
|
||||
headers: { Authorization: `Basic ${basic}` },
|
||||
});
|
||||
if (!check(login, { "login 201": (r) => r.status === 201 })) {
|
||||
fail(`login ${username}: ${login.status} ${login.body}`);
|
||||
}
|
||||
return { id: res.json("id"), token: login.json("token") };
|
||||
}
|
||||
|
||||
export function createChat(ownerToken, title, memberIds) {
|
||||
const res = http.post(
|
||||
`${API}/chats`,
|
||||
JSON.stringify({ title, member_ids: memberIds }),
|
||||
{ headers: authHeaders(ownerToken) },
|
||||
);
|
||||
if (!check(res, { "chat 201": (r) => r.status === 201 })) {
|
||||
fail(`create chat ${title}: ${res.status} ${res.body}`);
|
||||
}
|
||||
return res.json("id");
|
||||
}
|
||||
|
||||
export function sendMessage(chatId, senderToken, text) {
|
||||
const res = http.post(
|
||||
`${API}/chats/${chatId}/messages`,
|
||||
JSON.stringify({ text }),
|
||||
{
|
||||
headers: authHeaders(senderToken),
|
||||
responseCallback: http.expectedStatuses(201),
|
||||
},
|
||||
);
|
||||
check(res, { "message 201": (r) => r.status === 201 });
|
||||
return res;
|
||||
}
|
||||
|
||||
// итог прогона: в файл NAME.json каталога метки; без NAME — в рабочий
|
||||
// каталог (прогрев), чтобы оркестратор посчитал подтверждённые записи
|
||||
export function summaryFiles(data) {
|
||||
const name = __ENV.NAME;
|
||||
const path = name ? `${OUT_DIR}/raw/${name}.json` : `${WORK_DIR}/last.json`;
|
||||
return { [path]: JSON.stringify(data) };
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// Курсоры страниц плана фоновых чатов (трек 2): проход истории каждого чата
|
||||
// из plan_chats.json страницами по WALK_LIMIT, позиция и курсор после каждой
|
||||
// страницы. Идёт до включения auto_explain, поэтому в журнал не попадает;
|
||||
// заодно прогревает страницы этих чатов, как cursors.js — читаемого.
|
||||
import http from "k6/http";
|
||||
import { fail } from "k6";
|
||||
|
||||
import { API, WORK_DIR, authHeaders } from "./lib.js";
|
||||
|
||||
const fixture = JSON.parse(open(`${WORK_DIR}/fixture.json`));
|
||||
const chats = JSON.parse(open(`${WORK_DIR}/plan_chats.json`));
|
||||
const WALK_LIMIT = Number(__ENV.WALK_LIMIT || 100);
|
||||
|
||||
export const options = {
|
||||
vus: 1,
|
||||
iterations: 1,
|
||||
setupTimeout: "10m",
|
||||
};
|
||||
|
||||
export function setup() {
|
||||
const params = { headers: authHeaders(fixture.tokens[fixture.readerId]) };
|
||||
return chats.map((chat) => {
|
||||
const url = `${API}/chats/${chat.id}/messages`;
|
||||
const positions = [];
|
||||
let cursor = null;
|
||||
let walked = 0;
|
||||
for (;;) {
|
||||
const query = cursor === null
|
||||
? `?limit=${WALK_LIMIT}`
|
||||
: `?limit=${WALK_LIMIT}&cursor=${encodeURIComponent(cursor)}`;
|
||||
const res = http.get(url + query, params);
|
||||
if (res.status !== 200) {
|
||||
fail(`chat ${chat.id} after ${walked}: ${res.status} ${res.body}`);
|
||||
}
|
||||
const body = res.json();
|
||||
walked += body.items.length;
|
||||
if (body.next_cursor === null) {
|
||||
break;
|
||||
}
|
||||
positions.push({ after: walked, cursor: body.next_cursor });
|
||||
cursor = body.next_cursor;
|
||||
}
|
||||
return { id: chat.id, walked, positions };
|
||||
});
|
||||
}
|
||||
|
||||
export default function () {}
|
||||
|
||||
export function handleSummary(data) {
|
||||
return { [`${WORK_DIR}/plan_walks.json`]: JSON.stringify(data.setup_data) };
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// Одна порция наполнения: COUNT сообщений от участников по кругу. Чат
|
||||
// сообщения n берётся из расписания оркестратора (schedule.json: 0 —
|
||||
// читаемый чат, дальше фоновые в порядке фикстуры), так что сообщения всех
|
||||
// чатов идут вперемешку. OFFSET — сколько сообщений уже отправлено.
|
||||
import exec from "k6/execution";
|
||||
import { SharedArray } from "k6/data";
|
||||
|
||||
import {
|
||||
SUMMARY_THRESHOLDS,
|
||||
SUMMARY_TREND_STATS,
|
||||
WORK_DIR,
|
||||
sendMessage,
|
||||
summaryFiles,
|
||||
syntheticText,
|
||||
} from "./lib.js";
|
||||
|
||||
const fixture = JSON.parse(open(`${WORK_DIR}/fixture.json`));
|
||||
const schedule = new SharedArray(
|
||||
"schedule",
|
||||
() => JSON.parse(open(`${WORK_DIR}/schedule.json`)),
|
||||
);
|
||||
const chats = [fixture.readChatId, ...fixture.bgChats.map((c) => c.id)];
|
||||
const OFFSET = Number(__ENV.OFFSET || 0);
|
||||
|
||||
export const options = {
|
||||
scenarios: {
|
||||
prefill: {
|
||||
executor: "shared-iterations",
|
||||
vus: Number(__ENV.VUS || 32),
|
||||
iterations: Number(__ENV.COUNT),
|
||||
maxDuration: "30m",
|
||||
},
|
||||
},
|
||||
discardResponseBodies: true,
|
||||
summaryTrendStats: SUMMARY_TREND_STATS,
|
||||
thresholds: SUMMARY_THRESHOLDS,
|
||||
};
|
||||
|
||||
export default function () {
|
||||
const n = OFFSET + exec.scenario.iterationInTest;
|
||||
const sender = fixture.memberIds[n % fixture.memberIds.length];
|
||||
sendMessage(
|
||||
chats[schedule[n]],
|
||||
fixture.tokens[sender],
|
||||
syntheticText("p", n),
|
||||
);
|
||||
}
|
||||
|
||||
export function handleSummary(data) {
|
||||
return summaryFiles(data);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
// Пользователи и чаты стенда: читаемый (сценарий read), чат записи
|
||||
// (сценарий write) и фоновые чаты неравномерных размеров (трек 2). Каждый
|
||||
// пользователь регистрируется с паролем и входит по Basic; в фикстуру идут
|
||||
// id и Bearer-токены, пароли — нет. Итог — fixture.json в рабочем каталоге:
|
||||
// оркестратор удаляет его в конце прогона.
|
||||
import { WORK_DIR, createChat, register } from "./lib.js";
|
||||
|
||||
const MEMBERS = Number(__ENV.MEMBERS || 10);
|
||||
// уровни фоновых чатов: «10x5000,100x400» — число чатов x сообщений в чате
|
||||
const BACKGROUND = (__ENV.BACKGROUND || "")
|
||||
.split(",")
|
||||
.filter((tier) => tier !== "")
|
||||
.map((tier) => tier.split("x").map(Number));
|
||||
|
||||
export const options = {
|
||||
vus: 1,
|
||||
iterations: 1,
|
||||
setupTimeout: "5m",
|
||||
};
|
||||
|
||||
export function setup() {
|
||||
// размер начинается с пустой базы, поэтому имени хватает времени
|
||||
const stamp = Date.now().toString(36);
|
||||
const tokens = {};
|
||||
const reader = register(`b${stamp}_reader`, "Bench reader");
|
||||
tokens[reader.id] = reader.token;
|
||||
const memberIds = [];
|
||||
for (let i = 0; i < MEMBERS; i++) {
|
||||
const member = register(`b${stamp}_m${i}`, `Bench member ${i}`);
|
||||
tokens[member.id] = member.token;
|
||||
memberIds.push(member.id);
|
||||
}
|
||||
const everyone = [reader.id, ...memberIds];
|
||||
// фоновые чаты в порядке уровней: номер чата в расписании наполнения —
|
||||
// 1 + индекс в этом списке (0 — читаемый чат)
|
||||
const bgChats = [];
|
||||
for (const [count, size] of BACKGROUND) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
const title = `bench bg ${size} #${i}`;
|
||||
bgChats.push({ id: createChat(reader.token, title, everyone), size });
|
||||
}
|
||||
}
|
||||
return {
|
||||
readerId: reader.id,
|
||||
memberIds,
|
||||
tokens,
|
||||
readChatId: createChat(reader.token, "bench read", everyone),
|
||||
writeChatId: createChat(reader.token, "bench write", everyone),
|
||||
bgChats,
|
||||
};
|
||||
}
|
||||
|
||||
export default function () {}
|
||||
|
||||
export function handleSummary(data) {
|
||||
return { [`${WORK_DIR}/fixture.json`]: JSON.stringify(data.setup_data) };
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// Сценарий read: страница истории читаемого чата с курсором, случайно
|
||||
// выбранным из пула. У каждого VU свой генератор с зерном SEED + номер VU:
|
||||
// последовательность одинакова в разных метках и различна у клиентов.
|
||||
import exec from "k6/execution";
|
||||
import http from "k6/http";
|
||||
import { check } from "k6";
|
||||
import { SharedArray } from "k6/data";
|
||||
|
||||
import {
|
||||
API,
|
||||
PAGE_LIMIT,
|
||||
SUMMARY_THRESHOLDS,
|
||||
SUMMARY_TREND_STATS,
|
||||
WORK_DIR,
|
||||
authHeaders,
|
||||
mulberry32,
|
||||
summaryFiles,
|
||||
} from "./lib.js";
|
||||
|
||||
const fixture = JSON.parse(open(`${WORK_DIR}/fixture.json`));
|
||||
const cursors = new SharedArray(
|
||||
"cursors",
|
||||
() => JSON.parse(open(`${WORK_DIR}/cursors.json`)).cursors,
|
||||
);
|
||||
const SEED = Number(__ENV.SEED || 0);
|
||||
// отладка стенда: напечатать первые TRACE выборов каждого VU
|
||||
const TRACE = Number(__ENV.TRACE || 0);
|
||||
const URL = `${API}/chats/${fixture.readChatId}/messages`;
|
||||
const PARAMS = {
|
||||
headers: authHeaders(fixture.tokens[fixture.readerId]),
|
||||
responseCallback: http.expectedStatuses(200),
|
||||
};
|
||||
|
||||
export const options = {
|
||||
scenarios: {
|
||||
read: {
|
||||
executor: "constant-vus",
|
||||
vus: Number(__ENV.VUS),
|
||||
duration: __ENV.DURATION,
|
||||
gracefulStop: "5s",
|
||||
},
|
||||
},
|
||||
summaryTrendStats: SUMMARY_TREND_STATS,
|
||||
thresholds: SUMMARY_THRESHOLDS,
|
||||
};
|
||||
|
||||
let random = null;
|
||||
let picks = 0;
|
||||
|
||||
export default function () {
|
||||
if (random === null) {
|
||||
random = mulberry32(SEED + exec.vu.idInTest);
|
||||
}
|
||||
const index = Math.floor(random() * cursors.length);
|
||||
if (picks < TRACE) {
|
||||
console.log(`trace vu=${exec.vu.idInTest} pick=${picks} index=${index}`);
|
||||
}
|
||||
picks += 1;
|
||||
const cursor = encodeURIComponent(cursors[index]);
|
||||
const res = http.get(`${URL}?limit=${PAGE_LIMIT}&cursor=${cursor}`, PARAMS);
|
||||
check(res, {
|
||||
"status 200": (r) => r.status === 200,
|
||||
"full page": (r) => r.status === 200 && r.json("items.#") === PAGE_LIMIT,
|
||||
});
|
||||
}
|
||||
|
||||
export function handleSummary(data) {
|
||||
return summaryFiles(data);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
// Проверки восстановления через HTTP (трек 2), фаза — PHASE:
|
||||
// - source: исходная база до восстановления;
|
||||
// - stale: API на восстановленной базе, кэш ещё не очищен;
|
||||
// - restored: после FLUSHALL.
|
||||
// Во всех фазах — страницы этапа плана (plan_pages.json) и /users/me
|
||||
// читателя; в stale и restored — ещё чат и пользователь «после backup».
|
||||
// Ответы не проверяются здесь: статусы и элементы страниц пишутся в
|
||||
// check-<фаза>.json, сверяет оркестратор. Токенов в итоге нет.
|
||||
import http from "k6/http";
|
||||
|
||||
import { API, PAGE_LIMIT, WORK_DIR, authHeaders } from "./lib.js";
|
||||
|
||||
const PHASE = __ENV.PHASE;
|
||||
const fixture = JSON.parse(open(`${WORK_DIR}/fixture.json`));
|
||||
const pages = JSON.parse(open(`${WORK_DIR}/plan_pages.json`));
|
||||
// after.json появляется только после активности «после backup»
|
||||
const after = PHASE === "source"
|
||||
? null
|
||||
: JSON.parse(open(`${WORK_DIR}/after.json`));
|
||||
|
||||
export const options = {
|
||||
vus: 1,
|
||||
iterations: 1,
|
||||
setupTimeout: "5m",
|
||||
};
|
||||
|
||||
function status(res) {
|
||||
return res.status;
|
||||
}
|
||||
|
||||
export function setup() {
|
||||
const reader = { headers: authHeaders(fixture.tokens[fixture.readerId]) };
|
||||
const result = {
|
||||
phase: PHASE,
|
||||
reader_me: status(http.get(`${API}/users/me`, reader)),
|
||||
pages: pages.map((page) => {
|
||||
const query = page.cursor === null
|
||||
? `?limit=${PAGE_LIMIT}`
|
||||
: `?limit=${PAGE_LIMIT}&cursor=${encodeURIComponent(page.cursor)}`;
|
||||
const res = http.get(
|
||||
`${API}/chats/${page.chat_id}/messages${query}`,
|
||||
reader,
|
||||
);
|
||||
return {
|
||||
chat: page.chat,
|
||||
page: page.page,
|
||||
status: res.status,
|
||||
items: res.status === 200 ? res.json("items") : null,
|
||||
};
|
||||
}),
|
||||
};
|
||||
if (after !== null) {
|
||||
const late = { headers: authHeaders(after.token) };
|
||||
result.late_me = status(http.get(`${API}/users/me`, late));
|
||||
result.after_chat_get = status(
|
||||
http.get(`${API}/chats/${after.chatId}`, reader),
|
||||
);
|
||||
}
|
||||
if (PHASE === "stale") {
|
||||
// запись в чат, которого нет в восстановленной базе, а карточка — в кэше
|
||||
result.after_chat_post = status(
|
||||
http.post(
|
||||
`${API}/chats/${after.chatId}/messages`,
|
||||
JSON.stringify({ text: "written to a stale chat" }),
|
||||
reader,
|
||||
),
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export default function () {}
|
||||
|
||||
export function handleSummary(data) {
|
||||
return {
|
||||
[`${WORK_DIR}/check-${PHASE}.json`]: JSON.stringify(data.setup_data),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// Проверка после блока read: читаемый чат не изменился. Дочитывает
|
||||
// историю от последнего курсора пула до конца и считает сообщения. Новое
|
||||
// сообщение встало бы в конец, поэтому хвоста достаточно.
|
||||
import http from "k6/http";
|
||||
import { fail } from "k6";
|
||||
|
||||
import { API, WORK_DIR, authHeaders } from "./lib.js";
|
||||
|
||||
const fixture = JSON.parse(open(`${WORK_DIR}/fixture.json`));
|
||||
const pool = JSON.parse(open(`${WORK_DIR}/cursors.json`));
|
||||
const WALK_LIMIT = Number(__ENV.WALK_LIMIT || 100);
|
||||
|
||||
export const options = {
|
||||
vus: 1,
|
||||
iterations: 1,
|
||||
setupTimeout: "30m",
|
||||
};
|
||||
|
||||
export function setup() {
|
||||
const url = `${API}/chats/${fixture.readChatId}/messages`;
|
||||
const params = { headers: authHeaders(fixture.tokens[fixture.readerId]) };
|
||||
// пустой пул (история короче страницы обхода) — читаем с начала
|
||||
const hasPool = pool.cursors.length > 0;
|
||||
let cursor = hasPool ? pool.cursors[pool.cursors.length - 1] : null;
|
||||
let tail = 0;
|
||||
for (;;) {
|
||||
const query = cursor === null
|
||||
? `?limit=${WALK_LIMIT}`
|
||||
: `?limit=${WALK_LIMIT}&cursor=${encodeURIComponent(cursor)}`;
|
||||
const res = http.get(url + query, params);
|
||||
if (res.status !== 200) {
|
||||
fail(`history tail after ${tail}: ${res.status} ${res.body}`);
|
||||
}
|
||||
const body = res.json();
|
||||
tail += body.items.length;
|
||||
if (body.next_cursor === null) {
|
||||
break;
|
||||
}
|
||||
cursor = body.next_cursor;
|
||||
}
|
||||
return { from_after: hasPool ? pool.last_after : 0, tail };
|
||||
}
|
||||
|
||||
export default function () {}
|
||||
|
||||
export function handleSummary(data) {
|
||||
return { [`${WORK_DIR}/tail.json`]: JSON.stringify(data.setup_data) };
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// Сценарий write: ровно COUNT сообщений в чат записи от участников по
|
||||
// кругу, VUS клиентов одновременно. Читаемый чат не меняется.
|
||||
import exec from "k6/execution";
|
||||
|
||||
import {
|
||||
SUMMARY_THRESHOLDS,
|
||||
SUMMARY_TREND_STATS,
|
||||
WORK_DIR,
|
||||
sendMessage,
|
||||
summaryFiles,
|
||||
syntheticText,
|
||||
} from "./lib.js";
|
||||
|
||||
const fixture = JSON.parse(open(`${WORK_DIR}/fixture.json`));
|
||||
const OFFSET = Number(__ENV.OFFSET || 0);
|
||||
|
||||
export const options = {
|
||||
scenarios: {
|
||||
write: {
|
||||
executor: "shared-iterations",
|
||||
vus: Number(__ENV.VUS),
|
||||
iterations: Number(__ENV.COUNT),
|
||||
maxDuration: "10m",
|
||||
},
|
||||
},
|
||||
discardResponseBodies: true,
|
||||
summaryTrendStats: SUMMARY_TREND_STATS,
|
||||
thresholds: SUMMARY_THRESHOLDS,
|
||||
};
|
||||
|
||||
export default function () {
|
||||
const n = OFFSET + exec.scenario.iterationInTest;
|
||||
const sender = fixture.memberIds[n % fixture.memberIds.length];
|
||||
sendMessage(
|
||||
fixture.writeChatId,
|
||||
fixture.tokens[sender],
|
||||
syntheticText("w", n),
|
||||
);
|
||||
}
|
||||
|
||||
export function handleSummary(data) {
|
||||
return summaryFiles(data);
|
||||
}
|
||||
+2991
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,46 @@
|
||||
# Шаблон config.toml: `make env_setup` копирует его, не перезаписывая
|
||||
# существующий файл. Приоритет: окружение > .env > config.toml >
|
||||
# значения по умолчанию. Любой параметр можно задать и через
|
||||
# окружение: SECTION__FIELD, например APP__LOG_LEVEL.
|
||||
|
||||
[app]
|
||||
# Режим (console / docker) задают Makefile, Dockerfile и compose через
|
||||
# APP__RUN_MODE, а порт — APP__PORT в .env; здесь их не указывать.
|
||||
log_level = "INFO"
|
||||
# сколько секунд uvicorn ждёт текущие запросы после SIGTERM
|
||||
graceful_shutdown_seconds = 8
|
||||
|
||||
[database]
|
||||
# Адрес, порт, пользователь, пароль и имя базы приходят из .env (мосты к
|
||||
# POSTGRES_*) и из environment compose; здесь их не указывать.
|
||||
pool_size = 10
|
||||
max_overflow = 5
|
||||
# секунды ожидания свободного соединения пула
|
||||
pool_timeout_seconds = 5
|
||||
# секунды на установку соединения
|
||||
connect_timeout_seconds = 3
|
||||
# миллисекунды, серверный statement_timeout; 0 — без ограничения
|
||||
statement_timeout_ms = 5000
|
||||
# секунды на всю работу запроса с БД: зависший сервер, обрыв сети
|
||||
request_timeout_seconds = 6
|
||||
|
||||
[auth]
|
||||
# секунды жизни сессии с момента входа (контрактное имя
|
||||
# SESSION_TTL_SECONDS); короткий срок для проверки истечения — окружением
|
||||
# AUTH__SESSION_TTL_SECONDS=2
|
||||
session_ttl_seconds = 3600
|
||||
# сколько хэшей пароля Argon2id считается одновременно: 64 MiB на каждый
|
||||
kdf_concurrency = 4
|
||||
|
||||
[cache]
|
||||
# Адрес, порт и пароль Valkey приходят из .env (мосты к VALKEY_*) и из
|
||||
# environment compose; здесь их не указывать.
|
||||
# секунды на всю команду Valkey (ожидание пула, соединение, ответ);
|
||||
# дольше — запрос идёт в PostgreSQL
|
||||
timeout_seconds = 0.2
|
||||
# секунды, на которые кэш пропускается после отказа Valkey
|
||||
retry_after_seconds = 5
|
||||
# секунды жизни карточки чата в кэше
|
||||
chat_ttl_seconds = 3600
|
||||
# соединений в пуле клиента Valkey
|
||||
max_connections = 10
|
||||
@@ -0,0 +1,138 @@
|
||||
# Стенд лабы 2: PostgreSQL, Valkey (кэш), одноразовые миграции и API.
|
||||
# Правила — .claude/rules/docker.md. Значения — из .env (шаблон
|
||||
# .env.example); литералы только у адреса публикации 127.0.0.1 и у режима
|
||||
# docker.
|
||||
name: mtusi-lab2
|
||||
|
||||
# окружение приложения: одно для api и migrate, чтобы они не разъехались
|
||||
x-app-env: &app-env
|
||||
APP__RUN_MODE: docker
|
||||
APP__PORT: ${APP__PORT:-8080}
|
||||
DATABASE__HOST: ${POSTGRES_HOST:-postgres}
|
||||
DATABASE__PORT: ${POSTGRES_PORT:-5432}
|
||||
DATABASE__USER: ${POSTGRES_USER:?POSTGRES_USER is not set, run make env_setup}
|
||||
DATABASE__PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is empty, run make env_setup}
|
||||
DATABASE__NAME: ${POSTGRES_DB:?POSTGRES_DB is not set, run make env_setup}
|
||||
CACHE__HOST: ${VALKEY_HOST:-valkey}
|
||||
CACHE__PORT: ${VALKEY_PORT:-6379}
|
||||
CACHE__PASSWORD: ${VALKEY_PASSWORD:?VALKEY_PASSWORD is empty, copy Valkey lines from .env.example}
|
||||
|
||||
# config.toml только на чтение, длинной записью: без файла запуск падает,
|
||||
# а не создаёт на хосте каталог config.toml/
|
||||
x-config-toml: &config-toml
|
||||
type: bind
|
||||
source: ./config.toml
|
||||
target: /app/config.toml
|
||||
read_only: true
|
||||
bind:
|
||||
create_host_path: false
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:18.6-trixie@sha256:5a5a84b19854a9ffaa54082c166ff4ec27473a361e496e5ea167f298f2da9722
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER:?POSTGRES_USER is not set, run make env_setup}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is empty, run make env_setup}
|
||||
POSTGRES_DB: ${POSTGRES_DB:?POSTGRES_DB is not set, run make env_setup}
|
||||
# порт самого сервера; его же берут pg_isready и psql в контейнере
|
||||
PGPORT: ${POSTGRES_PORT:-5432}
|
||||
ports:
|
||||
# только localhost: к нему подключается приложение в console
|
||||
- "127.0.0.1:${POSTGRES_OUT_PORT:-5433}:${POSTGRES_PORT:-5432}"
|
||||
volumes:
|
||||
# с 18.x данные в /var/lib/postgresql/18/docker, volume образа —
|
||||
# весь /var/lib/postgresql (Config.Volumes)
|
||||
- postgres_data:/var/lib/postgresql
|
||||
networks:
|
||||
default:
|
||||
# любое значение POSTGRES_HOST указывает на этот сервис
|
||||
aliases:
|
||||
- ${POSTGRES_HOST:-postgres}
|
||||
healthcheck:
|
||||
# по TCP, а не через сокет: при инициализации образ поднимает
|
||||
# временный сервер только на сокете, и проверка через сокет
|
||||
# сказала бы «готов» раньше времени. $$ — переменная контейнера
|
||||
test: ["CMD-SHELL", "pg_isready -h 127.0.0.1 -U \"$$POSTGRES_USER\" -d \"$$POSTGRES_DB\""]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 30s
|
||||
start_interval: 1s
|
||||
|
||||
# кэш карточек чатов: без volume, persistence выключен в valkey.conf —
|
||||
# после рестарта кэш пуст, данные остаются в PostgreSQL
|
||||
valkey:
|
||||
image: valkey/valkey:9.1.2-trixie@sha256:418652cfb58ef879d4978c33553735d7147016032d5aefaa14c828e611eb9dfd
|
||||
restart: unless-stopped
|
||||
# $$ — переменные контейнера: пароль не попадает в command литералом.
|
||||
# Через docker-entrypoint.sh образа: он запускает сервер не от root
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- exec docker-entrypoint.sh valkey-server /usr/local/etc/valkey/valkey.conf --port "$$VALKEY_PORT" --requirepass "$$VALKEY_PASSWORD"
|
||||
environment:
|
||||
VALKEY_PORT: ${VALKEY_PORT:-6379}
|
||||
VALKEY_PASSWORD: ${VALKEY_PASSWORD:?VALKEY_PASSWORD is empty, copy Valkey lines from .env.example}
|
||||
# пароль для valkey-cli в контейнере (healthcheck), без -a в команде
|
||||
VALKEYCLI_AUTH: ${VALKEY_PASSWORD:?VALKEY_PASSWORD is empty, copy Valkey lines from .env.example}
|
||||
ports:
|
||||
# только localhost: к нему подключается приложение в console
|
||||
- "127.0.0.1:${VALKEY_OUT_PORT:-6380}:${VALKEY_PORT:-6379}"
|
||||
volumes:
|
||||
- type: bind
|
||||
source: ./infra/valkey/valkey.conf
|
||||
target: /usr/local/etc/valkey/valkey.conf
|
||||
read_only: true
|
||||
bind:
|
||||
create_host_path: false
|
||||
networks:
|
||||
default:
|
||||
# любое значение VALKEY_HOST указывает на этот сервис
|
||||
aliases:
|
||||
- ${VALKEY_HOST:-valkey}
|
||||
healthcheck:
|
||||
# PONG только после AUTH: проверяет и запуск, и пароль
|
||||
test: ["CMD-SHELL", 'test "$$(valkey-cli -p "$$VALKEY_PORT" ping)" = PONG']
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 10s
|
||||
start_interval: 1s
|
||||
|
||||
migrate:
|
||||
# образ собирает сервис api (make run_docker, make test_isolated)
|
||||
image: mtusi-messenger:lab2
|
||||
pull_policy: never
|
||||
command: ["alembic", "upgrade", "head"]
|
||||
restart: "no"
|
||||
environment: *app-env
|
||||
volumes:
|
||||
- *config-toml
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
|
||||
api:
|
||||
build: .
|
||||
image: mtusi-messenger:lab2
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
# только localhost: стенд учебный
|
||||
- "127.0.0.1:${APP_OUT_PORT:-8080}:${APP__PORT:-8080}"
|
||||
environment: *app-env
|
||||
volumes:
|
||||
- *config-toml
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
# без кэша API работает, но в штатном стенде он есть с первого запроса
|
||||
valkey:
|
||||
condition: service_healthy
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
# healthcheck — из образа; SIGKILL не раньше, чем через 10 с
|
||||
stop_grace_period: 10s
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
@@ -0,0 +1,78 @@
|
||||
# Срок сессии и отказ БД при запросе с токеном
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| Спеки | `sessions` «Истёкший токен», «Срок не продлевается», «БД остановлена при запросе с токеном»; `service-configuration` «Короткий срок из окружения» |
|
||||
| Change | `session-auth`, задача 7.1 |
|
||||
| Дата | 2026-10-01 15:53 UTC |
|
||||
| Commit | `ae4154e` |
|
||||
| Хост | Docker Desktop 29.8.1, macOS arm64; ВМ Docker: 12 CPU, 7 GiB RAM; лимиты контейнерам не задавались |
|
||||
| Клиент | разовый stdlib-скрипт; токены и пароли синтетические и в файл не попадают |
|
||||
|
||||
Автоматическая проверка истечения и отказа БД требует особого стенда и
|
||||
входит в change `failure-checks`. Здесь — ручной прогон тех же сценариев.
|
||||
|
||||
## 1. Срок 2 с: `AUTH__SESSION_TTL_SECONDS=2`
|
||||
|
||||
Стенд: сервис в console на `127.0.0.1:18080`
|
||||
(`AUTH__SESSION_TTL_SECONDS=2 python3 .claude/skills/run-mtusi-messenger/driver.py
|
||||
--port 18080 start`), Postgres из compose. Файлы конфигурации не
|
||||
менялись: окружение важнее `.env` и `config.toml`. Запись «Created
|
||||
session» в журнале сервиса — с `ttl_seconds: 2`.
|
||||
|
||||
### Истёкший токен
|
||||
|
||||
`expires_at` минус момент входа — 2,04 с.
|
||||
|
||||
| Момент после входа | `GET /users/me` | `WWW-Authenticate` |
|
||||
|---|---|---|
|
||||
| сразу | 200 | — |
|
||||
| через 3 с | 401 `unauthorized` | `Bearer realm="messenger"` |
|
||||
|
||||
### Срок не продлевается: запросы каждые 0,5 с
|
||||
|
||||
| Время после входа | Статус |
|
||||
|---|---|
|
||||
| 0,1 с | 200 |
|
||||
| 0,6 с | 200 |
|
||||
| 1,1 с | 200 |
|
||||
| 1,6 с | 200 |
|
||||
| 2,1 с | 401 |
|
||||
| 2,6 с | 401 |
|
||||
| 3,2 с | 401 |
|
||||
|
||||
Срок по `expires_at` — 2,06 с после входа, первый 401 — через 2,1 с.
|
||||
Частые успешные запросы срок не продлили.
|
||||
|
||||
## 2. PostgreSQL остановлен, токен действующий
|
||||
|
||||
Стенд: `make run_docker`, API на `127.0.0.1:8080`, срок по умолчанию
|
||||
(3600 с).
|
||||
|
||||
| Шаг | Запрос | Статус | `code` |
|
||||
|---|---|---|---|
|
||||
| БД работает | `GET /users/me` с токеном | 200 | — |
|
||||
| `docker compose stop postgres` | `GET /users/me` с токеном | 503 | `unavailable` |
|
||||
| | `POST /auth/sessions` | 503 | `unavailable` |
|
||||
| `docker compose start postgres` | `GET /users/me` тем же токеном | 200 | — |
|
||||
|
||||
У ответа 503 нет `WWW-Authenticate`: это не отказ в аутентификации, а
|
||||
недоступность хранилища.
|
||||
|
||||
Журнал API за время шага (`docker compose logs --no-log-prefix api`,
|
||||
поля `level`, `event`, `error_type`):
|
||||
|
||||
```json
|
||||
{"level": "warning", "event": "Database is unavailable", "error_type": "gaierror"}
|
||||
{"level": "warning", "event": "Database is unavailable", "error_type": "gaierror"}
|
||||
```
|
||||
|
||||
## Вывод
|
||||
|
||||
- Срок сессии фиксируется при входе. Окружение
|
||||
`AUTH__SESSION_TTL_SECONDS` меняет его без правки файлов.
|
||||
- После срока токен получает 401 с вызовом Bearer, и запросы срок не
|
||||
продлевают.
|
||||
- При остановленной БД запрос с действующим токеном получает 503, а не
|
||||
401 и не анонимный доступ. После возврата БД тот же токен снова
|
||||
работает без рестарта API.
|
||||
@@ -0,0 +1,82 @@
|
||||
# Пароли и токены: что хранится, что пишется в журнал, время входа
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| Спеки | `users` «Хэш в БД»; `sessions` «Токена нет в хранилище», «Неизвестный пользователь»; `service-logging` «Вход и выход» |
|
||||
| Change | `session-auth`, задача 7.1 |
|
||||
| Дата | 2026-10-01 15:52 UTC |
|
||||
| Commit | `ae4154e` |
|
||||
| Стенд | `make run_docker` (compose: postgres, migrate, api), API на `127.0.0.1:8080` |
|
||||
| Хост | Docker Desktop 29.8.1, macOS arm64; ВМ Docker: 12 CPU, 7 GiB RAM; лимиты контейнерам не задавались |
|
||||
| Клиент | разовый stdlib-скрипт: HTTP по контракту, `psql` и `pg_dump` в контейнере postgres, `docker compose logs`. Пароль P и токен T синтетические и в файл не попадают — только итоги проверок |
|
||||
|
||||
## 1. Регистрация и вход
|
||||
|
||||
| Запрос | Статус | Проверка |
|
||||
|---|---|---|
|
||||
| `POST /users` alice и bob с одинаковым паролем P | 201, 201 | поля `User`: `created_at`, `display_name`, `id`, `username`; пароля и хэша в ответе нет |
|
||||
| `POST /auth/sessions` alice по Basic | 201 | токен T — 43 символа (`secrets.token_urlsafe(32)`, 256 бит), не содержит username и id |
|
||||
|
||||
## 2. Что лежит в PostgreSQL
|
||||
|
||||
```text
|
||||
$ select username, left(password_hash, 31), length(password_hash) from users ...
|
||||
alice_… $argon2id$v=19$m=65536,t=3,p=4$… 97
|
||||
bob_… $argon2id$v=19$m=65536,t=3,p=4$… 97
|
||||
```
|
||||
|
||||
Хэш — строка Argon2id (версия 19, m = 64 MiB, t = 3, p = 4) с солью и
|
||||
результатом; параметры видны в самой строке.
|
||||
|
||||
| Проверка | Результат |
|
||||
|---|---|
|
||||
| хэши одинакового пароля у alice и bob различаются (соль) | да |
|
||||
| `token_hash` сессии alice — 32 байта | да |
|
||||
| `token_hash` равен SHA-256 выданного токена | да |
|
||||
| пароль P встречается в `pg_dump --data-only` | нет |
|
||||
| токен T встречается в `pg_dump --data-only` | нет |
|
||||
|
||||
## 3. Журнал API
|
||||
|
||||
Сценарий: две регистрации, вход alice, вход с неверным паролем (401),
|
||||
выход (204). Поиск по `docker compose logs --no-log-prefix api` за время
|
||||
сценария:
|
||||
|
||||
| В журнале | Встречается |
|
||||
|---|---|
|
||||
| пароль P | нет |
|
||||
| токен T | нет |
|
||||
| SHA-256 токена (hex) | нет |
|
||||
| credentials Basic (base64) | нет |
|
||||
| слово `Authorization` | нет |
|
||||
| username alice | нет |
|
||||
|
||||
Записи сервиса о сессиях (`module=session_service`; id сокращены,
|
||||
`timestamp` и место вызова опущены):
|
||||
|
||||
```json
|
||||
{"level": "info", "event": "Created session", "user_id": "bc82f04f…", "session_id": "7c4d74c6…", "ttl_seconds": 3600}
|
||||
{"level": "warning", "event": "Login failed"}
|
||||
{"level": "info", "event": "Revoked session", "user_id": "bc82f04f…", "session_id": "7c4d74c6…", "already_revoked": false}
|
||||
```
|
||||
|
||||
## 4. Время ответа на вход: неверный пароль и неизвестный username
|
||||
|
||||
30 пар запросов поочерёдно; оба ответа — 401 с одинаковым телом и
|
||||
`WWW-Authenticate: Basic realm="messenger", charset="UTF-8"`.
|
||||
|
||||
| Случай | Медиана | p90 | Мин | Макс |
|
||||
|---|---|---|---|---|
|
||||
| неверный пароль | 26,4 мс | 31,1 мс | 24,8 мс | 39,2 мс |
|
||||
| неизвестный username | 26,0 мс | 29,8 мс | 25,1 мс | 58,5 мс |
|
||||
|
||||
## Вывод
|
||||
|
||||
- Пароль хранится только строкой Argon2id с солью, токен — только
|
||||
SHA-256. По таблицам ни пароль, ни действующий токен не восстановить.
|
||||
- В журнале нет пароля, токена, его хэша, credentials и username. Вход,
|
||||
неудачный вход и выход записаны с `user_id` и `id` сессии там, где
|
||||
они есть.
|
||||
- Неизвестный username проверяется против фиктивного хэша, поэтому время
|
||||
ответа то же, что у неверного пароля. Существование пользователя по
|
||||
времени не определить; разница медиан — 0,4 мс.
|
||||
@@ -0,0 +1,36 @@
|
||||
# Срок сессии: `config.toml`, значение по умолчанию, окружение, неверное значение
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| Спек | `service-configuration` «Срок жизни сессии»: сценарии «Срок из config.toml», «Срок по умолчанию», «Короткий срок из окружения», «Срок не число» |
|
||||
| Change | `session-auth`, доработка по `/opsx:verify` |
|
||||
| Дата | 2026-10-01 16:12 UTC |
|
||||
| Commit | `0cef333` |
|
||||
| Стенд | сервис в console на `127.0.0.1:18081` (`python -m src`), Postgres из compose |
|
||||
| Хост | Docker Desktop 29.8.1, macOS arm64; ВМ Docker: 12 CPU, 7 GiB RAM; лимиты контейнерам не задавались |
|
||||
| Как снято | разовый stdlib-скрипт. Для каждого случая сервис запускается из временной копии `src/` со своим `config.toml` (из `config_example.toml` с заменённой секцией `[auth]`) и тем же `.env`; рабочий `config.toml` не трогается. Регистрация и вход, срок — `expires_at` минус момент отправки входа. Пароли синтетические и не печатаются |
|
||||
|
||||
## Срок новой сессии
|
||||
|
||||
| Случай | `expires_at` − момент входа |
|
||||
|---|---|
|
||||
| в `config.toml` нет секции `[auth]` | 3600,0 с |
|
||||
| `[auth] session_ttl_seconds = 600` | 600,0 с |
|
||||
| 600 в файле + `AUTH__SESSION_TTL_SECONDS=2` в окружении | 2,0 с |
|
||||
|
||||
## Неверное значение
|
||||
|
||||
| Окружение | Запуск |
|
||||
|---|---|
|
||||
| `AUTH__SESSION_TTL_SECONDS=abc` | код 1: `ValidationError` для `auth.session_ttl_seconds` — Input should be a valid integer, unable to parse string as an integer |
|
||||
| `AUTH__SESSION_TTL_SECONDS=0` | код 1: `ValidationError` для `auth.session_ttl_seconds` — Input should be greater than 0 |
|
||||
|
||||
## Вывод
|
||||
|
||||
- Срок сессии — параметр `config.toml`, без него 3600 с.
|
||||
- Окружение `AUTH__SESSION_TTL_SECONDS` перекрывает файл без его правки:
|
||||
так проверяется истечение (`evidence/auth/expiry.md`).
|
||||
- Нецелое и неположительное значение останавливают запуск ошибкой
|
||||
проверки настроек.
|
||||
- Контрактное имя `SESSION_TTL_SECONDS` сопоставлено с параметром в
|
||||
`REPORT.md`.
|
||||
@@ -0,0 +1,99 @@
|
||||
# План запроса истории: размер 100k
|
||||
|
||||
Commit e61a0e5
|
||||
Страница истории читаемого чата; позиция — сколько сообщений
|
||||
истории до страницы:
|
||||
- first: после 0
|
||||
- middle: после 50000
|
||||
- last: после 99900
|
||||
|
||||
## Планы приложения
|
||||
|
||||
auto_explain (ANALYZE, BUFFERS, TIMING): запрос, параметры и план,
|
||||
с которыми его выполнило приложение (prepared statement asyncpg).
|
||||
|
||||
### first
|
||||
|
||||
duration: 0.031 ms plan:
|
||||
Query Text: SELECT messages.id, messages.chat_id, messages.sender_id, messages.text, messages.created_at
|
||||
FROM messages
|
||||
WHERE messages.chat_id = $1::UUID ORDER BY messages.created_at, messages.id
|
||||
LIMIT $2::INTEGER
|
||||
Query Parameters: $1 = '547a9c1d-1b3e-4901-8aee-460715b75b45', $2 = '51'
|
||||
Limit (cost=0.42..5.06 rows=51 width=121) (actual time=0.016..0.021 rows=51.00 loops=1)
|
||||
Buffers: shared hit=4
|
||||
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.42..9110.17 rows=100000 width=121) (actual time=0.016..0.018 rows=51.00 loops=1)
|
||||
Index Cond: (chat_id = '547a9c1d-1b3e-4901-8aee-460715b75b45'::uuid)
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=4
|
||||
|
||||
### middle
|
||||
|
||||
duration: 0.042 ms plan:
|
||||
Query Text: SELECT messages.id, messages.chat_id, messages.sender_id, messages.text, messages.created_at
|
||||
FROM messages
|
||||
WHERE messages.chat_id = $1::UUID AND (messages.created_at, messages.id) > ($2::TIMESTAMP WITH TIME ZONE, $3::UUID) ORDER BY messages.created_at, messages.id
|
||||
LIMIT $4::INTEGER
|
||||
Query Parameters: $1 = '547a9c1d-1b3e-4901-8aee-460715b75b45', $2 = '2026-10-02 00:27:22.663427+00', $3 = '438a10bc-cc63-4c01-9f81-62ffadcbc63b', $4 = '51'
|
||||
Limit (cost=0.42..6.88 rows=51 width=121) (actual time=0.015..0.031 rows=51.00 loops=1)
|
||||
Buffers: shared hit=50
|
||||
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.42..6410.36 rows=50569 width=121) (actual time=0.015..0.029 rows=51.00 loops=1)
|
||||
Index Cond: ((chat_id = '547a9c1d-1b3e-4901-8aee-460715b75b45'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:27:22.663427+00'::timestamp with time zone, '438a10bc-cc63-4c01-9f81-62ffadcbc63b'::uuid)))
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=50
|
||||
|
||||
### last
|
||||
|
||||
duration: 0.050 ms plan:
|
||||
Query Text: SELECT messages.id, messages.chat_id, messages.sender_id, messages.text, messages.created_at
|
||||
FROM messages
|
||||
WHERE messages.chat_id = $1::UUID AND (messages.created_at, messages.id) > ($2::TIMESTAMP WITH TIME ZONE, $3::UUID) ORDER BY messages.created_at, messages.id
|
||||
LIMIT $4::INTEGER
|
||||
Query Parameters: $1 = '547a9c1d-1b3e-4901-8aee-460715b75b45', $2 = '2026-10-02 00:28:16.874516+00', $3 = '2ecf99f9-79eb-4983-a427-a5845bf8f655', $4 = '51'
|
||||
Limit (cost=0.42..93.66 rows=51 width=121) (actual time=0.016..0.040 rows=51.00 loops=1)
|
||||
Buffers: shared hit=54
|
||||
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.42..159.47 rows=87 width=121) (actual time=0.016..0.037 rows=51.00 loops=1)
|
||||
Index Cond: ((chat_id = '547a9c1d-1b3e-4901-8aee-460715b75b45'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:28:16.874516+00'::timestamp with time zone, '2ecf99f9-79eb-4983-a427-a5845bf8f655'::uuid)))
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=54
|
||||
|
||||
## Средняя страница в psql: с индексом и без
|
||||
|
||||
Тот же текст запроса и те же параметры, что у плана middle.
|
||||
psql планирует их заново (custom plan). DROP INDEX — внутри
|
||||
транзакции, затем ROLLBACK: индекс остаётся в базе.
|
||||
|
||||
### С индексом ix_messages_chat_id_created_at_id
|
||||
|
||||
Limit (cost=0.42..6.88 rows=51 width=121) (actual time=0.031..0.055 rows=51.00 loops=1)
|
||||
Buffers: shared hit=50
|
||||
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.42..6410.36 rows=50569 width=121) (actual time=0.030..0.051 rows=51.00 loops=1)
|
||||
Index Cond: ((chat_id = '547a9c1d-1b3e-4901-8aee-460715b75b45'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:27:22.663427+00'::timestamp with time zone, '438a10bc-cc63-4c01-9f81-62ffadcbc63b'::uuid)))
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=50
|
||||
Planning:
|
||||
Buffers: shared hit=111
|
||||
Planning Time: 0.252 ms
|
||||
Execution Time: 0.091 ms
|
||||
|
||||
### Без индекса ix_messages_chat_id_created_at_id
|
||||
|
||||
Limit (cost=4954.81..4960.62 rows=51 width=121) (actual time=5.630..6.910 rows=51.00 loops=1)
|
||||
Buffers: shared hit=1948
|
||||
-> Gather Merge (cost=4954.81..10718.08 rows=50568 width=121) (actual time=5.629..6.895 rows=51.00 loops=1)
|
||||
Workers Planned: 1
|
||||
Workers Launched: 1
|
||||
Buffers: shared hit=1948
|
||||
-> Sort (cost=3954.80..4029.17 rows=29746 width=121) (actual time=4.649..4.651 rows=34.00 loops=2)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: top-N heapsort Memory: 42kB
|
||||
Buffers: shared hit=1948
|
||||
Worker 0: Sort Method: top-N heapsort Memory: 51kB
|
||||
-> Parallel Seq Scan on messages (cost=0.00..2962.41 rows=29746 width=121) (actual time=0.894..3.243 rows=25000.00 loops=2)
|
||||
Filter: ((chat_id = '547a9c1d-1b3e-4901-8aee-460715b75b45'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:27:22.663427+00'::timestamp with time zone, '438a10bc-cc63-4c01-9f81-62ffadcbc63b'::uuid)))
|
||||
Rows Removed by Filter: 25000
|
||||
Buffers: shared hit=1933
|
||||
Planning:
|
||||
Buffers: shared hit=15
|
||||
Planning Time: 0.088 ms
|
||||
Execution Time: 6.933 ms
|
||||
@@ -0,0 +1,94 @@
|
||||
# План запроса истории: размер 10k
|
||||
|
||||
Commit e61a0e5
|
||||
Страница истории читаемого чата; позиция — сколько сообщений
|
||||
истории до страницы:
|
||||
- first: после 0
|
||||
- middle: после 5000
|
||||
- last: после 9900
|
||||
|
||||
## Планы приложения
|
||||
|
||||
auto_explain (ANALYZE, BUFFERS, TIMING): запрос, параметры и план,
|
||||
с которыми его выполнило приложение (prepared statement asyncpg).
|
||||
|
||||
### first
|
||||
|
||||
duration: 0.034 ms plan:
|
||||
Query Text: SELECT messages.id, messages.chat_id, messages.sender_id, messages.text, messages.created_at
|
||||
FROM messages
|
||||
WHERE messages.chat_id = $1::UUID ORDER BY messages.created_at, messages.id
|
||||
LIMIT $2::INTEGER
|
||||
Query Parameters: $1 = '43653413-a4e5-4fce-8197-5e94ebffbd59', $2 = '51'
|
||||
Limit (cost=0.29..5.09 rows=51 width=121) (actual time=0.016..0.022 rows=51.00 loops=1)
|
||||
Buffers: shared hit=3
|
||||
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.29..942.41 rows=10000 width=121) (actual time=0.015..0.018 rows=51.00 loops=1)
|
||||
Index Cond: (chat_id = '43653413-a4e5-4fce-8197-5e94ebffbd59'::uuid)
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=3
|
||||
|
||||
### middle
|
||||
|
||||
duration: 0.049 ms plan:
|
||||
Query Text: SELECT messages.id, messages.chat_id, messages.sender_id, messages.text, messages.created_at
|
||||
FROM messages
|
||||
WHERE messages.chat_id = $1::UUID AND (messages.created_at, messages.id) > ($2::TIMESTAMP WITH TIME ZONE, $3::UUID) ORDER BY messages.created_at, messages.id
|
||||
LIMIT $4::INTEGER
|
||||
Query Parameters: $1 = '43653413-a4e5-4fce-8197-5e94ebffbd59', $2 = '2026-10-02 00:21:19.575202+00', $3 = '912186b6-d6ec-4eb9-85d7-c1cff28b4a98', $4 = '51'
|
||||
Limit (cost=0.29..7.04 rows=51 width=121) (actual time=0.011..0.037 rows=51.00 loops=1)
|
||||
Buffers: shared hit=54
|
||||
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.29..662.60 rows=5000 width=121) (actual time=0.011..0.034 rows=51.00 loops=1)
|
||||
Index Cond: ((chat_id = '43653413-a4e5-4fce-8197-5e94ebffbd59'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:21:19.575202+00'::timestamp with time zone, '912186b6-d6ec-4eb9-85d7-c1cff28b4a98'::uuid)))
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=54
|
||||
|
||||
### last
|
||||
|
||||
duration: 0.046 ms plan:
|
||||
Query Text: SELECT messages.id, messages.chat_id, messages.sender_id, messages.text, messages.created_at
|
||||
FROM messages
|
||||
WHERE messages.chat_id = $1::UUID AND (messages.created_at, messages.id) > ($2::TIMESTAMP WITH TIME ZONE, $3::UUID) ORDER BY messages.created_at, messages.id
|
||||
LIMIT $4::INTEGER
|
||||
Query Parameters: $1 = '43653413-a4e5-4fce-8197-5e94ebffbd59', $2 = '2026-10-02 00:21:24.712133+00', $3 = '77b54258-b0ae-4886-abfb-18c074ed7baf', $4 = '51'
|
||||
Limit (cost=0.29..77.36 rows=51 width=121) (actual time=0.009..0.034 rows=51.00 loops=1)
|
||||
Buffers: shared hit=54
|
||||
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.29..151.41 rows=100 width=121) (actual time=0.009..0.031 rows=51.00 loops=1)
|
||||
Index Cond: ((chat_id = '43653413-a4e5-4fce-8197-5e94ebffbd59'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:21:24.712133+00'::timestamp with time zone, '77b54258-b0ae-4886-abfb-18c074ed7baf'::uuid)))
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=54
|
||||
|
||||
## Средняя страница в psql: с индексом и без
|
||||
|
||||
Тот же текст запроса и те же параметры, что у плана middle.
|
||||
psql планирует их заново (custom plan). DROP INDEX — внутри
|
||||
транзакции, затем ROLLBACK: индекс остаётся в базе.
|
||||
|
||||
### С индексом ix_messages_chat_id_created_at_id
|
||||
|
||||
Limit (cost=0.29..7.04 rows=51 width=121) (actual time=0.017..0.041 rows=51.00 loops=1)
|
||||
Buffers: shared hit=54
|
||||
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.29..662.60 rows=5000 width=121) (actual time=0.016..0.037 rows=51.00 loops=1)
|
||||
Index Cond: ((chat_id = '43653413-a4e5-4fce-8197-5e94ebffbd59'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:21:19.575202+00'::timestamp with time zone, '912186b6-d6ec-4eb9-85d7-c1cff28b4a98'::uuid)))
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=54
|
||||
Planning:
|
||||
Buffers: shared hit=111
|
||||
Planning Time: 0.203 ms
|
||||
Execution Time: 0.068 ms
|
||||
|
||||
### Без индекса ix_messages_chat_id_created_at_id
|
||||
|
||||
Limit (cost=544.81..544.94 rows=51 width=121) (actual time=0.832..0.836 rows=51.00 loops=1)
|
||||
Buffers: shared hit=209
|
||||
-> Sort (cost=544.81..557.31 rows=5000 width=121) (actual time=0.831..0.834 rows=51.00 loops=1)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: top-N heapsort Memory: 44kB
|
||||
Buffers: shared hit=209
|
||||
-> Seq Scan on messages (cost=0.00..378.00 rows=5000 width=121) (actual time=0.206..0.559 rows=5000.00 loops=1)
|
||||
Filter: ((chat_id = '43653413-a4e5-4fce-8197-5e94ebffbd59'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:21:19.575202+00'::timestamp with time zone, '912186b6-d6ec-4eb9-85d7-c1cff28b4a98'::uuid)))
|
||||
Rows Removed by Filter: 5000
|
||||
Buffers: shared hit=203
|
||||
Planning:
|
||||
Buffers: shared hit=15
|
||||
Planning Time: 0.086 ms
|
||||
Execution Time: 0.848 ms
|
||||
@@ -0,0 +1,100 @@
|
||||
# План запроса истории: размер 500k
|
||||
|
||||
Commit e61a0e5
|
||||
Страница истории читаемого чата; позиция — сколько сообщений
|
||||
истории до страницы:
|
||||
- first: после 0
|
||||
- middle: после 250000
|
||||
- last: после 499500
|
||||
|
||||
## Планы приложения
|
||||
|
||||
auto_explain (ANALYZE, BUFFERS, TIMING): запрос, параметры и план,
|
||||
с которыми его выполнило приложение (prepared statement asyncpg).
|
||||
|
||||
### first
|
||||
|
||||
duration: 0.038 ms plan:
|
||||
Query Text: SELECT messages.id, messages.chat_id, messages.sender_id, messages.text, messages.created_at
|
||||
FROM messages
|
||||
WHERE messages.chat_id = $1::UUID ORDER BY messages.created_at, messages.id
|
||||
LIMIT $2::INTEGER
|
||||
Query Parameters: $1 = '109824b5-66a4-4253-80e5-49bb45401d43', $2 = '51'
|
||||
Limit (cost=0.42..5.06 rows=51 width=121) (actual time=0.017..0.025 rows=51.00 loops=1)
|
||||
Buffers: shared hit=4
|
||||
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.42..45451.11 rows=500000 width=121) (actual time=0.016..0.021 rows=51.00 loops=1)
|
||||
Index Cond: (chat_id = '109824b5-66a4-4253-80e5-49bb45401d43'::uuid)
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=4
|
||||
|
||||
### middle
|
||||
|
||||
duration: 0.048 ms plan:
|
||||
Query Text: SELECT messages.id, messages.chat_id, messages.sender_id, messages.text, messages.created_at
|
||||
FROM messages
|
||||
WHERE messages.chat_id = $1::UUID AND (messages.created_at, messages.id) > ($2::TIMESTAMP WITH TIME ZONE, $3::UUID) ORDER BY messages.created_at, messages.id
|
||||
LIMIT $4::INTEGER
|
||||
Query Parameters: $1 = '109824b5-66a4-4253-80e5-49bb45401d43', $2 = '2026-10-02 00:37:56.094512+00', $3 = '6cc91dc6-e968-416e-b22f-7c0cfd478b00', $4 = '51'
|
||||
Limit (cost=0.42..6.92 rows=51 width=121) (actual time=0.012..0.036 rows=51.00 loops=1)
|
||||
Buffers: shared hit=47
|
||||
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.42..31731.26 rows=248945 width=121) (actual time=0.012..0.033 rows=51.00 loops=1)
|
||||
Index Cond: ((chat_id = '109824b5-66a4-4253-80e5-49bb45401d43'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:37:56.094512+00'::timestamp with time zone, '6cc91dc6-e968-416e-b22f-7c0cfd478b00'::uuid)))
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=47
|
||||
|
||||
### last
|
||||
|
||||
duration: 0.049 ms plan:
|
||||
Query Text: SELECT messages.id, messages.chat_id, messages.sender_id, messages.text, messages.created_at
|
||||
FROM messages
|
||||
WHERE messages.chat_id = $1::UUID AND (messages.created_at, messages.id) > ($2::TIMESTAMP WITH TIME ZONE, $3::UUID) ORDER BY messages.created_at, messages.id
|
||||
LIMIT $4::INTEGER
|
||||
Query Parameters: $1 = '109824b5-66a4-4253-80e5-49bb45401d43', $2 = '2026-10-02 00:42:27.49097+00', $3 = 'e088f724-9b35-4c97-9f18-9c7895e0a326', $4 = '51'
|
||||
Limit (cost=0.42..91.14 rows=51 width=121) (actual time=0.010..0.038 rows=51.00 loops=1)
|
||||
Buffers: shared hit=55
|
||||
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.42..832.84 rows=468 width=121) (actual time=0.009..0.034 rows=51.00 loops=1)
|
||||
Index Cond: ((chat_id = '109824b5-66a4-4253-80e5-49bb45401d43'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:42:27.49097+00'::timestamp with time zone, 'e088f724-9b35-4c97-9f18-9c7895e0a326'::uuid)))
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=55
|
||||
|
||||
## Средняя страница в psql: с индексом и без
|
||||
|
||||
Тот же текст запроса и те же параметры, что у плана middle.
|
||||
psql планирует их заново (custom plan). DROP INDEX — внутри
|
||||
транзакции, затем ROLLBACK: индекс остаётся в базе.
|
||||
|
||||
### С индексом ix_messages_chat_id_created_at_id
|
||||
|
||||
Limit (cost=0.42..6.92 rows=51 width=121) (actual time=0.027..0.059 rows=51.00 loops=1)
|
||||
Buffers: shared hit=47
|
||||
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.42..31731.26 rows=248945 width=121) (actual time=0.026..0.054 rows=51.00 loops=1)
|
||||
Index Cond: ((chat_id = '109824b5-66a4-4253-80e5-49bb45401d43'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:37:56.094512+00'::timestamp with time zone, '6cc91dc6-e968-416e-b22f-7c0cfd478b00'::uuid)))
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=47
|
||||
Planning:
|
||||
Buffers: shared hit=111
|
||||
Planning Time: 0.287 ms
|
||||
Execution Time: 0.090 ms
|
||||
|
||||
### Без индекса ix_messages_chat_id_created_at_id
|
||||
|
||||
Limit (cost=17754.41..17760.35 rows=51 width=121) (actual time=18.156..20.096 rows=51.00 loops=1)
|
||||
Buffers: shared hit=9678
|
||||
-> Gather Merge (cost=17754.41..46748.16 rows=248945 width=121) (actual time=18.156..20.093 rows=51.00 loops=1)
|
||||
Workers Planned: 2
|
||||
Workers Launched: 2
|
||||
Buffers: shared hit=9678
|
||||
-> Sort (cost=16754.39..17013.70 rows=103727 width=121) (actual time=16.709..16.711 rows=42.33 loops=3)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: top-N heapsort Memory: 43kB
|
||||
Buffers: shared hit=9678
|
||||
Worker 0: Sort Method: top-N heapsort Memory: 42kB
|
||||
Worker 1: Sort Method: top-N heapsort Memory: 44kB
|
||||
-> Parallel Seq Scan on messages (cost=0.00..13293.83 rows=103727 width=121) (actual time=5.006..11.514 rows=83333.33 loops=3)
|
||||
Filter: ((chat_id = '109824b5-66a4-4253-80e5-49bb45401d43'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:37:56.094512+00'::timestamp with time zone, '6cc91dc6-e968-416e-b22f-7c0cfd478b00'::uuid)))
|
||||
Rows Removed by Filter: 83333
|
||||
Buffers: shared hit=9648
|
||||
Planning:
|
||||
Buffers: shared hit=15
|
||||
Planning Time: 0.094 ms
|
||||
Execution Time: 20.124 ms
|
||||
@@ -0,0 +1,393 @@
|
||||
{
|
||||
"label": "baseline",
|
||||
"status": "complete",
|
||||
"started_at": "2026-10-02T00:21:00+00:00",
|
||||
"command": "uv run python bench/run.py --profile full --label baseline",
|
||||
"git": {
|
||||
"commit": "e61a0e5",
|
||||
"dirty": false
|
||||
},
|
||||
"overrides": {},
|
||||
"host_state": {
|
||||
"start": {
|
||||
"swap_used_mib": 0.0,
|
||||
"swap_total_mib": 0.0,
|
||||
"memory_free_percent": 77,
|
||||
"power": "AC Power",
|
||||
"battery_percent": 80
|
||||
},
|
||||
"end": {
|
||||
"swap_used_mib": 0.0,
|
||||
"swap_total_mib": 0.0,
|
||||
"memory_free_percent": 78,
|
||||
"power": "AC Power",
|
||||
"battery_percent": 80
|
||||
}
|
||||
},
|
||||
"host_warnings": [],
|
||||
"other_containers": [],
|
||||
"app_image": {
|
||||
"tag": "mtusi-messenger:bench",
|
||||
"id": "sha256:b747d551f20964c998d3fd66b6d2c61a4c58a86ec622dd31316b5e2d3c13580f",
|
||||
"versions": {
|
||||
"python": "3.12.14",
|
||||
"fastapi": "0.141.1",
|
||||
"starlette": "1.7.0",
|
||||
"pydantic": "2.13.5",
|
||||
"uvicorn": "0.54.0",
|
||||
"sqlalchemy": "2.1.1",
|
||||
"asyncpg": "0.31.0",
|
||||
"redis": "8.1.0"
|
||||
}
|
||||
},
|
||||
"generator": {
|
||||
"image": "grafana/k6:2.3.0@sha256:9c2dee7f8ed74d317e4027c06a10f169b625638189de8d4555d0b3486a5aeb34",
|
||||
"version": "k6 v2.3.0 (commit/e088784614, go1.27.1, linux/arm64)"
|
||||
},
|
||||
"docker": {
|
||||
"server": "29.8.1",
|
||||
"vm_os": "Docker Desktop",
|
||||
"vm_cpus": 12,
|
||||
"vm_memory_gib": 7.7,
|
||||
"cgroup": "2",
|
||||
"logging_driver": "local"
|
||||
},
|
||||
"host": {
|
||||
"os": "macOS 26.6.2",
|
||||
"machine": "Apple M3 Pro",
|
||||
"memory_gib": 18.0
|
||||
},
|
||||
"profile": {
|
||||
"name": "full",
|
||||
"sizes": [
|
||||
10000,
|
||||
100000,
|
||||
500000
|
||||
],
|
||||
"concurrency": [
|
||||
1,
|
||||
10,
|
||||
50
|
||||
],
|
||||
"repeats": 3,
|
||||
"read_warmup_s": 5,
|
||||
"read_measure_s": 20,
|
||||
"write_warmup": 500,
|
||||
"write_measure": 5000,
|
||||
"prefill_chunk": 25000,
|
||||
"prefill_vus": 32,
|
||||
"text_length": 64,
|
||||
"page_limit": 50,
|
||||
"walk_limit": 100,
|
||||
"cursor_pool": 1000,
|
||||
"members": 10,
|
||||
"seed": 20260930,
|
||||
"warmup_seed_shift": 1000003,
|
||||
"generator_cpu_limit": 4.0,
|
||||
"cpus": "1",
|
||||
"memory": "2g",
|
||||
"db_cpus": "4",
|
||||
"db_memory": "3g",
|
||||
"cache_cpus": "2",
|
||||
"cache_memory": "512m",
|
||||
"session_ttl_seconds": 21600
|
||||
},
|
||||
"sizes": [
|
||||
{
|
||||
"size": 10000,
|
||||
"rss_before_mib": 87.5,
|
||||
"rss_after_mib": 91.6,
|
||||
"bytes_per_message": 431,
|
||||
"prefill_seconds": 11.0,
|
||||
"prefill_rate": 908,
|
||||
"cursors": 99,
|
||||
"maintenance_seconds": 0.1,
|
||||
"messages_rows": 10000,
|
||||
"messages_table_bytes": 1703936,
|
||||
"messages_indexes_bytes": 1032192,
|
||||
"db_bytes_per_message": 274,
|
||||
"plans": [
|
||||
{
|
||||
"page": "first",
|
||||
"after": 0,
|
||||
"source": "app",
|
||||
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
|
||||
"shared_hit": 3,
|
||||
"shared_read": 0,
|
||||
"rows": 51.0,
|
||||
"time_ms": 0.034,
|
||||
"kind": "custom"
|
||||
},
|
||||
{
|
||||
"page": "middle",
|
||||
"after": 5000,
|
||||
"source": "app",
|
||||
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
|
||||
"shared_hit": 54,
|
||||
"shared_read": 0,
|
||||
"rows": 51.0,
|
||||
"time_ms": 0.049,
|
||||
"kind": "custom"
|
||||
},
|
||||
{
|
||||
"page": "last",
|
||||
"after": 9900,
|
||||
"source": "app",
|
||||
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
|
||||
"shared_hit": 54,
|
||||
"shared_read": 0,
|
||||
"rows": 51.0,
|
||||
"time_ms": 0.046,
|
||||
"kind": "custom"
|
||||
},
|
||||
{
|
||||
"page": "middle",
|
||||
"after": 5000,
|
||||
"source": "psql",
|
||||
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
|
||||
"shared_hit": 54,
|
||||
"shared_read": 0,
|
||||
"rows": 51.0,
|
||||
"time_ms": 0.068,
|
||||
"kind": "custom"
|
||||
},
|
||||
{
|
||||
"page": "middle",
|
||||
"after": 5000,
|
||||
"source": "psql, no index",
|
||||
"node": "Seq Scan on messages",
|
||||
"shared_hit": 209,
|
||||
"shared_read": 0,
|
||||
"rows": 51.0,
|
||||
"time_ms": 0.848,
|
||||
"kind": "custom"
|
||||
}
|
||||
],
|
||||
"rss_peak_mib": 151.0
|
||||
},
|
||||
{
|
||||
"size": 100000,
|
||||
"rss_before_mib": 87.5,
|
||||
"rss_after_mib": 93.5,
|
||||
"bytes_per_message": 63,
|
||||
"prefill_seconds": 108.0,
|
||||
"prefill_rate": 926,
|
||||
"cursors": 999,
|
||||
"maintenance_seconds": 0.2,
|
||||
"messages_rows": 100000,
|
||||
"messages_table_bytes": 15876096,
|
||||
"messages_indexes_bytes": 10395648,
|
||||
"db_bytes_per_message": 263,
|
||||
"plans": [
|
||||
{
|
||||
"page": "first",
|
||||
"after": 0,
|
||||
"source": "app",
|
||||
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
|
||||
"shared_hit": 4,
|
||||
"shared_read": 0,
|
||||
"rows": 51.0,
|
||||
"time_ms": 0.031,
|
||||
"kind": "custom"
|
||||
},
|
||||
{
|
||||
"page": "middle",
|
||||
"after": 50000,
|
||||
"source": "app",
|
||||
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
|
||||
"shared_hit": 50,
|
||||
"shared_read": 0,
|
||||
"rows": 51.0,
|
||||
"time_ms": 0.042,
|
||||
"kind": "custom"
|
||||
},
|
||||
{
|
||||
"page": "last",
|
||||
"after": 99900,
|
||||
"source": "app",
|
||||
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
|
||||
"shared_hit": 54,
|
||||
"shared_read": 0,
|
||||
"rows": 51.0,
|
||||
"time_ms": 0.05,
|
||||
"kind": "custom"
|
||||
},
|
||||
{
|
||||
"page": "middle",
|
||||
"after": 50000,
|
||||
"source": "psql",
|
||||
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
|
||||
"shared_hit": 50,
|
||||
"shared_read": 0,
|
||||
"rows": 51.0,
|
||||
"time_ms": 0.091,
|
||||
"kind": "custom"
|
||||
},
|
||||
{
|
||||
"page": "middle",
|
||||
"after": 50000,
|
||||
"source": "psql, no index",
|
||||
"node": "Parallel Seq Scan on messages",
|
||||
"shared_hit": 1948,
|
||||
"shared_read": 0,
|
||||
"rows": 51.0,
|
||||
"time_ms": 6.933,
|
||||
"kind": "custom"
|
||||
}
|
||||
],
|
||||
"rss_peak_mib": 151.0
|
||||
},
|
||||
{
|
||||
"size": 500000,
|
||||
"rss_before_mib": 87.5,
|
||||
"rss_after_mib": 92.6,
|
||||
"bytes_per_message": 11,
|
||||
"prefill_seconds": 539.7,
|
||||
"prefill_rate": 926,
|
||||
"cursors": 1000,
|
||||
"maintenance_seconds": 0.2,
|
||||
"messages_rows": 500000,
|
||||
"messages_table_bytes": 79093760,
|
||||
"messages_indexes_bytes": 49119232,
|
||||
"db_bytes_per_message": 256,
|
||||
"plans": [
|
||||
{
|
||||
"page": "first",
|
||||
"after": 0,
|
||||
"source": "app",
|
||||
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
|
||||
"shared_hit": 4,
|
||||
"shared_read": 0,
|
||||
"rows": 51.0,
|
||||
"time_ms": 0.038,
|
||||
"kind": "custom"
|
||||
},
|
||||
{
|
||||
"page": "middle",
|
||||
"after": 250000,
|
||||
"source": "app",
|
||||
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
|
||||
"shared_hit": 47,
|
||||
"shared_read": 0,
|
||||
"rows": 51.0,
|
||||
"time_ms": 0.048,
|
||||
"kind": "custom"
|
||||
},
|
||||
{
|
||||
"page": "last",
|
||||
"after": 499500,
|
||||
"source": "app",
|
||||
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
|
||||
"shared_hit": 55,
|
||||
"shared_read": 0,
|
||||
"rows": 51.0,
|
||||
"time_ms": 0.049,
|
||||
"kind": "custom"
|
||||
},
|
||||
{
|
||||
"page": "middle",
|
||||
"after": 250000,
|
||||
"source": "psql",
|
||||
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
|
||||
"shared_hit": 47,
|
||||
"shared_read": 0,
|
||||
"rows": 51.0,
|
||||
"time_ms": 0.09,
|
||||
"kind": "custom"
|
||||
},
|
||||
{
|
||||
"page": "middle",
|
||||
"after": 250000,
|
||||
"source": "psql, no index",
|
||||
"node": "Parallel Seq Scan on messages",
|
||||
"shared_hit": 9678,
|
||||
"shared_read": 0,
|
||||
"rows": 51.0,
|
||||
"time_ms": 20.124,
|
||||
"kind": "custom"
|
||||
}
|
||||
],
|
||||
"rss_peak_mib": 151.1
|
||||
}
|
||||
],
|
||||
"limits": {
|
||||
"api": {
|
||||
"nano_cpus": 1000000000,
|
||||
"memory": 2147483648,
|
||||
"memory_swap": 2147483648,
|
||||
"published_ports": {},
|
||||
"healthcheck": [
|
||||
"NONE"
|
||||
],
|
||||
"log_driver": "local"
|
||||
},
|
||||
"postgres": {
|
||||
"nano_cpus": 4000000000,
|
||||
"memory": 3221225472,
|
||||
"memory_swap": 3221225472,
|
||||
"published_ports": {},
|
||||
"healthcheck": [
|
||||
"CMD-SHELL",
|
||||
"pg_isready -h 127.0.0.1 -U \"$POSTGRES_USER\" -d \"$POSTGRES_DB\""
|
||||
],
|
||||
"log_driver": "local"
|
||||
},
|
||||
"valkey": {
|
||||
"nano_cpus": 2000000000,
|
||||
"memory": 536870912,
|
||||
"memory_swap": 536870912,
|
||||
"published_ports": {},
|
||||
"healthcheck": [
|
||||
"CMD-SHELL",
|
||||
"test \"$(valkey-cli -p \"$VALKEY_PORT\" ping)\" = PONG"
|
||||
],
|
||||
"log_driver": "local"
|
||||
}
|
||||
},
|
||||
"stand": {
|
||||
"postgres": {
|
||||
"image": "postgres:18.6-trixie@sha256:5a5a84b19854a9ffaa54082c166ff4ec27473a361e496e5ea167f298f2da9722",
|
||||
"id": "sha256:5a5a84b19854a9ffaa54082c166ff4ec27473a361e496e5ea167f298f2da9722",
|
||||
"version": "18.6 (Debian 18.6-1.pgdg13+2)",
|
||||
"settings": {
|
||||
"autovacuum": "on",
|
||||
"checkpoint_timeout": "5min",
|
||||
"effective_cache_size": "4GB",
|
||||
"fsync": "on",
|
||||
"jit": "on",
|
||||
"maintenance_work_mem": "64MB",
|
||||
"max_connections": "100",
|
||||
"max_wal_size": "1GB",
|
||||
"plan_cache_mode": "auto",
|
||||
"random_page_cost": "4",
|
||||
"shared_buffers": "128MB",
|
||||
"shared_preload_libraries": "auto_explain",
|
||||
"synchronous_commit": "on",
|
||||
"wal_level": "replica",
|
||||
"work_mem": "4MB"
|
||||
}
|
||||
},
|
||||
"valkey": {
|
||||
"image": "valkey/valkey:9.1.2-trixie@sha256:418652cfb58ef879d4978c33553735d7147016032d5aefaa14c828e611eb9dfd",
|
||||
"id": "sha256:418652cfb58ef879d4978c33553735d7147016032d5aefaa14c828e611eb9dfd",
|
||||
"version": "9.1.2",
|
||||
"maxmemory": "67108864",
|
||||
"maxmemory-clients": "0",
|
||||
"maxmemory-eviction-tenacity": "10",
|
||||
"maxmemory-policy": "allkeys-lru",
|
||||
"maxmemory-samples": "5"
|
||||
},
|
||||
"app_env": {
|
||||
"APP__PORT": "8080",
|
||||
"APP__RUN_MODE": "docker",
|
||||
"AUTH__SESSION_TTL_SECONDS": "21600",
|
||||
"CACHE__HOST": "valkey",
|
||||
"CACHE__PORT": "6379",
|
||||
"DATABASE__HOST": "postgres",
|
||||
"DATABASE__NAME": "bench",
|
||||
"DATABASE__PORT": "5432",
|
||||
"DATABASE__USER": "bench"
|
||||
}
|
||||
},
|
||||
"finished_at": "2026-10-02T00:47:33+00:00"
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
size,chunk,messages_before,messages_after,duration_s,requests_ok,requests_failed,rps,error_ratio,p50_ms,p95_ms,p99_ms,max_ms,app_cpu_cores,rss_end_mib,mem_cgroup_end_mib,generator_cpu_cores,flags,db_cpu_cores
|
||||
10000,1,0,10000,11.018,10000,0,907.6,0.0,33.187,54.688,80.018,227.563,0.995,91.6,111.5,0.143,,0.21
|
||||
100000,1,0,25000,27.301,25000,0,915.7,0.0,33.451,52.543,67.663,243.363,0.999,91.6,83.9,0.135,,0.204
|
||||
100000,2,25000,50000,27.151,25000,0,920.8,0.0,33.402,53.317,69.073,179.275,0.995,92.5,82.5,0.134,,0.202
|
||||
100000,3,50000,75000,27.15,25000,0,920.8,0.0,33.688,53.359,67.828,131.394,0.999,93.5,84.1,0.135,,0.204
|
||||
100000,4,75000,100000,26.386,25000,0,947.5,0.0,32.745,51.17,64.453,147.5,0.999,93.5,83.5,0.137,,0.212
|
||||
500000,1,0,25000,27.199,25000,0,919.1,0.0,33.492,52.766,66.789,227.795,0.999,91.6,82.2,0.135,,0.207
|
||||
500000,2,25000,50000,27.007,25000,0,925.7,0.0,33.322,51.502,64.544,114.587,1.0,92.5,80.8,0.137,,0.205
|
||||
500000,3,50000,75000,27.121,25000,0,921.8,0.0,33.681,53.131,67.132,141.988,1.0,92.6,82.9,0.134,,0.203
|
||||
500000,4,75000,100000,27.702,25000,0,902.5,0.0,34.407,55.32,72.185,155.464,1.0,92.6,82.8,0.129,,0.204
|
||||
500000,5,100000,125000,27.027,25000,0,925.0,0.0,33.382,51.994,65.514,127.731,0.999,92.6,82.6,0.136,,0.206
|
||||
500000,6,125000,150000,27.168,25000,0,920.2,0.0,33.718,52.447,66.423,114.897,1.0,92.6,84.6,0.137,,0.211
|
||||
500000,7,150000,175000,27.187,25000,0,919.6,0.0,33.835,52.353,64.333,133.09,0.999,92.6,84.7,0.137,,0.211
|
||||
500000,8,175000,200000,27.049,25000,0,924.3,0.0,33.453,52.026,66.033,118.281,0.999,92.6,83.0,0.137,,0.209
|
||||
500000,9,200000,225000,27.234,25000,0,918.0,0.0,33.619,53.08,68.421,113.571,0.998,92.6,83.0,0.137,,0.21
|
||||
500000,10,225000,250000,26.8,25000,0,932.8,0.0,33.083,51.807,65.1,130.39,0.999,92.6,83.1,0.134,,0.21
|
||||
500000,11,250000,275000,26.733,25000,0,935.2,0.0,33.042,51.894,68.126,152.377,0.997,92.6,83.1,0.135,,0.205
|
||||
500000,12,275000,300000,26.809,25000,0,932.5,0.0,33.16,51.496,65.213,128.389,0.999,92.6,81.0,0.136,,0.208
|
||||
500000,13,300000,325000,26.599,25000,0,939.9,0.0,32.886,51.319,64.505,122.747,1.0,92.6,82.7,0.136,,0.205
|
||||
500000,14,325000,350000,27.04,25000,0,924.6,0.0,33.375,51.756,64.432,110.653,0.999,92.6,83.0,0.138,,0.215
|
||||
500000,15,350000,375000,26.732,25000,0,935.2,0.0,33.074,51.71,65.224,137.091,0.999,92.6,82.7,0.134,,0.208
|
||||
500000,16,375000,400000,27.088,25000,0,922.9,0.0,33.56,52.647,67.052,108.234,1.0,92.6,83.0,0.134,,0.211
|
||||
500000,17,400000,425000,26.828,25000,0,931.9,0.0,33.054,52.435,67.054,114.851,0.999,92.6,82.9,0.135,,0.21
|
||||
500000,18,425000,450000,26.86,25000,0,930.8,0.0,33.041,51.698,65.699,130.022,0.999,92.6,82.9,0.136,,0.207
|
||||
500000,19,450000,475000,26.668,25000,0,937.5,0.0,32.948,51.698,66.148,115.29,0.999,92.6,82.8,0.136,,0.21
|
||||
500000,20,475000,500000,26.858,25000,0,930.8,0.0,33.359,52.943,67.103,147.667,0.999,92.6,83.2,0.136,,0.208
|
||||
|
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"label": "baseline",
|
||||
"profile": "full",
|
||||
"stage": "done",
|
||||
"size": 500000,
|
||||
"runs_done": 54,
|
||||
"runs_total": 54,
|
||||
"elapsed_s": 1593,
|
||||
"eta_s": 0,
|
||||
"warnings": [],
|
||||
"updated_at": "2026-10-02T00:47:33+00:00"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdErrTTY":false,"testRunDurationMs":27301.432749,"isStdOutTTY":false},"metrics":{"http_req_failed":{"type":"rate","contains":"default","values":{"rate":0,"passes":0,"fails":25000}},"http_req_blocked":{"type":"trend","contains":"time","values":{"p(50)":0.000834,"p(95)":0.001708,"p(99)":0.003334,"max":1.607167,"avg":0.0025265527599996175,"min":0.000416,"med":0.000834}},"data_sent":{"type":"counter","contains":"data","values":{"count":8225000,"rate":301266.2403331659}},"vus":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"iteration_duration":{"type":"trend","contains":"time","values":{"min":11.425125,"med":33.5005,"p(50)":33.5005,"p(95)":52.59873095,"p(99)":67.73737358,"max":244.839542,"avg":34.928659873280196}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"avg":0,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0}},"checks":{"type":"rate","contains":"default","values":{"rate":1,"passes":25000,"fails":0}},"http_req_duration":{"contains":"time","values":{"p(99)":67.66284990999999,"max":243.363083,"avg":34.875992672279864,"min":11.384917,"med":33.451333500000004,"p(50)":33.451333500000004,"p(95)":52.5429452},"type":"trend"},"http_req_waiting":{"type":"trend","contains":"time","values":{"min":11.372,"med":33.432459,"p(50)":33.432459,"p(95)":52.52494585,"p(99)":67.62921667,"max":243.342333,"avg":34.85801068876007}},"http_req_duration{expected_response:true}":{"values":{"min":11.384917,"med":33.451333500000004,"p(50)":33.451333500000004,"p(95)":52.5429452,"p(99)":67.66284990999999,"max":243.363083,"avg":34.875992672279864},"thresholds":{"max>=0":{"ok":true}},"type":"trend","contains":"time"},"http_reqs":{"type":"counter","contains":"default","values":{"count":25000,"rate":915.7028581555194}},"http_req_receiving":{"type":"trend","contains":"time","values":{"p(95)":0.030666049999999997,"p(99)":0.057335509999999944,"max":1.523792,"avg":0.013947407280000216,"min":0.003958,"med":0.011333,"p(50)":0.011333}},"data_received":{"type":"counter","contains":"data","values":{"count":11025000,"rate":403824.9604465841}},"iterations":{"type":"counter","contains":"default","values":{"count":25000,"rate":915.7028581555194}},"vus_max":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"http_req_connecting":{"type":"trend","contains":"time","values":{"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0.297042,"avg":0.00015992999999999997}},"http_req_sending":{"values":{"avg":0.004034576239999893,"min":0.001584,"med":0.003167,"p(50)":0.003167,"p(95)":0.007666,"p(99)":0.016459,"max":0.2635},"type":"trend","contains":"time"}},"root_group":{"groups":[],"checks":[{"fails":0,"name":"message 201","path":"::message 201","id":"6445aff337e1ade0bc10402fbac79882","passes":25000}],"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e"}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"groups":[],"checks":[{"id":"6445aff337e1ade0bc10402fbac79882","passes":25000,"fails":0,"name":"message 201","path":"::message 201"}],"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e"},"options":{"noColor":true,"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":""},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":27150.563082},"metrics":{"http_req_failed":{"values":{"rate":0,"passes":0,"fails":25000},"type":"rate","contains":"default"},"http_req_duration{expected_response:true}":{"thresholds":{"max>=0":{"ok":true}},"type":"trend","contains":"time","values":{"max":179.275459,"avg":34.682297986080094,"min":11.545167,"med":33.4017085,"p(50)":33.4017085,"p(95)":53.31742469999999,"p(99)":69.07309716999998}},"http_req_waiting":{"type":"trend","contains":"time","values":{"max":179.266584,"avg":34.664602647160166,"min":11.531542,"med":33.3847915,"p(50)":33.3847915,"p(95)":53.292391349999995,"p(99)":69.05534966999997}},"http_req_connecting":{"type":"trend","contains":"time","values":{"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0.379166,"avg":0.00011372668000000001}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0,"avg":0,"min":0}},"checks":{"values":{"rate":1,"passes":25000,"fails":0},"type":"rate","contains":"default"},"http_req_blocked":{"values":{"min":0.000417,"med":0.000834,"p(50)":0.000834,"p(95)":0.001708,"p(99)":0.003292409999999991,"max":2.267,"avg":0.002852094959999736},"type":"trend","contains":"time"},"http_req_receiving":{"values":{"p(50)":0.011375,"p(95)":0.029458,"p(99)":0.05591601,"max":0.361834,"avg":0.013743192200000037,"min":0.004,"med":0.011375},"type":"trend","contains":"time"},"data_sent":{"values":{"count":8225000,"rate":302940.31012023194},"type":"counter","contains":"data"},"vus_max":{"contains":"default","values":{"value":32,"min":32,"max":32},"type":"gauge"},"vus":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"data_received":{"type":"counter","contains":"data","values":{"count":11025000,"rate":406068.9263313747}},"iteration_duration":{"type":"trend","contains":"time","values":{"min":11.589833,"med":33.4522915,"p(50)":33.4522915,"p(95)":53.378204149999995,"p(99)":69.12095600999999,"max":179.308792,"avg":34.73491701556002}},"iterations":{"type":"counter","contains":"default","values":{"count":25000,"rate":920.7912161709177}},"http_reqs":{"type":"counter","contains":"default","values":{"count":25000,"rate":920.7912161709177}},"http_req_duration":{"type":"trend","contains":"time","values":{"min":11.545167,"med":33.4017085,"p(50)":33.4017085,"p(95)":53.31742469999999,"p(99)":69.07309716999998,"max":179.275459,"avg":34.682297986080094}},"http_req_sending":{"values":{"avg":0.003952146719999886,"min":0.001667,"med":0.003125,"p(50)":0.003125,"p(95)":0.007458,"p(99)":0.016251249999999974,"max":0.203542},"type":"trend","contains":"time"}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"testRunDurationMs":27149.892415,"isStdOutTTY":false,"isStdErrTTY":false},"metrics":{"vus":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"checks":{"type":"rate","contains":"default","values":{"rate":1,"passes":25000,"fails":0}},"data_received":{"type":"counter","contains":"data","values":{"count":11025000,"rate":406078.9572009065}},"http_req_duration{expected_response:true}":{"type":"trend","contains":"time","values":{"avg":34.68239686859979,"min":11.021708,"med":33.688083500000005,"p(50)":33.688083500000005,"p(95)":53.35858155,"p(99)":67.82779899999998,"max":131.393791},"thresholds":{"max>=0":{"ok":true}}},"http_req_connecting":{"type":"trend","contains":"time","values":{"p(95)":0,"p(99)":0,"max":0.313084,"avg":0.00010004007999999999,"min":0,"med":0,"p(50)":0}},"http_reqs":{"values":{"count":25000,"rate":920.8139619068173},"type":"counter","contains":"default"},"http_req_receiving":{"type":"trend","contains":"time","values":{"avg":0.013724771160000137,"min":0.003917,"med":0.011416,"p(50)":0.011416,"p(95)":0.029625,"p(99)":0.057708419999999996,"max":0.31125}},"iterations":{"type":"counter","contains":"default","values":{"count":25000,"rate":920.8139619068173}},"http_req_waiting":{"contains":"time","values":{"p(50)":33.668229,"p(95)":53.3382167,"p(99)":67.80776674999998,"max":131.376167,"avg":34.66466029991987,"min":11.013416,"med":33.668229},"type":"trend"},"iteration_duration":{"type":"trend","contains":"time","values":{"avg":34.73462744399994,"min":11.058,"med":33.738749999999996,"p(50)":33.738749999999996,"p(95)":53.42747084999999,"p(99)":67.87765999999999,"max":132.772417}},"vus_max":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"http_req_blocked":{"contains":"time","values":{"p(99)":0.003209409999999991,"max":1.505084,"avg":0.0022655991199996613,"min":0.000416,"med":0.000834,"p(50)":0.000834,"p(95)":0.001709},"type":"trend"},"http_req_tls_handshaking":{"contains":"time","values":{"p(50)":0,"p(95)":0,"p(99)":0,"max":0,"avg":0,"min":0,"med":0},"type":"trend"},"http_req_sending":{"type":"trend","contains":"time","values":{"max":0.173292,"avg":0.004011797519999872,"min":0.001667,"med":0.003167,"p(50)":0.003167,"p(95)":0.007667,"p(99)":0.016666}},"data_sent":{"values":{"count":8225000,"rate":302947.7934673429},"type":"counter","contains":"data"},"http_req_duration":{"type":"trend","contains":"time","values":{"avg":34.68239686859979,"min":11.021708,"med":33.688083500000005,"p(50)":33.688083500000005,"p(95)":53.35858155,"p(99)":67.82779899999998,"max":131.393791}},"http_req_failed":{"type":"rate","contains":"default","values":{"rate":0,"passes":0,"fails":25000}}},"root_group":{"groups":[],"checks":[{"name":"message 201","path":"::message 201","id":"6445aff337e1ade0bc10402fbac79882","passes":25000,"fails":0}],"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e"}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"checks":[{"fails":0,"name":"message 201","path":"::message 201","id":"6445aff337e1ade0bc10402fbac79882","passes":25000}],"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[]},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":26386.372748},"metrics":{"iteration_duration":{"type":"trend","contains":"time","values":{"p(99)":64.50525841999999,"max":149.10675,"avg":33.75736454256003,"min":10.935792,"med":32.791771,"p(50)":32.791771,"p(95)":51.237097649999995}},"http_req_duration":{"type":"trend","contains":"time","values":{"min":10.889042,"med":32.7448545,"p(50)":32.7448545,"p(95)":51.16981635,"p(99)":64.45289907999998,"max":147.500125,"avg":33.70641126832006}},"http_reqs":{"type":"counter","contains":"default","values":{"count":25000,"rate":947.4587598212005}},"http_req_waiting":{"contains":"time","values":{"med":32.728375,"p(50)":32.728375,"p(95)":51.158820549999994,"p(99)":64.42631542,"max":147.476208,"avg":33.68876010956001,"min":10.878958},"type":"trend"},"http_req_failed":{"type":"rate","contains":"default","values":{"passes":0,"fails":25000,"rate":0}},"checks":{"values":{"rate":1,"passes":25000,"fails":0},"type":"rate","contains":"default"},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"p(50)":0,"p(95)":0,"p(99)":0,"max":0,"avg":0,"min":0,"med":0}},"http_req_sending":{"type":"trend","contains":"time","values":{"p(95)":0.007416049999999999,"p(99)":0.0155,"max":0.218541,"avg":0.00387482327999988,"min":0.001708,"med":0.003083,"p(50)":0.003083}},"data_sent":{"type":"counter","contains":"data","values":{"count":8225000,"rate":311713.9319811749}},"http_req_connecting":{"type":"trend","contains":"time","values":{"max":0.2605,"avg":0.00013785827999999997,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0}},"data_received":{"type":"counter","contains":"data","values":{"count":11025000,"rate":417829.3130811494}},"http_req_blocked":{"type":"trend","contains":"time","values":{"p(95)":0.001625,"p(99)":0.002917,"max":1.360458,"avg":0.0019912267599997467,"min":0.000416,"med":0.000833,"p(50)":0.000833}},"iterations":{"contains":"default","values":{"count":25000,"rate":947.4587598212005},"type":"counter"},"http_req_duration{expected_response:true}":{"type":"trend","contains":"time","values":{"med":32.7448545,"p(50)":32.7448545,"p(95)":51.16981635,"p(99)":64.45289907999998,"max":147.500125,"avg":33.70641126832006,"min":10.889042},"thresholds":{"max>=0":{"ok":true}}},"vus":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"http_req_receiving":{"type":"trend","contains":"time","values":{"med":0.0115,"p(50)":0.0115,"p(95)":0.02925,"p(99)":0.05900207999999995,"max":0.509083,"avg":0.013776335480000033,"min":0.003875}},"vus_max":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"fails":0,"name":"message 201","path":"::message 201","id":"6445aff337e1ade0bc10402fbac79882","passes":10000}],"name":"","path":""},"options":{"noColor":true,"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":""},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":11018.16363},"metrics":{"data_received":{"type":"counter","contains":"data","values":{"count":4410000,"rate":400248.1854591952}},"vus_max":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"data_sent":{"type":"counter","contains":"data","values":{"count":3290000,"rate":298597.85264416155}},"http_req_connecting":{"type":"trend","contains":"time","values":{"avg":0.0003671374000000002,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0.265625}},"iteration_duration":{"contains":"time","values":{"avg":35.22289649309995,"min":11.017917,"med":33.237479,"p(50)":33.237479,"p(95)":54.738593099999996,"p(99)":80.080873,"max":228.935292},"type":"trend"},"http_req_duration":{"type":"trend","contains":"time","values":{"p(99)":80.01766975999999,"max":227.562917,"avg":35.16604782650005,"min":10.967041,"med":33.187021,"p(50)":33.187021,"p(95)":54.6875497}},"http_req_duration{expected_response:true}":{"type":"trend","contains":"time","values":{"min":10.967041,"med":33.187021,"p(50)":33.187021,"p(95)":54.6875497,"p(99)":80.01766975999999,"max":227.562917,"avg":35.16604782650005},"thresholds":{"max>=0":{"ok":true}}},"http_req_blocked":{"contains":"time","values":{"p(50)":0.000875,"p(95)":0.001791,"p(99)":0.004458829999999993,"max":1.131625,"avg":0.0032118876000000727,"min":0.000416,"med":0.000875},"type":"trend"},"vus":{"type":"gauge","contains":"default","values":{"max":32,"value":32,"min":32}},"http_req_sending":{"type":"trend","contains":"time","values":{"max":0.744167,"avg":0.004680360099999889,"min":0.001833,"med":0.003375,"p(50)":0.003375,"p(95)":0.008208,"p(99)":0.017502909999999976}},"http_req_waiting":{"type":"trend","contains":"time","values":{"avg":35.14657834160006,"min":10.946333,"med":33.1707085,"p(50)":33.1707085,"p(95)":54.6659545,"p(99)":80.00261976,"max":227.510375}},"http_req_receiving":{"type":"trend","contains":"time","values":{"p(95)":0.03221214999999996,"p(99)":0.059625,"max":1.738625,"avg":0.014789124799999965,"min":0.004167,"med":0.011666,"p(50)":0.011666}},"checks":{"type":"rate","contains":"default","values":{"rate":1,"passes":10000,"fails":0}},"iterations":{"type":"counter","contains":"default","values":{"count":10000,"rate":907.5922572770868}},"http_reqs":{"contains":"default","values":{"count":10000,"rate":907.5922572770868},"type":"counter"},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0,"avg":0}},"http_req_failed":{"type":"rate","contains":"default","values":{"passes":0,"fails":10000,"rate":0}}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"id":"6445aff337e1ade0bc10402fbac79882","passes":25000,"fails":0,"name":"message 201","path":"::message 201"}],"name":""},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":27199.416707},"metrics":{"vus_max":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"http_req_duration{expected_response:true}":{"contains":"time","values":{"avg":34.744818115240044,"min":10.820416,"med":33.4922505,"p(50)":33.4922505,"p(95)":52.765732699999994,"p(99)":66.78906466999999,"max":227.795},"thresholds":{"max>=0":{"ok":true}},"type":"trend"},"http_req_connecting":{"type":"trend","contains":"time","values":{"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0.20175,"avg":0.0001109634,"min":0}},"http_req_blocked":{"contains":"time","values":{"p(50)":0.000834,"p(95)":0.001625,"p(99)":0.002917,"max":1.935125,"avg":0.002452437679999617,"min":0.000416,"med":0.000834},"type":"trend"},"iterations":{"type":"counter","contains":"default","values":{"count":25000,"rate":919.137357587747}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"avg":0,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0}},"http_reqs":{"type":"counter","contains":"default","values":{"count":25000,"rate":919.137357587747}},"http_req_waiting":{"type":"trend","contains":"time","values":{"max":227.773375,"avg":34.72687064456007,"min":10.799458,"med":33.473104,"p(50)":33.473104,"p(95)":52.751010449999995,"p(99)":66.77146101}},"http_req_sending":{"contains":"time","values":{"min":0.001625,"med":0.00325,"p(50)":0.00325,"p(95)":0.007542,"p(99)":0.016334409999999994,"max":0.268667,"avg":0.004038044159999863},"type":"trend"},"http_req_receiving":{"type":"trend","contains":"time","values":{"max":0.656666,"avg":0.013909426520000084,"min":0.004125,"med":0.011458,"p(50)":0.011458,"p(95)":0.029375,"p(99)":0.05883440999999999}},"data_received":{"type":"counter","contains":"data","values":{"count":11025000,"rate":405339.5746961964}},"vus":{"type":"gauge","contains":"default","values":{"max":32,"value":32,"min":32}},"data_sent":{"type":"counter","contains":"data","values":{"count":8225000,"rate":302396.1906463688}},"http_req_failed":{"type":"rate","contains":"default","values":{"fails":25000,"rate":0,"passes":0}},"checks":{"type":"rate","contains":"default","values":{"rate":1,"passes":25000,"fails":0}},"http_req_duration":{"values":{"avg":34.744818115240044,"min":10.820416,"med":33.4922505,"p(50)":33.4922505,"p(95)":52.765732699999994,"p(99)":66.78906466999999,"max":227.795},"type":"trend","contains":"time"},"iteration_duration":{"type":"trend","contains":"time","values":{"min":10.864791,"med":33.5422715,"p(50)":33.5422715,"p(95)":52.81504965,"p(99)":66.84509167,"max":229.718458,"avg":34.797694421359935}}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"metrics":{"checks":{"values":{"fails":0,"rate":1,"passes":25000},"type":"rate","contains":"default"},"data_received":{"type":"counter","contains":"data","values":{"count":11025000,"rate":408225.00630719576}},"http_reqs":{"contains":"default","values":{"count":25000,"rate":925.6802864108747},"type":"counter"},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"p(95)":0,"p(99)":0,"max":0,"avg":0,"min":0,"med":0,"p(50)":0}},"iteration_duration":{"type":"trend","contains":"time","values":{"avg":34.551929167040015,"min":11.042917,"med":33.3729165,"p(50)":33.3729165,"p(95)":51.561319049999994,"p(99)":64.589952,"max":116.192333}},"http_req_duration{expected_response:true}":{"type":"trend","contains":"time","values":{"avg":34.49887261832016,"min":11.00025,"med":33.322083500000005,"p(50)":33.322083500000005,"p(95)":51.5022997,"p(99)":64.54375875000001,"max":114.587417},"thresholds":{"max>=0":{"ok":true}}},"http_req_blocked":{"type":"trend","contains":"time","values":{"p(50)":0.000834,"p(95)":0.0016270499999999544,"p(99)":0.002958,"max":1.875958,"avg":0.002798833399999737,"min":0.000417,"med":0.000834}},"http_req_connecting":{"type":"trend","contains":"time","values":{"p(99)":0,"max":0.312208,"avg":0.00018880484,"min":0,"med":0,"p(50)":0,"p(95)":0}},"http_req_sending":{"type":"trend","contains":"time","values":{"p(99)":0.01612541999999999,"max":0.406791,"avg":0.00399748539999986,"min":0.001708,"med":0.003208,"p(50)":0.003208,"p(95)":0.0075}},"http_req_receiving":{"type":"trend","contains":"time","values":{"max":0.298833,"avg":0.01400749864000009,"min":0.003833,"med":0.011584,"p(50)":0.011584,"p(95)":0.030044049999999954,"p(99)":0.057792409999999995}},"http_req_duration":{"type":"trend","contains":"time","values":{"avg":34.49887261832016,"min":11.00025,"med":33.322083500000005,"p(50)":33.322083500000005,"p(95)":51.5022997,"p(99)":64.54375875000001,"max":114.587417}},"http_req_waiting":{"type":"trend","contains":"time","values":{"med":33.3030835,"p(50)":33.3030835,"p(95)":51.490216350000004,"p(99)":64.52538691,"max":114.511208,"avg":34.48086763428005,"min":10.981083}},"http_req_failed":{"type":"rate","contains":"default","values":{"passes":0,"fails":25000,"rate":0}},"vus":{"contains":"default","values":{"value":17,"min":17,"max":32},"type":"gauge"},"data_sent":{"type":"counter","contains":"data","values":{"count":8225000,"rate":304548.8142291778}},"iterations":{"type":"counter","contains":"default","values":{"count":25000,"rate":925.6802864108747}},"vus_max":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}}},"root_group":{"path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"id":"6445aff337e1ade0bc10402fbac79882","passes":25000,"fails":0,"name":"message 201","path":"::message 201"}],"name":""},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":27007.164749}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"groups":[],"checks":[{"path":"::message 201","id":"6445aff337e1ade0bc10402fbac79882","passes":25000,"fails":0,"name":"message 201"}],"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e"},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":27121.025873},"metrics":{"checks":{"type":"rate","contains":"default","values":{"rate":1,"passes":25000,"fails":0}},"vus_max":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"http_req_failed":{"type":"rate","contains":"default","values":{"rate":0,"passes":0,"fails":25000}},"data_sent":{"type":"counter","contains":"data","values":{"count":8225000,"rate":303270.2390578926}},"data_received":{"values":{"count":11025000,"rate":406511.1715031326},"type":"counter","contains":"data"},"http_req_blocked":{"values":{"avg":0.001999624879999766,"min":0.000416,"med":0.000875,"p(50)":0.000875,"p(95)":0.001667,"p(99)":0.002916,"max":1.274458},"type":"trend","contains":"time"},"http_req_duration{expected_response:true}":{"type":"trend","contains":"time","values":{"max":141.987959,"avg":34.645498809079925,"min":0.031167,"med":33.681042,"p(50)":33.681042,"p(95)":53.1312351,"p(99)":67.13192351000001},"thresholds":{"max>=0":{"ok":true}}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0,"avg":0,"min":0}},"http_reqs":{"type":"counter","contains":"default","values":{"count":25000,"rate":921.7940396896431}},"http_req_waiting":{"type":"trend","contains":"time","values":{"max":141.954541,"avg":34.627466982359834,"min":0,"med":33.663270999999995,"p(50)":33.663270999999995,"p(95)":53.11446665,"p(99)":67.12084883}},"vus":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"http_req_connecting":{"contains":"time","values":{"avg":0.00006523651999999999,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0.103916},"type":"trend"},"http_req_sending":{"contains":"time","values":{"max":0.18075,"avg":0.004050156959999892,"min":0.00175,"med":0.00325,"p(50)":0.00325,"p(95)":0.007584,"p(99)":0.015791429999999988},"type":"trend"},"http_req_receiving":{"values":{"med":0.01175,"p(50)":0.01175,"p(95)":0.029833,"p(99)":0.055083419999999994,"max":0.415209,"avg":0.013981669760000148,"min":0.003916},"type":"trend","contains":"time"},"http_req_duration":{"type":"trend","contains":"time","values":{"avg":34.645498809079925,"min":0.031167,"med":33.681042,"p(50)":33.681042,"p(95)":53.1312351,"p(99)":67.13192351000001,"max":141.987959}},"iteration_duration":{"type":"trend","contains":"time","values":{"avg":34.72141181295981,"min":11.669626,"med":33.7446665,"p(50)":33.7446665,"p(95)":53.1991476,"p(99)":67.18759301,"max":142.085625}},"iterations":{"values":{"rate":921.7940396896431,"count":25000},"type":"counter","contains":"default"}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"metrics":{"http_req_duration":{"type":"trend","contains":"time","values":{"avg":35.385882292239785,"min":10.618403,"med":34.40675,"p(50)":34.40675,"p(95)":55.3204077,"p(99)":72.18460273999999,"max":155.463708}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0,"avg":0}},"http_req_receiving":{"contains":"time","values":{"med":0.0115,"p(50)":0.0115,"p(95)":0.028916,"p(99)":0.053583,"max":0.681917,"avg":0.013617796599999997,"min":0.003833},"type":"trend"},"http_reqs":{"values":{"count":25000,"rate":902.4724156970544},"type":"counter","contains":"default"},"data_sent":{"type":"counter","contains":"data","values":{"count":8225000,"rate":296913.4247643309}},"http_req_blocked":{"type":"trend","contains":"time","values":{"min":0.000416,"med":0.000834,"p(50)":0.000834,"p(95)":0.001667,"p(99)":0.002709,"max":0.879584,"avg":0.0013724688399999946}},"vus":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"http_req_sending":{"type":"trend","contains":"time","values":{"p(99)":0.013458,"max":0.296709,"avg":0.003964239359999882,"min":0.001708,"med":0.00325,"p(50)":0.00325,"p(95)":0.007458}},"http_req_duration{expected_response:true}":{"type":"trend","contains":"time","values":{"p(99)":72.18460273999999,"max":155.463708,"avg":35.385882292239785,"min":10.618403,"med":34.40675,"p(50)":34.40675,"p(95)":55.3204077},"thresholds":{"max>=0":{"ok":true}}},"http_req_waiting":{"contains":"time","values":{"min":10.598861,"med":34.387854000000004,"p(50)":34.387854000000004,"p(95)":55.30658989999999,"p(99)":72.17459633999998,"max":155.448458,"avg":35.36830025628003},"type":"trend"},"data_received":{"type":"counter","contains":"data","values":{"count":11025000,"rate":397990.335322401}},"iteration_duration":{"type":"trend","contains":"time","values":{"avg":35.43971266919966,"min":11.388416,"med":34.457104,"p(50)":34.457104,"p(95)":55.36586875,"p(99)":72.22578699999998,"max":155.571625}},"iterations":{"values":{"count":25000,"rate":902.4724156970544},"type":"counter","contains":"default"},"http_req_failed":{"contains":"default","values":{"passes":0,"fails":25000,"rate":0},"type":"rate"},"vus_max":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"http_req_connecting":{"type":"trend","contains":"time","values":{"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0.228708,"avg":0.0000933218,"min":0}},"checks":{"values":{"rate":1,"passes":25000,"fails":0},"type":"rate","contains":"default"}},"root_group":{"groups":[],"checks":[{"id":"6445aff337e1ade0bc10402fbac79882","passes":25000,"fails":0,"name":"message 201","path":"::message 201"}],"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e"},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":27701.677708}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"passes":25000,"fails":0,"name":"message 201","path":"::message 201","id":"6445aff337e1ade0bc10402fbac79882"}]},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":27026.71154},"metrics":{"data_sent":{"contains":"data","values":{"count":8225000,"rate":304328.5524332791},"type":"counter"},"http_req_duration{expected_response:true}":{"values":{"med":33.381688,"p(50)":33.381688,"p(95)":51.994275349999995,"p(99)":65.5143145,"max":127.731083,"avg":34.52409949056004,"min":10.979167},"thresholds":{"max>=0":{"ok":true}},"type":"trend","contains":"time"},"http_reqs":{"type":"counter","contains":"default","values":{"rate":925.0107976695414,"count":25000}},"http_req_failed":{"type":"rate","contains":"default","values":{"rate":0,"passes":0,"fails":25000}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0,"avg":0}},"http_req_sending":{"type":"trend","contains":"time","values":{"p(50)":0.003209,"p(95)":0.007708,"p(99)":0.01645841999999999,"max":0.21825,"avg":0.0041172855999998675,"min":0.001666,"med":0.003209}},"http_req_waiting":{"type":"trend","contains":"time","values":{"med":33.363729,"p(50)":33.363729,"p(95)":51.9780795,"p(99)":65.49594167,"max":127.474083,"avg":34.50602191863986,"min":10.962958}},"checks":{"contains":"default","values":{"rate":1,"passes":25000,"fails":0},"type":"rate"},"http_req_receiving":{"type":"trend","contains":"time","values":{"avg":0.013960286320000048,"min":0.003791,"med":0.0115,"p(50)":0.0115,"p(95)":0.030252049999999954,"p(99)":0.058167,"max":0.835875}},"data_received":{"type":"counter","contains":"data","values":{"count":11025000,"rate":407929.76177226775}},"http_req_connecting":{"type":"trend","contains":"time","values":{"avg":0.00019667652,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0.309791}},"vus_max":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"http_req_duration":{"type":"trend","contains":"time","values":{"max":127.731083,"avg":34.52409949056004,"min":10.979167,"med":33.381688,"p(50)":33.381688,"p(95)":51.994275349999995,"p(99)":65.5143145}},"http_req_blocked":{"type":"trend","contains":"time","values":{"p(50)":0.000875,"p(95)":0.001708,"p(99)":0.00329101,"max":2.720084,"avg":0.0018867026799998393,"min":0.000416,"med":0.000875}},"iterations":{"type":"counter","contains":"default","values":{"rate":925.0107976695414,"count":25000}},"vus":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"iteration_duration":{"contains":"time","values":{"avg":34.577157200599856,"min":11.022375,"med":33.430854,"p(50)":33.430854,"p(95)":52.06892979999999,"p(99)":65.55444733,"max":128.51725},"type":"trend"}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"groups":[],"checks":[{"name":"message 201","path":"::message 201","id":"6445aff337e1ade0bc10402fbac79882","passes":25000,"fails":0}],"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e"},"options":{"summaryTimeUnit":"","noColor":true,"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"]},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":27167.521416},"metrics":{"http_req_blocked":{"type":"trend","contains":"time","values":{"p(99)":0.003417409999999991,"max":1.586333,"avg":0.002295717919999652,"min":0.000416,"med":0.000875,"p(50)":0.000875,"p(95)":0.00175}},"http_req_waiting":{"type":"trend","contains":"time","values":{"med":33.697874999999996,"p(50)":33.697874999999996,"p(95)":52.430581249999996,"p(99)":66.40927925000001,"max":114.332959,"avg":34.68453677492014,"min":10.790875}},"data_sent":{"type":"counter","contains":"data","values":{"count":8225000,"rate":302751.2106848283}},"http_req_duration{expected_response:true}":{"values":{"min":10.800417,"med":33.7175835,"p(50)":33.7175835,"p(95)":52.44686074999999,"p(99)":66.42251825,"max":114.897042,"avg":34.70317513156005},"thresholds":{"max>=0":{"ok":true}},"type":"trend","contains":"time"},"http_req_sending":{"type":"trend","contains":"time","values":{"max":0.790291,"avg":0.00434393843999989,"min":0.001666,"med":0.00325,"p(50)":0.00325,"p(95)":0.00775,"p(99)":0.01729241999999999}},"checks":{"type":"rate","contains":"default","values":{"rate":1,"passes":25000,"fails":0}},"vus":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"http_req_receiving":{"contains":"time","values":{"min":0.004,"med":0.011584,"p(50)":0.011584,"p(95)":0.030919049999999955,"p(99)":0.06162540999999999,"max":0.342583,"avg":0.014294418200000002},"type":"trend"},"http_req_duration":{"values":{"med":33.7175835,"p(50)":33.7175835,"p(95)":52.44686074999999,"p(99)":66.42251825,"max":114.897042,"avg":34.70317513156005,"min":10.800417},"type":"trend","contains":"time"},"iterations":{"type":"counter","contains":"default","values":{"rate":920.2164458505418,"count":25000}},"data_received":{"type":"counter","contains":"data","values":{"count":11025000,"rate":405815.45262008894}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"max":0,"avg":0,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0}},"iteration_duration":{"type":"trend","contains":"time","values":{"p(99)":66.46285216999999,"max":116.67975,"avg":34.75707143287996,"min":10.84025,"med":33.7684585,"p(50)":33.7684585,"p(95)":52.5007955}},"http_req_failed":{"values":{"rate":0,"passes":0,"fails":25000},"type":"rate","contains":"default"},"vus_max":{"values":{"min":32,"max":32,"value":32},"type":"gauge","contains":"default"},"http_req_connecting":{"values":{"max":0.50225,"avg":0.00014771512000000004,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0},"type":"trend","contains":"time"},"http_reqs":{"type":"counter","contains":"default","values":{"rate":920.2164458505418,"count":25000}}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"name":"message 201","path":"::message 201","id":"6445aff337e1ade0bc10402fbac79882","passes":25000,"fails":0}]},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":27186.686082},"metrics":{"http_req_receiving":{"type":"trend","contains":"time","values":{"avg":0.014216877760000118,"min":0.003875,"med":0.0116665,"p(50)":0.0116665,"p(95)":0.031208,"p(99)":0.058833010000000005,"max":0.331667}},"checks":{"type":"rate","contains":"default","values":{"rate":1,"passes":25000,"fails":0}},"iteration_duration":{"type":"trend","contains":"time","values":{"med":33.890041499999995,"p(50)":33.890041499999995,"p(95)":52.40305834999999,"p(99)":64.40324691,"max":133.791875,"avg":34.78069919939989,"min":11.014584}},"http_req_connecting":{"contains":"time","values":{"p(95)":0,"p(99)":0,"max":0.749291,"avg":0.00009975484,"min":0,"med":0,"p(50)":0},"type":"trend"},"http_req_waiting":{"type":"trend","contains":"time","values":{"avg":34.70990444363989,"min":10.762708,"med":33.818208,"p(50)":33.818208,"p(95)":52.32698394999999,"p(99)":64.32076065999999,"max":133.0695}},"http_req_duration{expected_response:true}":{"type":"trend","contains":"time","values":{"p(50)":33.835333500000004,"p(95)":52.35255384999999,"p(99)":64.33273190999999,"max":133.0905,"avg":34.72831147035997,"min":10.912291,"med":33.835333500000004},"thresholds":{"max>=0":{"ok":true}}},"vus":{"contains":"default","values":{"max":32,"value":32,"min":32},"type":"gauge"},"http_reqs":{"type":"counter","contains":"default","values":{"rate":919.5677591816612,"count":25000}},"http_req_sending":{"type":"trend","contains":"time","values":{"med":0.00325,"p(50)":0.00325,"p(95)":0.007875,"p(99)":0.01666601,"max":0.374084,"avg":0.004190148959999853,"min":0.001667}},"http_req_duration":{"type":"trend","contains":"time","values":{"p(95)":52.35255384999999,"p(99)":64.33273190999999,"max":133.0905,"avg":34.72831147035997,"min":10.912291,"med":33.835333500000004,"p(50)":33.835333500000004}},"iterations":{"type":"counter","contains":"default","values":{"count":25000,"rate":919.5677591816612}},"vus_max":{"values":{"value":32,"min":32,"max":32},"type":"gauge","contains":"default"},"http_req_failed":{"type":"rate","contains":"default","values":{"rate":0,"passes":0,"fails":25000}},"data_received":{"type":"counter","contains":"data","values":{"count":11025000,"rate":405529.38179911266}},"http_req_blocked":{"type":"trend","contains":"time","values":{"p(95)":0.00175,"p(99)":0.00325,"max":1.171667,"avg":0.0018091675999998512,"min":0.000416,"med":0.000875,"p(50)":0.000875}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"p(50)":0,"p(95)":0,"p(99)":0,"max":0,"avg":0,"min":0,"med":0}},"data_sent":{"type":"counter","contains":"data","values":{"rate":302537.79277076654,"count":8225000}}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"name":"message 201","path":"::message 201","id":"6445aff337e1ade0bc10402fbac79882","passes":25000,"fails":0}]},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":27048.791207},"metrics":{"checks":{"type":"rate","contains":"default","values":{"passes":25000,"fails":0,"rate":1}},"http_req_duration":{"type":"trend","contains":"time","values":{"med":33.4529165,"p(50)":33.4529165,"p(95)":52.026033299999995,"p(99)":66.03262759,"max":118.281042,"avg":34.55263125128009,"min":10.124292}},"iteration_duration":{"type":"trend","contains":"time","values":{"avg":34.60486019259999,"min":10.160834,"med":33.5073335,"p(50)":33.5073335,"p(95)":52.091213149999994,"p(99)":66.07774283,"max":118.942708}},"http_req_waiting":{"contains":"time","values":{"min":10.107709,"med":33.4343335,"p(50)":33.4343335,"p(95)":52.01158749999999,"p(99)":66.02061983,"max":118.206333,"avg":34.534483632759915},"type":"trend"},"vus_max":{"values":{"min":32,"max":32,"value":32},"type":"gauge","contains":"default"},"http_req_receiving":{"type":"trend","contains":"time","values":{"p(99)":0.06020883999999998,"max":0.32075,"avg":0.014090006800000273,"min":0.003917,"med":0.011667,"p(50)":0.011667,"p(95)":0.0305}},"data_received":{"type":"counter","contains":"data","values":{"count":11025000,"rate":407596.77264789643}},"data_sent":{"type":"counter","contains":"data","values":{"count":8225000,"rate":304080.1319754148}},"iterations":{"type":"counter","contains":"default","values":{"count":25000,"rate":924.2557202900147}},"http_req_blocked":{"type":"trend","contains":"time","values":{"min":0.000416,"med":0.000875,"p(50)":0.000875,"p(95)":0.001667,"p(99)":0.003541,"max":0.823292,"avg":0.0018194096799998363}},"http_req_connecting":{"values":{"avg":0.00032549839999999994,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0.414708},"type":"trend","contains":"time"},"http_reqs":{"type":"counter","contains":"default","values":{"count":25000,"rate":924.2557202900147}},"http_req_failed":{"type":"rate","contains":"default","values":{"rate":0,"passes":0,"fails":25000}},"http_req_duration{expected_response:true}":{"type":"trend","contains":"time","values":{"p(95)":52.026033299999995,"p(99)":66.03262759,"max":118.281042,"avg":34.55263125128009,"min":10.124292,"med":33.4529165,"p(50)":33.4529165},"thresholds":{"max>=0":{"ok":true}}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"avg":0,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0}},"vus":{"type":"gauge","contains":"default","values":{"min":32,"max":32,"value":32}},"http_req_sending":{"values":{"med":0.003208,"p(50)":0.003208,"p(95)":0.007583,"p(99)":0.0165,"max":0.472459,"avg":0.0040576117199998775,"min":0.001625},"type":"trend","contains":"time"}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":27233.835138},"metrics":{"iterations":{"type":"counter","contains":"default","values":{"count":25000,"rate":917.9757413276296}},"http_req_connecting":{"type":"trend","contains":"time","values":{"p(99)":0,"max":0.629917,"avg":0.00024665995999999994,"min":0,"med":0,"p(50)":0,"p(95)":0}},"http_req_sending":{"type":"trend","contains":"time","values":{"min":0.001667,"med":0.00325,"p(50)":0.00325,"p(95)":0.007708,"p(99)":0.01720841999999999,"max":2.93325,"avg":0.0043519730399999125}},"data_sent":{"type":"counter","contains":"data","values":{"count":8225000,"rate":302014.01889679016}},"data_received":{"values":{"count":11025000,"rate":404827.3019254847},"type":"counter","contains":"data"},"http_reqs":{"type":"counter","contains":"default","values":{"count":25000,"rate":917.9757413276296}},"vus_max":{"type":"gauge","contains":"default","values":{"max":32,"value":32,"min":32}},"vus":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"iteration_duration":{"type":"trend","contains":"time","values":{"p(99)":68.52848608,"max":114.782625,"avg":34.841497958319835,"min":10.746458,"med":33.667833,"p(50)":33.667833,"p(95)":53.1301806}},"http_req_duration":{"type":"trend","contains":"time","values":{"med":33.6192085,"p(50)":33.6192085,"p(95)":53.08015864999999,"p(99)":68.42129266999999,"max":113.570666,"avg":34.78845215635987,"min":10.710084}},"checks":{"type":"rate","contains":"default","values":{"rate":1,"passes":25000,"fails":0}},"http_req_blocked":{"type":"trend","contains":"time","values":{"max":1.173791,"avg":0.002055131279999733,"min":0.000416,"med":0.000875,"p(50)":0.000875,"p(95)":0.00175,"p(99)":0.003292}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0,"avg":0,"min":0}},"http_req_receiving":{"type":"trend","contains":"time","values":{"p(99)":0.05979183999999998,"max":0.354375,"avg":0.01418914648000009,"min":0.003959,"med":0.011708,"p(50)":0.011708,"p(95)":0.0305}},"http_req_duration{expected_response:true}":{"type":"trend","contains":"time","values":{"max":113.570666,"avg":34.78845215635987,"min":10.710084,"med":33.6192085,"p(50)":33.6192085,"p(95)":53.08015864999999,"p(99)":68.42129266999999},"thresholds":{"max>=0":{"ok":true}}},"http_req_waiting":{"type":"trend","contains":"time","values":{"p(95)":53.04597114999999,"p(99)":68.41254523999999,"max":113.526917,"avg":34.76991103684003,"min":10.70025,"med":33.597708499999996,"p(50)":33.597708499999996}},"http_req_failed":{"type":"rate","contains":"default","values":{"rate":0,"passes":0,"fails":25000}}},"root_group":{"checks":[{"name":"message 201","path":"::message 201","id":"6445aff337e1ade0bc10402fbac79882","passes":25000,"fails":0}],"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[]},"options":{"noColor":true,"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":""}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"checks":[{"passes":25000,"fails":0,"name":"message 201","path":"::message 201","id":"6445aff337e1ade0bc10402fbac79882"}],"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[]},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":26800.479874},"metrics":{"http_reqs":{"values":{"rate":932.8191180730796,"count":25000},"type":"counter","contains":"default"},"data_sent":{"contains":"data","values":{"count":8225000,"rate":306897.4898460432},"type":"counter"},"http_req_duration":{"type":"trend","contains":"time","values":{"avg":34.23637276472001,"min":10.971958,"med":33.082916499999996,"p(50)":33.082916499999996,"p(95)":51.80705594999999,"p(99)":65.09967916999999,"max":130.390208}},"vus":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"http_req_duration{expected_response:true}":{"type":"trend","contains":"time","values":{"p(95)":51.80705594999999,"p(99)":65.09967916999999,"max":130.390208,"avg":34.23637276472001,"min":10.971958,"med":33.082916499999996,"p(50)":33.082916499999996},"thresholds":{"max>=0":{"ok":true}}},"data_received":{"contains":"data","values":{"count":11025000,"rate":411373.2310702281},"type":"counter"},"http_req_blocked":{"type":"trend","contains":"time","values":{"p(50)":0.000834,"p(95)":0.001625,"p(99)":0.003,"max":1.09175,"avg":0.001846308239999814,"min":0.000416,"med":0.000834}},"iteration_duration":{"type":"trend","contains":"time","values":{"p(95)":51.871245849999994,"p(99)":65.14055573999998,"max":130.777291,"avg":34.28759745280002,"min":11.020542,"med":33.128541999999996,"p(50)":33.128541999999996}},"http_req_receiving":{"type":"trend","contains":"time","values":{"med":0.011417,"p(50)":0.011417,"p(95)":0.028669049999999956,"p(99)":0.057044079999999955,"max":0.356959,"avg":0.01361545824000005,"min":0.004041}},"iterations":{"contains":"default","values":{"count":25000,"rate":932.8191180730796},"type":"counter"},"http_req_connecting":{"type":"trend","contains":"time","values":{"p(95)":0,"p(99)":0,"max":0.190167,"avg":0.00009434347999999998,"min":0,"med":0,"p(50)":0}},"http_req_failed":{"type":"rate","contains":"default","values":{"rate":0,"passes":0,"fails":25000}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"max":0,"avg":0,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0}},"http_req_waiting":{"type":"trend","contains":"time","values":{"p(99)":65.07631032999998,"max":130.370708,"avg":34.21881865931985,"min":10.953083,"med":33.063625,"p(50)":33.063625,"p(95)":51.78282915}},"checks":{"type":"rate","contains":"default","values":{"rate":1,"passes":25000,"fails":0}},"vus_max":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"http_req_sending":{"type":"trend","contains":"time","values":{"avg":0.003938647159999876,"min":0.001625,"med":0.003166,"p(50)":0.003166,"p(95)":0.007375,"p(99)":0.016125,"max":0.198166}}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"checks":[{"name":"message 201","path":"::message 201","id":"6445aff337e1ade0bc10402fbac79882","passes":25000,"fails":0}],"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[]},"options":{"summaryTimeUnit":"","noColor":true,"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"]},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":26733.074373},"metrics":{"http_req_duration{expected_response:true}":{"type":"trend","contains":"time","values":{"p(50)":33.0417085,"p(95)":51.89379614999999,"p(99)":68.12627907999999,"max":152.376709,"avg":34.14847172971995,"min":10.88625,"med":33.0417085},"thresholds":{"max>=0":{"ok":true}}},"http_req_connecting":{"type":"trend","contains":"time","values":{"max":0.109375,"avg":0.00007146496000000002,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"p(50)":0,"p(95)":0,"p(99)":0,"max":0,"avg":0,"min":0,"med":0}},"vus_max":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"checks":{"type":"rate","contains":"default","values":{"fails":0,"rate":1,"passes":25000}},"http_reqs":{"type":"counter","contains":"default","values":{"count":25000,"rate":935.1711535748249}},"http_req_failed":{"type":"rate","contains":"default","values":{"passes":0,"fails":25000,"rate":0}},"data_sent":{"type":"counter","contains":"data","values":{"count":8225000,"rate":307671.3095261174}},"iteration_duration":{"type":"trend","contains":"time","values":{"p(95)":51.94682115,"p(99)":68.1739425,"max":152.427917,"avg":34.19982515100005,"min":10.926959,"med":33.0920625,"p(50)":33.0920625}},"http_req_duration":{"type":"trend","contains":"time","values":{"avg":34.14847172971995,"min":10.88625,"med":33.0417085,"p(50)":33.0417085,"p(95)":51.89379614999999,"p(99)":68.12627907999999,"max":152.376709}},"vus":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"http_req_blocked":{"type":"trend","contains":"time","values":{"avg":0.0023405267999996064,"min":0.000416,"med":0.000834,"p(50)":0.000834,"p(95)":0.001625,"p(99)":0.00316601,"max":1.522458}},"http_req_waiting":{"values":{"avg":34.13089821820005,"min":10.870833,"med":33.023979499999996,"p(50)":33.023979499999996,"p(95)":51.86927354999999,"p(99)":68.11330608,"max":152.358791},"type":"trend","contains":"time"},"http_req_sending":{"type":"trend","contains":"time","values":{"max":0.203791,"avg":0.003896064959999876,"min":0.001666,"med":0.003167,"p(50)":0.003167,"p(95)":0.007167,"p(99)":0.01475}},"http_req_receiving":{"type":"trend","contains":"time","values":{"avg":0.013677446560000103,"min":0.003916,"med":0.011458,"p(50)":0.011458,"p(95)":0.028419049999999956,"p(99)":0.056167419999999996,"max":1.536875}},"data_received":{"type":"counter","contains":"data","values":{"count":11025000,"rate":412410.4787264978}},"iterations":{"type":"counter","contains":"default","values":{"count":25000,"rate":935.1711535748249}}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"groups":[],"checks":[{"path":"::message 201","id":"6445aff337e1ade0bc10402fbac79882","passes":25000,"fails":0,"name":"message 201"}],"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e"},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":26808.555582},"metrics":{"http_req_blocked":{"type":"trend","contains":"time","values":{"avg":0.0020614081999997037,"min":0.000416,"med":0.000834,"p(50)":0.000834,"p(95)":0.001625,"p(99)":0.00320801,"max":1.394667}},"http_req_sending":{"type":"trend","contains":"time","values":{"avg":0.003967335999999896,"min":0.001708,"med":0.003125,"p(50)":0.003125,"p(95)":0.007375,"p(99)":0.016,"max":1.059584}},"vus_max":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"http_req_failed":{"contains":"default","values":{"rate":0,"passes":0,"fails":25000},"type":"rate"},"iteration_duration":{"values":{"p(99)":65.26246115999997,"max":128.524125,"avg":34.29641619119998,"min":10.771167,"med":33.2108955,"p(50)":33.2108955,"p(95)":51.563606249999985},"type":"trend","contains":"time"},"checks":{"type":"rate","contains":"default","values":{"rate":1,"passes":25000,"fails":0}},"iterations":{"type":"counter","contains":"default","values":{"rate":932.5381191661697,"count":25000}},"vus":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"http_req_receiving":{"contains":"time","values":{"avg":0.013698492560000018,"min":0.004,"med":0.011417,"p(50)":0.011417,"p(95)":0.02921214999999991,"p(99)":0.056666419999999995,"max":0.474917},"type":"trend"},"http_req_tls_handshaking":{"values":{"avg":0,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0},"type":"trend","contains":"time"},"http_req_waiting":{"type":"trend","contains":"time","values":{"min":10.674709,"med":33.143479,"p(50)":33.143479,"p(95)":51.48077885,"p(99)":65.19552516999998,"max":128.341958,"avg":34.2269536944801}},"http_req_duration{expected_response:true}":{"values":{"avg":34.24461952303997,"min":10.704042,"med":33.160333,"p(50)":33.160333,"p(95)":51.49614025,"p(99)":65.21346174999998,"max":128.389125},"thresholds":{"max>=0":{"ok":true}},"type":"trend","contains":"time"},"http_req_duration":{"contains":"time","values":{"p(99)":65.21346174999998,"max":128.389125,"avg":34.24461952303997,"min":10.704042,"med":33.160333,"p(50)":33.160333,"p(95)":51.49614025},"type":"trend"},"data_sent":{"type":"counter","contains":"data","values":{"count":8225000,"rate":306805.0412056698}},"http_req_connecting":{"type":"trend","contains":"time","values":{"avg":0.00011473668000000001,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0.208708}},"data_received":{"type":"counter","contains":"data","values":{"count":11025000,"rate":411249.31055228086}},"http_reqs":{"contains":"default","values":{"count":25000,"rate":932.5381191661697},"type":"counter"}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"path":"::message 201","id":"6445aff337e1ade0bc10402fbac79882","passes":25000,"fails":0,"name":"message 201"}]},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"testRunDurationMs":26599.398082,"isStdOutTTY":false,"isStdErrTTY":false},"metrics":{"iteration_duration":{"contains":"time","values":{"avg":34.026423105160134,"min":11.430125,"med":32.9326875,"p(50)":32.9326875,"p(95)":51.36052919999998,"p(99)":64.55224601,"max":124.342958},"type":"trend"},"http_req_blocked":{"type":"trend","contains":"time","values":{"avg":0.002211016119999635,"min":0.000416,"med":0.000834,"p(50)":0.000834,"p(95)":0.001625,"p(99)":0.0030830099999999997,"max":2.1465}},"checks":{"type":"rate","contains":"default","values":{"fails":0,"rate":1,"passes":25000}},"vus":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"vus_max":{"type":"gauge","contains":"default","values":{"max":32,"value":32,"min":32}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"avg":0,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0}},"http_req_connecting":{"type":"trend","contains":"time","values":{"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0.403416,"avg":0.00009130840000000002,"min":0}},"http_req_failed":{"contains":"default","values":{"passes":0,"fails":25000,"rate":0},"type":"rate"},"http_req_duration{expected_response:true}":{"type":"trend","contains":"time","values":{"p(99)":64.50538551,"max":122.747458,"avg":33.97547401840007,"min":11.380833,"med":32.8855,"p(50)":32.8855,"p(95)":51.3185226},"thresholds":{"max>=0":{"ok":true}}},"http_reqs":{"values":{"count":25000,"rate":939.870891925095},"type":"counter","contains":"default"},"http_req_waiting":{"type":"trend","contains":"time","values":{"p(99)":64.48721008999999,"max":122.730791,"avg":33.95744333147986,"min":11.361291,"med":32.86625,"p(50)":32.86625,"p(95)":51.294149699999984}},"data_received":{"type":"counter","contains":"data","values":{"count":11025000,"rate":414483.06333896687}},"http_req_duration":{"type":"trend","contains":"time","values":{"avg":33.97547401840007,"min":11.380833,"med":32.8855,"p(50)":32.8855,"p(95)":51.3185226,"p(99)":64.50538551,"max":122.747458}},"http_req_receiving":{"type":"trend","contains":"time","values":{"avg":0.013560601679999956,"min":0.003834,"med":0.011417,"p(50)":0.011417,"p(95)":0.028833,"p(99)":0.05441740999999999,"max":0.281125}},"iterations":{"values":{"count":25000,"rate":939.870891925095},"type":"counter","contains":"default"},"http_req_sending":{"type":"trend","contains":"time","values":{"med":0.003167,"p(50)":0.003167,"p(95)":0.007294049999999955,"p(99)":0.01525,"max":1.535208,"avg":0.004470085239999874,"min":0.001666}},"data_sent":{"values":{"rate":309217.5234433562,"count":8225000},"type":"counter","contains":"data"}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":27039.875207},"metrics":{"http_reqs":{"contains":"default","values":{"count":25000,"rate":924.5604799806205},"type":"counter"},"data_sent":{"type":"counter","contains":"data","values":{"count":8225000,"rate":304180.3979136241}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"avg":0,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0}},"data_received":{"type":"counter","contains":"data","values":{"count":11025000,"rate":407731.17167145363}},"vus":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"http_req_blocked":{"type":"trend","contains":"time","values":{"min":0.000417,"med":0.000875,"p(50)":0.000875,"p(95)":0.00175,"p(99)":0.003000409999999991,"max":1.048916,"avg":0.001936188199999783}},"http_req_sending":{"type":"trend","contains":"time","values":{"p(95)":0.007708,"p(99)":0.015416009999999999,"max":0.28625,"avg":0.004081474919999871,"min":0.001709,"med":0.00325,"p(50)":0.00325}},"http_req_duration{expected_response:true}":{"type":"trend","contains":"time","values":{"max":110.652709,"avg":34.54013370740021,"min":10.588666,"med":33.374958500000005,"p(50)":33.374958500000005,"p(95)":51.75599555,"p(99)":64.43164349999999},"thresholds":{"max>=0":{"ok":true}}},"http_req_connecting":{"contains":"time","values":{"p(99)":0,"max":0.27975,"avg":0.00013810012,"min":0,"med":0,"p(50)":0,"p(95)":0},"type":"trend"},"iteration_duration":{"values":{"avg":34.593345097920135,"min":10.632208,"med":33.422854,"p(50)":33.422854,"p(95)":51.79925659999999,"p(99)":64.47615133999999,"max":111.843},"type":"trend","contains":"time"},"vus_max":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"iterations":{"values":{"count":25000,"rate":924.5604799806205},"type":"counter","contains":"default"},"http_req_duration":{"type":"trend","contains":"time","values":{"avg":34.54013370740021,"min":10.588666,"med":33.374958500000005,"p(50)":33.374958500000005,"p(95)":51.75599555,"p(99)":64.43164349999999,"max":110.652709}},"http_req_failed":{"type":"rate","contains":"default","values":{"rate":0,"passes":0,"fails":25000}},"checks":{"type":"rate","contains":"default","values":{"rate":1,"passes":25000,"fails":0}},"http_req_waiting":{"type":"trend","contains":"time","values":{"avg":34.52163738280002,"min":10.573917,"med":33.3577915,"p(50)":33.3577915,"p(95)":51.72953124999999,"p(99)":64.42038608,"max":110.629167}},"http_req_receiving":{"type":"trend","contains":"time","values":{"p(99)":0.062,"max":0.886083,"avg":0.014414849680000204,"min":0.003916,"med":0.011792,"p(50)":0.011792,"p(95)":0.031585099999999956}}},"root_group":{"checks":[{"name":"message 201","path":"::message 201","id":"6445aff337e1ade0bc10402fbac79882","passes":25000,"fails":0}],"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[]}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"path":"::message 201","id":"6445aff337e1ade0bc10402fbac79882","passes":25000,"fails":0,"name":"message 201"}]},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdErrTTY":false,"testRunDurationMs":26732.487832,"isStdOutTTY":false},"metrics":{"checks":{"values":{"rate":1,"passes":25000,"fails":0},"type":"rate","contains":"default"},"data_sent":{"type":"counter","contains":"data","values":{"count":8225000,"rate":307678.0601824235}},"http_req_receiving":{"type":"trend","contains":"time","values":{"avg":0.013627145960000041,"min":0.003917,"med":0.011375,"p(50)":0.011375,"p(95)":0.028833,"p(99)":0.057917409999999996,"max":0.298333}},"http_req_connecting":{"type":"trend","contains":"time","values":{"max":0.276584,"avg":0.00014710664,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0}},"data_received":{"contains":"data","values":{"rate":412419.5274785677,"count":11025000},"type":"counter"},"http_reqs":{"type":"counter","contains":"default","values":{"count":25000,"rate":935.1916722870016}},"http_req_blocked":{"type":"trend","contains":"time","values":{"p(50)":0.000834,"p(95)":0.001625,"p(99)":0.00279101,"max":0.688333,"avg":0.0016719139599998746,"min":0.000416,"med":0.000834}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"avg":0,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0}},"http_req_sending":{"type":"trend","contains":"time","values":{"avg":0.003964896039999868,"min":0.001708,"med":0.003125,"p(50)":0.003125,"p(95)":0.007291,"p(99)":0.015293509999999944,"max":0.420917}},"http_req_waiting":{"type":"trend","contains":"time","values":{"med":33.0556455,"p(50)":33.0556455,"p(95)":51.68845209999999,"p(99)":65.17948249999999,"max":137.039375,"avg":34.13262099224018,"min":10.39875}},"http_req_failed":{"type":"rate","contains":"default","values":{"passes":0,"fails":25000,"rate":0}},"vus":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"http_req_duration{expected_response:true}":{"values":{"p(95)":51.70963539999999,"p(99)":65.22360976,"max":137.090667,"avg":34.15021303423974,"min":10.416167,"med":33.0742085,"p(50)":33.0742085},"thresholds":{"max>=0":{"ok":true}},"type":"trend","contains":"time"},"iteration_duration":{"type":"trend","contains":"time","values":{"med":33.122521,"p(50)":33.122521,"p(95)":51.76815145,"p(99)":65.26816466999998,"max":137.876541,"avg":34.20069826923986,"min":10.452625}},"iterations":{"type":"counter","contains":"default","values":{"count":25000,"rate":935.1916722870016}},"vus_max":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"http_req_duration":{"type":"trend","contains":"time","values":{"p(99)":65.22360976,"max":137.090667,"avg":34.15021303423974,"min":10.416167,"med":33.0742085,"p(50)":33.0742085,"p(95)":51.70963539999999}}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"fails":0,"name":"message 201","path":"::message 201","id":"6445aff337e1ade0bc10402fbac79882","passes":25000}]},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":27088.04554},"metrics":{"http_req_failed":{"type":"rate","contains":"default","values":{"rate":0,"passes":0,"fails":25000}},"vus":{"type":"gauge","contains":"default","values":{"max":32,"value":32,"min":32}},"http_req_blocked":{"contains":"time","values":{"max":1.881625,"avg":0.0017018137999998675,"min":0.000416,"med":0.000875,"p(50)":0.000875,"p(95)":0.001708,"p(99)":0.003167},"type":"trend"},"http_req_waiting":{"type":"trend","contains":"time","values":{"min":10.3615,"med":33.539417,"p(50)":33.539417,"p(95)":52.62749824999999,"p(99)":67.0187275,"max":108.2175,"avg":34.58344398359985}},"http_req_sending":{"type":"trend","contains":"time","values":{"avg":0.004348626039999895,"min":0.001584,"med":0.00325,"p(50)":0.00325,"p(95)":0.007584,"p(99)":0.01533301,"max":1.533542}},"http_req_connecting":{"type":"trend","contains":"time","values":{"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0.418625,"avg":0.00008262675999999999,"min":0}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0,"avg":0,"min":0}},"checks":{"values":{"rate":1,"passes":25000,"fails":0},"type":"rate","contains":"default"},"data_sent":{"type":"counter","contains":"data","values":{"count":8225000,"rate":303639.47771183494}},"iteration_duration":{"type":"trend","contains":"time","values":{"p(95)":52.71222674999999,"p(99)":67.10763824,"max":109.946875,"avg":34.654468356879974,"min":10.415708,"med":33.6112495,"p(50)":33.6112495}},"vus_max":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"http_req_duration{expected_response:true}":{"type":"trend","contains":"time","values":{"avg":34.60180767343975,"min":10.373833,"med":33.5595625,"p(50)":33.5595625,"p(95)":52.647095849999985,"p(99)":67.05201959,"max":108.233625},"thresholds":{"max>=0":{"ok":true}}},"http_req_duration":{"type":"trend","contains":"time","values":{"p(95)":52.647095849999985,"p(99)":67.05201959,"max":108.233625,"avg":34.60180767343975,"min":10.373833,"med":33.5595625,"p(50)":33.5595625}},"iterations":{"type":"counter","contains":"default","values":{"count":25000,"rate":922.9163456286776}},"data_received":{"contains":"data","values":{"count":11025000,"rate":407006.1084222468},"type":"counter"},"http_reqs":{"type":"counter","contains":"default","values":{"count":25000,"rate":922.9163456286776}},"http_req_receiving":{"values":{"p(99)":0.05791766999999996,"max":0.381208,"avg":0.014015063800000114,"min":0.003875,"med":0.011583,"p(50)":0.011583,"p(95)":0.030667},"type":"trend","contains":"time"}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":26827.839624},"metrics":{"http_req_receiving":{"type":"trend","contains":"time","values":{"avg":0.013601474440000061,"min":0.003875,"med":0.011375,"p(50)":0.011375,"p(95)":0.02895805,"p(99)":0.056667409999999994,"max":0.298833}},"http_req_connecting":{"type":"trend","contains":"time","values":{"p(99)":0,"max":0.112125,"avg":0.00006441643999999999,"min":0,"med":0,"p(50)":0,"p(95)":0}},"checks":{"type":"rate","contains":"default","values":{"rate":1,"passes":25000,"fails":0}},"iteration_duration":{"contains":"time","values":{"p(99)":67.10827625,"max":114.99425,"avg":34.32151821807999,"min":10.493,"med":33.1004165,"p(50)":33.1004165,"p(95)":52.49323955},"type":"trend"},"http_reqs":{"values":{"rate":931.8678041311673,"count":25000},"type":"counter","contains":"default"},"http_req_sending":{"type":"trend","contains":"time","values":{"avg":0.004048323719999879,"min":0.001583,"med":0.003125,"p(50)":0.003125,"p(95)":0.007375,"p(99)":0.01504101,"max":0.851417}},"http_req_duration":{"contains":"time","values":{"avg":34.27065413743991,"min":10.455458,"med":33.0539165,"p(50)":33.0539165,"p(95)":52.43462739999998,"p(99)":67.0536025,"max":114.850583},"type":"trend"},"http_req_waiting":{"type":"trend","contains":"time","values":{"med":33.0382915,"p(50)":33.0382915,"p(95)":52.417268750000005,"p(99)":67.03343582999999,"max":114.8305,"avg":34.25300433927995,"min":10.438833}},"data_received":{"type":"counter","contains":"data","values":{"rate":410953.7016218448,"count":11025000}},"data_sent":{"type":"counter","contains":"data","values":{"count":8225000,"rate":306584.50755915407}},"http_req_duration{expected_response:true}":{"thresholds":{"max>=0":{"ok":true}},"type":"trend","contains":"time","values":{"avg":34.27065413743991,"min":10.455458,"med":33.0539165,"p(50)":33.0539165,"p(95)":52.43462739999998,"p(99)":67.0536025,"max":114.850583}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"avg":0,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0}},"iterations":{"type":"counter","contains":"default","values":{"count":25000,"rate":931.8678041311673}},"vus_max":{"values":{"value":32,"min":32,"max":32},"type":"gauge","contains":"default"},"http_req_failed":{"values":{"rate":0,"passes":0,"fails":25000},"type":"rate","contains":"default"},"vus":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"http_req_blocked":{"type":"trend","contains":"time","values":{"min":0.000416,"med":0.000834,"p(50)":0.000834,"p(95)":0.001667,"p(99)":0.003125,"max":0.807042,"avg":0.0014121834399999918}}},"root_group":{"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"fails":0,"name":"message 201","path":"::message 201","id":"6445aff337e1ade0bc10402fbac79882","passes":25000}]},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"name":"message 201","path":"::message 201","id":"6445aff337e1ade0bc10402fbac79882","passes":25000,"fails":0}]},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":26860.002749},"metrics":{"http_req_waiting":{"type":"trend","contains":"time","values":{"max":129.986083,"avg":34.293263900439975,"min":10.6265,"med":33.0247085,"p(50)":33.0247085,"p(95)":51.68550239999999,"p(99)":65.68925226}},"http_req_receiving":{"type":"trend","contains":"time","values":{"avg":0.013827207280000009,"min":0.003917,"med":0.011458,"p(50)":0.011458,"p(95)":0.029667,"p(99)":0.05904491999999993,"max":0.364792}},"http_req_failed":{"type":"rate","contains":"default","values":{"rate":0,"passes":0,"fails":25000}},"http_req_connecting":{"type":"trend","contains":"time","values":{"max":0.343167,"avg":0.0001384568,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0}},"iterations":{"type":"counter","contains":"default","values":{"count":25000,"rate":930.7519523962354}},"http_req_duration{expected_response:true}":{"values":{"min":10.639125,"med":33.040667,"p(50)":33.040667,"p(95)":51.69845029999998,"p(99)":65.69855233,"max":130.022041,"avg":34.31119166208001},"thresholds":{"max>=0":{"ok":true}},"type":"trend","contains":"time"},"data_received":{"values":{"count":11025000,"rate":410461.61100673984},"type":"counter","contains":"data"},"iteration_duration":{"contains":"time","values":{"p(99)":65.75682458,"max":131.252334,"avg":34.36279860431987,"min":10.674042,"med":33.0905205,"p(50)":33.0905205,"p(95)":51.75843809999999},"type":"trend"},"vus_max":{"values":{"value":32,"min":32,"max":32},"type":"gauge","contains":"default"},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0,"avg":0,"min":0}},"http_reqs":{"values":{"rate":930.7519523962354,"count":25000},"type":"counter","contains":"default"},"http_req_sending":{"type":"trend","contains":"time","values":{"p(99)":0.016376249999999974,"max":0.500667,"avg":0.004100554359999878,"min":0.001708,"med":0.003125,"p(50)":0.003125,"p(95)":0.007333}},"vus":{"values":{"value":32,"min":32,"max":32},"type":"gauge","contains":"default"},"data_sent":{"type":"counter","contains":"data","values":{"count":8225000,"rate":306217.3923383615}},"http_req_blocked":{"type":"trend","contains":"time","values":{"max":1.509584,"avg":0.002219815599999643,"min":0.000416,"med":0.000834,"p(50)":0.000834,"p(95)":0.001666,"p(99)":0.003042409999999991}},"checks":{"type":"rate","contains":"default","values":{"rate":1,"passes":25000,"fails":0}},"http_req_duration":{"type":"trend","contains":"time","values":{"p(50)":33.040667,"p(95)":51.69845029999998,"p(99)":65.69855233,"max":130.022041,"avg":34.31119166208001,"min":10.639125,"med":33.040667}}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"id":"6445aff337e1ade0bc10402fbac79882","passes":25000,"fails":0,"name":"message 201","path":"::message 201"}]},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":26667.597804},"metrics":{"http_req_sending":{"values":{"max":0.482417,"avg":0.004012655239999853,"min":0.001625,"med":0.003166,"p(50)":0.003166,"p(95)":0.007292,"p(99)":0.015542829999999981},"type":"trend","contains":"time"},"http_req_receiving":{"type":"trend","contains":"time","values":{"avg":0.013492650879999981,"min":0.003875,"med":0.011417,"p(50)":0.011417,"p(95)":0.028,"p(99)":0.05496049999999995,"max":0.304958}},"data_sent":{"type":"counter","contains":"data","values":{"rate":308426.73046337505,"count":8225000}},"iterations":{"type":"counter","contains":"default","values":{"rate":937.4672658461247,"count":25000}},"vus":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"vus_max":{"type":"gauge","contains":"default","values":{"max":32,"value":32,"min":32}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0,"avg":0,"min":0}},"iteration_duration":{"contains":"time","values":{"avg":34.109214798600114,"min":10.614708,"med":32.9959375,"p(50)":32.9959375,"p(95)":51.75654435,"p(99)":66.19562117,"max":116.091375},"type":"trend"},"http_req_duration":{"type":"trend","contains":"time","values":{"min":10.576292,"med":32.9478955,"p(50)":32.9478955,"p(95)":51.697870849999994,"p(99)":66.14791941,"max":115.28975,"avg":34.057748541399874}},"checks":{"values":{"fails":0,"rate":1,"passes":25000},"type":"rate","contains":"default"},"data_received":{"values":{"count":11025000,"rate":413423.064238141},"type":"counter","contains":"data"},"http_reqs":{"type":"counter","contains":"default","values":{"count":25000,"rate":937.4672658461247}},"http_req_connecting":{"type":"trend","contains":"time","values":{"p(99)":0,"max":0.341833,"avg":0.00013388668,"min":0,"med":0,"p(50)":0,"p(95)":0}},"http_req_failed":{"type":"rate","contains":"default","values":{"rate":0,"passes":0,"fails":25000}},"http_req_blocked":{"contains":"time","values":{"p(99)":0.0031254099999999912,"max":1.34725,"avg":0.002131338719999711,"min":0.000416,"med":0.000834,"p(50)":0.000834,"p(95)":0.001667},"type":"trend"},"http_req_duration{expected_response:true}":{"type":"trend","contains":"time","values":{"max":115.28975,"avg":34.057748541399874,"min":10.576292,"med":32.9478955,"p(50)":32.9478955,"p(95)":51.697870849999994,"p(99)":66.14791941},"thresholds":{"max>=0":{"ok":true}}},"http_req_waiting":{"type":"trend","contains":"time","values":{"med":32.931583,"p(50)":32.931583,"p(95)":51.682083999999996,"p(99)":66.13198374999999,"max":115.028541,"avg":34.040243235280386,"min":10.566333}}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"fails":0,"name":"message 201","path":"::message 201","id":"6445aff337e1ade0bc10402fbac79882","passes":25000}]},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":26858.441596},"metrics":{"data_received":{"values":{"rate":410485.46918083075,"count":11025000},"type":"counter","contains":"data"},"checks":{"values":{"rate":1,"passes":25000,"fails":0},"type":"rate","contains":"default"},"data_sent":{"contains":"data","values":{"count":8225000,"rate":306235.19129363564},"type":"counter"},"http_req_failed":{"type":"rate","contains":"default","values":{"rate":0,"passes":0,"fails":25000}},"http_reqs":{"values":{"count":25000,"rate":930.806052564242},"type":"counter","contains":"default"},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0,"avg":0,"min":0}},"http_req_sending":{"type":"trend","contains":"time","values":{"med":0.003167,"p(50)":0.003167,"p(95)":0.00725,"p(99)":0.01483301,"max":0.359042,"avg":0.003895200439999918,"min":0.001667}},"http_req_waiting":{"type":"trend","contains":"time","values":{"min":10.899,"med":33.341896,"p(50)":33.341896,"p(95)":52.92476009999999,"p(99)":67.08991316,"max":147.650667,"avg":34.290867745519975}},"iteration_duration":{"type":"trend","contains":"time","values":{"max":147.719626,"avg":34.359636960400046,"min":10.953625,"med":33.4093125,"p(50)":33.4093125,"p(95)":52.996887799999996,"p(99)":67.15219800999999}},"http_req_duration{expected_response:true}":{"thresholds":{"max>=0":{"ok":true}},"type":"trend","contains":"time","values":{"p(95)":52.94277469999999,"p(99)":67.10289341999999,"max":147.667334,"avg":34.30848719583989,"min":10.913833,"med":33.358625,"p(50)":33.358625}},"iterations":{"type":"counter","contains":"default","values":{"count":25000,"rate":930.806052564242}},"http_req_connecting":{"contains":"time","values":{"max":1.320333,"avg":0.00012615172000000002,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0},"type":"trend"},"http_req_receiving":{"values":{"p(95)":0.029292,"p(99)":0.055417259999999975,"max":0.335,"avg":0.01372424987999999,"min":0.003625,"med":0.011625,"p(50)":0.011625},"type":"trend","contains":"time"},"http_req_blocked":{"type":"trend","contains":"time","values":{"avg":0.0017805315599998376,"min":0.000417,"med":0.000834,"p(50)":0.000834,"p(95)":0.001584,"p(99)":0.0027924099999999913,"max":1.395458}},"vus_max":{"type":"gauge","contains":"default","values":{"value":32,"min":32,"max":32}},"http_req_duration":{"type":"trend","contains":"time","values":{"p(95)":52.94277469999999,"p(99)":67.10289341999999,"max":147.667334,"avg":34.30848719583989,"min":10.913833,"med":33.358625,"p(50)":33.358625}},"vus":{"type":"gauge","contains":"default","values":{"max":32,"value":32,"min":32}}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"id":"fad9fa412b86fcb03bee97c80dcd61f1","passes":11479,"fails":0,"name":"status 200","path":"::status 200"},{"path":"::full page","id":"736a4affc4111c8285c374c0b4d25aed","passes":11479,"fails":0,"name":"full page"}]},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":20000.60812},"metrics":{"vus":{"values":{"value":1,"min":1,"max":1},"type":"gauge","contains":"default"},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"avg":0,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0}},"http_req_receiving":{"values":{"min":0.009584,"med":0.015792,"p(50)":0.015792,"p(95)":0.034333,"p(99)":0.05389325999999999,"max":0.266708,"avg":0.018440668699363994},"type":"trend","contains":"time"},"http_req_failed":{"type":"rate","contains":"default","values":{"rate":0,"passes":0,"fails":11479}},"http_req_connecting":{"type":"trend","contains":"time","values":{"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0.146959,"avg":0.000012802421813746843}},"vus_max":{"type":"gauge","contains":"default","values":{"value":1,"min":1,"max":1}},"http_req_sending":{"type":"trend","contains":"time","values":{"med":0.002542,"p(50)":0.002542,"p(95)":0.004958,"p(99)":0.00920822,"max":0.107333,"avg":0.0029381705723494547,"min":0.001583}},"data_sent":{"type":"counter","contains":"data","values":{"count":4890054,"rate":244495.26587694575}},"http_req_waiting":{"values":{"avg":1.6600083628364761,"min":1.344584,"med":1.612208,"p(50)":1.612208,"p(95)":1.9274622,"p(99)":2.39279348,"max":17.687583},"type":"trend","contains":"time"},"http_reqs":{"type":"counter","contains":"default","values":{"count":11479,"rate":573.9325490069149}},"iterations":{"values":{"rate":573.9325490069149,"count":11479},"type":"counter","contains":"default"},"iteration_duration":{"type":"trend","contains":"time","values":{"max":17.8105,"avg":1.7395701239655097,"min":1.414792,"med":1.685292,"p(50)":1.685292,"p(95)":2.0383082999999997,"p(99)":2.55353872}},"http_req_duration{expected_response:true}":{"type":"trend","contains":"time","values":{"med":1.631208,"p(50)":1.631208,"p(95)":1.9621665999999998,"p(99)":2.44905178,"max":17.735208,"avg":1.6813872021082035,"min":1.367459},"thresholds":{"max>=0":{"ok":true}}},"http_req_blocked":{"type":"trend","contains":"time","values":{"p(50)":0.000917,"p(95)":0.001708,"p(99)":0.002625,"max":0.708459,"avg":0.0011219303075181014,"min":0.0005,"med":0.000917}},"http_req_duration":{"type":"trend","contains":"time","values":{"p(95)":1.9621665999999998,"p(99)":2.44905178,"max":17.735208,"avg":1.6813872021082035,"min":1.367459,"med":1.631208,"p(50)":1.631208}},"checks":{"values":{"rate":1,"passes":22958,"fails":0},"type":"rate","contains":"default"},"data_received":{"contains":"data","values":{"count":155310870,"rate":7765307.388063559},"type":"counter"}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"name":"status 200","path":"::status 200","id":"fad9fa412b86fcb03bee97c80dcd61f1","passes":11671,"fails":0},{"fails":0,"name":"full page","path":"::full page","id":"736a4affc4111c8285c374c0b4d25aed","passes":11671}],"name":""},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"testRunDurationMs":20001.500454,"isStdOutTTY":false,"isStdErrTTY":false},"metrics":{"http_req_waiting":{"type":"trend","contains":"time","values":{"avg":1.6337604720246828,"min":1.372166,"med":1.592542,"p(50)":1.592542,"p(95)":1.8617914999999994,"p(99)":2.3227045,"max":18.581125}},"vus_max":{"type":"gauge","contains":"default","values":{"max":1,"value":1,"min":1}},"http_req_sending":{"values":{"min":0.001541,"med":0.0025,"p(50)":0.0025,"p(95)":0.004708499999999999,"p(99)":0.009625,"max":0.177292,"avg":0.002935807043098226},"type":"trend","contains":"time"},"http_reqs":{"type":"counter","contains":"default","values":{"count":11671,"rate":583.5062237876247}},"data_received":{"type":"counter","contains":"data","values":{"count":157908630,"rate":7894839.207846562}},"http_req_blocked":{"type":"trend","contains":"time","values":{"p(99)":0.002334,"max":0.525083,"avg":0.0010628418301773894,"min":0.000458,"med":0.000875,"p(50)":0.000875,"p(95)":0.001625}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"p(95)":0,"p(99)":0,"max":0,"avg":0,"min":0,"med":0,"p(50)":0}},"http_req_receiving":{"values":{"p(50)":0.015416,"p(95)":0.031792,"p(99)":0.049795599999999975,"max":0.354625,"avg":0.01769007882786399,"min":0.008709,"med":0.015416},"type":"trend","contains":"time"},"http_req_connecting":{"type":"trend","contains":"time","values":{"p(99)":0,"max":0.115708,"avg":0.000009914146174278126,"min":0,"med":0,"p(50)":0,"p(95)":0}},"http_req_failed":{"contains":"default","values":{"rate":0,"passes":0,"fails":11671},"type":"rate"},"http_req_duration":{"type":"trend","contains":"time","values":{"p(50)":1.610916,"p(95)":1.8914169999999995,"p(99)":2.3658792999999996,"max":18.637417,"avg":1.654386357895632,"min":1.388167,"med":1.610916}},"vus":{"type":"gauge","contains":"default","values":{"value":1,"min":1,"max":1}},"checks":{"type":"rate","contains":"default","values":{"rate":1,"passes":23342,"fails":0}},"data_sent":{"type":"counter","contains":"data","values":{"count":4971846,"rate":248573.6513335281}},"iterations":{"values":{"count":11671,"rate":583.5062237876247},"type":"counter","contains":"default"},"http_req_duration{expected_response:true}":{"thresholds":{"max>=0":{"ok":true}},"type":"trend","contains":"time","values":{"avg":1.654386357895632,"min":1.388167,"med":1.610916,"p(50)":1.610916,"p(95)":1.8914169999999995,"p(99)":2.3658792999999996,"max":18.637417}},"iteration_duration":{"type":"trend","contains":"time","values":{"avg":1.7110078428583515,"min":1.432916,"med":1.6635,"p(50)":1.6635,"p(95)":1.9713124999999998,"p(99)":2.4694078999999993,"max":18.739334}}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"passes":11625,"fails":0,"name":"status 200","path":"::status 200","id":"fad9fa412b86fcb03bee97c80dcd61f1"},{"path":"::full page","id":"736a4affc4111c8285c374c0b4d25aed","passes":11625,"fails":0,"name":"full page"}]},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":20000.587162},"metrics":{"http_req_sending":{"contains":"time","values":{"med":0.0025,"p(50)":0.0025,"p(95)":0.004792,"p(99)":0.009417,"max":0.236417,"avg":0.0029006348387096183,"min":0.001541},"type":"trend"},"iterations":{"type":"counter","contains":"default","values":{"count":11625,"rate":581.2329361053386}},"http_req_receiving":{"values":{"p(95)":0.03386659999999998,"p(99)":0.05420876,"max":0.265042,"avg":0.018307978236559126,"min":0.010084,"med":0.015833,"p(50)":0.015833},"type":"trend","contains":"time"},"vus_max":{"type":"gauge","contains":"default","values":{"value":1,"min":1,"max":1}},"http_req_duration{expected_response:true}":{"type":"trend","contains":"time","values":{"avg":1.6596308941935456,"min":1.3545,"med":1.616584,"p(50)":1.616584,"p(95)":1.8981,"p(99)":2.4030799999999997,"max":6.345166},"thresholds":{"max>=0":{"ok":true}}},"http_req_duration":{"type":"trend","contains":"time","values":{"max":6.345166,"avg":1.6596308941935456,"min":1.3545,"med":1.616584,"p(50)":1.616584,"p(95)":1.8981,"p(99)":2.4030799999999997}},"data_received":{"type":"counter","contains":"data","values":{"count":157286250,"rate":7864081.62550523}},"iteration_duration":{"values":{"p(99)":2.51387808,"max":6.555709,"avg":1.7177073316129068,"min":1.40175,"med":1.670583,"p(50)":1.670583,"p(95)":1.9779164},"type":"trend","contains":"time"},"http_req_blocked":{"type":"trend","contains":"time","values":{"avg":0.00113661849462368,"min":0.0005,"med":0.000917,"p(50)":0.000917,"p(95)":0.001625,"p(99)":0.002458,"max":0.700958}},"http_req_failed":{"type":"rate","contains":"default","values":{"rate":0,"passes":0,"fails":11625}},"checks":{"type":"rate","contains":"default","values":{"rate":1,"passes":23250,"fails":0}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"avg":0,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0}},"data_sent":{"type":"counter","contains":"data","values":{"count":4952250,"rate":247605.23078087423}},"http_reqs":{"type":"counter","contains":"default","values":{"count":11625,"rate":581.2329361053386}},"http_req_waiting":{"contains":"time","values":{"p(95)":1.8659329999999996,"p(99)":2.3556330799999996,"max":6.281292,"avg":1.638422281118279,"min":1.338125,"med":1.597583,"p(50)":1.597583},"type":"trend"},"vus":{"type":"gauge","contains":"default","values":{"value":1,"min":1,"max":1}},"http_req_connecting":{"values":{"p(99)":0,"max":0.092,"avg":0.000007913978494623655,"min":0,"med":0,"p(50)":0,"p(95)":0},"type":"trend","contains":"time"}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"testRunDurationMs":20009.250162,"isStdOutTTY":false,"isStdErrTTY":false},"metrics":{"http_req_duration{expected_response:true}":{"values":{"avg":13.20199208349359,"min":6.937875,"med":12.600791,"p(50)":12.600791,"p(95)":17.223371399999998,"p(99)":31.276239479999994,"max":58.123792},"thresholds":{"max>=0":{"ok":true}},"type":"trend","contains":"time"},"http_req_receiving":{"type":"trend","contains":"time","values":{"min":0.00525,"med":0.016083,"p(50)":0.016083,"p(95)":0.03779519999999997,"p(99)":0.08570373999999997,"max":1.706917,"avg":0.019935992373499526}},"data_received":{"type":"counter","contains":"data","values":{"count":204018870,"rate":10196227.662116827}},"vus":{"type":"gauge","contains":"default","values":{"value":10,"min":10,"max":10}},"iterations":{"type":"counter","contains":"default","values":{"rate":753.6014532237123,"count":15079}},"iteration_duration":{"type":"trend","contains":"time","values":{"p(50)":12.661583,"p(95)":17.303941999999996,"p(99)":31.334376999999993,"max":58.2125,"avg":13.263813910604235,"min":7.269875,"med":12.661583}},"http_req_failed":{"type":"rate","contains":"default","values":{"fails":15079,"rate":0,"passes":0}},"http_req_duration":{"values":{"med":12.600791,"p(50)":12.600791,"p(95)":17.223371399999998,"p(99)":31.276239479999994,"max":58.123792,"avg":13.20199208349359,"min":6.937875},"type":"trend","contains":"time"},"http_req_blocked":{"contains":"time","values":{"max":0.740458,"avg":0.001412567544266913,"min":0.000417,"med":0.000875,"p(50)":0.000875,"p(95)":0.00175,"p(99)":0.003},"type":"trend"},"http_req_waiting":{"type":"trend","contains":"time","values":{"p(50)":12.578208,"p(95)":17.197066,"p(99)":31.226175979999997,"max":58.088916,"avg":13.178821175077836,"min":6.818583,"med":12.578208}},"data_sent":{"type":"counter","contains":"data","values":{"count":6423654,"rate":321034.2190733014}},"vus_max":{"type":"gauge","contains":"default","values":{"value":10,"min":10,"max":10}},"http_req_sending":{"values":{"avg":0.0032349160421777726,"min":0.001459,"med":0.002667,"p(50)":0.002667,"p(95)":0.005583,"p(99)":0.011833,"max":0.148416},"type":"trend","contains":"time"},"checks":{"type":"rate","contains":"default","values":{"rate":1,"passes":30158,"fails":0}},"http_req_tls_handshaking":{"values":{"p(50)":0,"p(95)":0,"p(99)":0,"max":0,"avg":0,"min":0,"med":0},"type":"trend","contains":"time"},"http_req_connecting":{"contains":"time","values":{"p(95)":0,"p(99)":0,"max":0.119,"avg":0.0000475578619271835,"min":0,"med":0,"p(50)":0},"type":"trend"},"http_reqs":{"type":"counter","contains":"default","values":{"count":15079,"rate":753.6014532237123}}},"root_group":{"checks":[{"name":"status 200","path":"::status 200","id":"fad9fa412b86fcb03bee97c80dcd61f1","passes":15079,"fails":0},{"id":"736a4affc4111c8285c374c0b4d25aed","passes":15079,"fails":0,"name":"full page","path":"::full page"}],"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[]}}
|
||||
@@ -0,0 +1 @@
|
||||
{"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":20009.181343},"metrics":{"data_sent":{"values":{"count":6467106,"rate":323206.92631747515},"type":"counter","contains":"data"},"http_req_blocked":{"type":"trend","contains":"time","values":{"p(50)":0.000834,"p(95)":0.001667,"p(99)":0.003058599999999989,"max":1.091625,"avg":0.0016592789671300207,"min":0.000458,"med":0.000834}},"iteration_duration":{"values":{"min":7.378667,"med":12.465209,"p(50)":12.465209,"p(95)":17.292834,"p(99)":30.854783199999996,"max":58.457875,"avg":13.175233771227129},"type":"trend","contains":"time"},"http_req_connecting":{"contains":"time","values":{"avg":0.00009556353336407351,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0.282167},"type":"trend"},"vus":{"type":"gauge","contains":"default","values":{"max":10,"value":10,"min":10}},"http_req_receiving":{"type":"trend","contains":"time","values":{"p(50)":0.015625,"p(95)":0.037042,"p(99)":0.0704664,"max":0.750334,"avg":0.01868800520387325,"min":0.005125,"med":0.015625}},"iterations":{"type":"counter","contains":"default","values":{"rate":758.7017049705989,"count":15181}},"http_req_failed":{"type":"rate","contains":"default","values":{"rate":0,"passes":0,"fails":15181}},"http_req_duration":{"type":"trend","contains":"time","values":{"p(50)":12.404459,"p(95)":17.208458,"p(99)":30.796557999999997,"max":58.389542,"avg":13.11459931210068,"min":7.33675,"med":12.404459}},"http_reqs":{"type":"counter","contains":"default","values":{"count":15181,"rate":758.7017049705989}},"http_req_waiting":{"type":"trend","contains":"time","values":{"p(99)":30.7818748,"max":58.3605,"avg":13.092762321059233,"min":7.324709,"med":12.381833,"p(50)":12.381833,"p(95)":17.18475}},"data_received":{"type":"counter","contains":"data","values":{"count":205398930,"rate":10265234.068252204}},"vus_max":{"type":"gauge","contains":"default","values":{"value":10,"min":10,"max":10}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0,"avg":0}},"http_req_sending":{"type":"trend","contains":"time","values":{"avg":0.00314898583756003,"min":0.001583,"med":0.002584,"p(50)":0.002584,"p(95)":0.005541,"p(99)":0.011717199999999995,"max":0.218708}},"http_req_duration{expected_response:true}":{"thresholds":{"max>=0":{"ok":true}},"type":"trend","contains":"time","values":{"avg":13.11459931210068,"min":7.33675,"med":12.404459,"p(50)":12.404459,"p(95)":17.208458,"p(99)":30.796557999999997,"max":58.389542}},"checks":{"type":"rate","contains":"default","values":{"rate":1,"passes":30362,"fails":0}}},"root_group":{"id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"name":"status 200","path":"::status 200","id":"fad9fa412b86fcb03bee97c80dcd61f1","passes":15181,"fails":0},{"passes":15181,"fails":0,"name":"full page","path":"::full page","id":"736a4affc4111c8285c374c0b4d25aed"}],"name":"","path":""}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"name":"status 200","path":"::status 200","id":"fad9fa412b86fcb03bee97c80dcd61f1","passes":15115,"fails":0},{"passes":15115,"fails":0,"name":"full page","path":"::full page","id":"736a4affc4111c8285c374c0b4d25aed"}]},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":20009.323051},"metrics":{"iteration_duration":{"type":"trend","contains":"time","values":{"avg":13.232276243400548,"min":7.18325,"med":12.526625,"p(50)":12.526625,"p(95)":17.269470399999992,"p(99)":31.270204999999994,"max":56.180333}},"http_req_duration":{"values":{"avg":13.171817221568034,"min":7.133459,"med":12.466125,"p(50)":12.466125,"p(95)":17.201420499999998,"p(99)":31.204462239999998,"max":56.068917},"type":"trend","contains":"time"},"iterations":{"values":{"count":15115,"rate":755.3978693569347},"type":"counter","contains":"default"},"data_sent":{"type":"counter","contains":"data","values":{"count":6438990,"rate":321799.4923460542}},"vus":{"contains":"default","values":{"value":10,"min":10,"max":10},"type":"gauge"},"vus_max":{"type":"gauge","contains":"default","values":{"value":10,"min":10,"max":10}},"http_req_sending":{"values":{"min":0.0015,"med":0.002625,"p(50)":0.002625,"p(95)":0.00525,"p(99)":0.011083,"max":0.242125,"avg":0.0031764060866687955},"type":"trend","contains":"time"},"http_req_failed":{"type":"rate","contains":"default","values":{"rate":0,"passes":0,"fails":15115}},"data_received":{"type":"counter","contains":"data","values":{"count":204505950,"rate":10220533.172399327}},"checks":{"type":"rate","contains":"default","values":{"rate":1,"passes":30230,"fails":0}},"http_reqs":{"contains":"default","values":{"count":15115,"rate":755.3978693569347},"type":"counter"},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"avg":0,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0}},"http_req_duration{expected_response:true}":{"values":{"avg":13.171817221568034,"min":7.133459,"med":12.466125,"p(50)":12.466125,"p(95)":17.201420499999998,"p(99)":31.204462239999998,"max":56.068917},"thresholds":{"max>=0":{"ok":true}},"type":"trend","contains":"time"},"http_req_connecting":{"type":"trend","contains":"time","values":{"p(50)":0,"p(95)":0,"p(99)":0,"max":0.3135,"avg":0.00014742269268938144,"min":0,"med":0}},"http_req_blocked":{"type":"trend","contains":"time","values":{"p(95)":0.001666,"p(99)":0.0026191199999999943,"max":0.683875,"avg":0.0013880764141581692,"min":0.000417,"med":0.000834,"p(50)":0.000834}},"http_req_receiving":{"type":"trend","contains":"time","values":{"avg":0.018715511875620355,"min":0.005041,"med":0.015792,"p(50)":0.015792,"p(95)":0.0365,"p(99)":0.06625,"max":0.402709}},"http_req_waiting":{"type":"trend","contains":"time","values":{"max":56.036167,"avg":13.149925303605805,"min":7.122541,"med":12.446667,"p(50)":12.446667,"p(95)":17.164446499999997,"p(99)":31.186828379999998}}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"checks":[{"name":"status 200","path":"::status 200","id":"fad9fa412b86fcb03bee97c80dcd61f1","passes":14623,"fails":0},{"name":"full page","path":"::full page","id":"736a4affc4111c8285c374c0b4d25aed","passes":14623,"fails":0}],"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[]},"options":{"noColor":true,"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":""},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":20046.203037},"metrics":{"data_sent":{"type":"counter","contains":"data","values":{"count":6229398,"rate":310752.0156561407}},"vus":{"type":"gauge","contains":"default","values":{"value":50,"min":50,"max":50}},"http_req_duration":{"type":"trend","contains":"time","values":{"p(95)":127.64289609999997,"p(99)":176.20697052,"max":343.689208,"avg":68.3953124343842,"min":10.256958,"med":64.777042,"p(50)":64.777042}},"http_req_duration{expected_response:true}":{"thresholds":{"max>=0":{"ok":true}},"type":"trend","contains":"time","values":{"med":64.777042,"p(50)":64.777042,"p(95)":127.64289609999997,"p(99)":176.20697052,"max":343.689208,"avg":68.3953124343842,"min":10.256958}},"data_received":{"type":"counter","contains":"data","values":{"count":197849190,"rate":9869659.088797145}},"http_req_connecting":{"contains":"time","values":{"avg":0.00040150789851603637,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0.676709},"type":"trend"},"http_req_receiving":{"type":"trend","contains":"time","values":{"min":0.005541,"med":0.016708,"p(50)":0.016708,"p(95)":0.039625,"p(99)":0.06781075999999997,"max":0.463958,"avg":0.01966190214046372}},"http_req_failed":{"type":"rate","contains":"default","values":{"rate":0,"passes":0,"fails":14623}},"checks":{"type":"rate","contains":"default","values":{"rate":1,"passes":29246,"fails":0}},"iterations":{"type":"counter","contains":"default","values":{"count":14623,"rate":729.4648254838984}},"vus_max":{"type":"gauge","contains":"default","values":{"value":50,"min":50,"max":50}},"http_reqs":{"type":"counter","contains":"default","values":{"count":14623,"rate":729.4648254838984}},"http_req_blocked":{"type":"trend","contains":"time","values":{"p(99)":0.004073979999999994,"max":2.410125,"avg":0.002662752444778628,"min":0.000416,"med":0.000875,"p(50)":0.000875,"p(95)":0.00175}},"http_req_sending":{"type":"trend","contains":"time","values":{"max":0.452625,"avg":0.003485022772344847,"min":0.001583,"med":0.002792,"p(50)":0.002792,"p(95)":0.005875,"p(99)":0.011740979999999995}},"http_req_waiting":{"type":"trend","contains":"time","values":{"max":343.672792,"avg":68.37216550947159,"min":10.234833,"med":64.758166,"p(50)":64.758166,"p(95)":127.59834099999998,"p(99)":176.1857545}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"avg":0,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0}},"iteration_duration":{"type":"trend","contains":"time","values":{"p(99)":176.27573347999999,"max":343.768125,"avg":68.45997885269784,"min":10.313,"med":64.835833,"p(50)":64.835833,"p(95)":127.70509589999999}}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"name":"status 200","path":"::status 200","id":"fad9fa412b86fcb03bee97c80dcd61f1","passes":14478,"fails":0},{"path":"::full page","id":"736a4affc4111c8285c374c0b4d25aed","passes":14478,"fails":0,"name":"full page"}],"name":""},"options":{"summaryTimeUnit":"","noColor":true,"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"]},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":20048.614745},"metrics":{"http_req_duration{expected_response:true}":{"type":"trend","contains":"time","values":{"avg":69.08989414173232,"min":10.535,"med":65.56174949999999,"p(50)":65.56174949999999,"p(95)":121.87324195,"p(99)":168.32731575,"max":373.128292},"thresholds":{"max>=0":{"ok":true}}},"checks":{"type":"rate","contains":"default","values":{"passes":28956,"fails":0,"rate":1}},"iteration_duration":{"contains":"time","values":{"p(95)":121.94505805,"p(99)":168.40350159000002,"max":373.2025,"avg":69.1574177689599,"min":10.612458,"med":65.6247085,"p(50)":65.6247085},"type":"trend"},"http_req_blocked":{"type":"trend","contains":"time","values":{"avg":0.004322159897775554,"min":0.000416,"med":0.000916,"p(50)":0.000916,"p(95)":0.001833,"p(99)":0.003467659999999995,"max":1.339708}},"http_req_sending":{"contains":"time","values":{"med":0.002834,"p(50)":0.002834,"p(95)":0.006458,"p(99)":0.012084,"max":0.300875,"avg":0.0035419903992263166,"min":0.0015},"type":"trend"},"http_req_waiting":{"type":"trend","contains":"time","values":{"avg":69.06648556430484,"min":10.498333,"med":65.54110449999999,"p(50)":65.54110449999999,"p(95)":121.84905275,"p(99)":168.29742356999998,"max":373.099167}},"vus":{"type":"gauge","contains":"default","values":{"value":50,"min":50,"max":50}},"http_reqs":{"contains":"default","values":{"count":14478,"rate":722.1446560845669},"type":"counter"},"http_req_connecting":{"type":"trend","contains":"time","values":{"p(99)":0,"max":0.324875,"avg":0.0002889383202099738,"min":0,"med":0,"p(50)":0,"p(95)":0}},"data_sent":{"type":"counter","contains":"data","values":{"count":6167628,"rate":307633.6234920255}},"vus_max":{"contains":"default","values":{"value":50,"min":50,"max":50},"type":"gauge"},"http_req_failed":{"type":"rate","contains":"default","values":{"rate":0,"passes":0,"fails":14478}},"http_req_duration":{"type":"trend","contains":"time","values":{"max":373.128292,"avg":69.08989414173232,"min":10.535,"med":65.56174949999999,"p(50)":65.56174949999999,"p(95)":121.87324195,"p(99)":168.32731575}},"http_req_receiving":{"type":"trend","contains":"time","values":{"p(99)":0.07301931999999998,"max":0.285792,"avg":0.019866587028595086,"min":0.00575,"med":0.01675,"p(50)":0.01675,"p(95)":0.041}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"max":0,"avg":0,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0}},"data_received":{"values":{"rate":9770617.19682419,"count":195887340},"type":"counter","contains":"data"},"iterations":{"type":"counter","contains":"default","values":{"count":14478,"rate":722.1446560845669}}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"name":"status 200","path":"::status 200","id":"fad9fa412b86fcb03bee97c80dcd61f1","passes":14568,"fails":0},{"passes":14568,"fails":0,"name":"full page","path":"::full page","id":"736a4affc4111c8285c374c0b4d25aed"}]},"options":{"summaryTimeUnit":"","noColor":true,"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"]},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":20054.718328},"metrics":{"vus":{"type":"gauge","contains":"default","values":{"value":50,"min":50,"max":50}},"iteration_duration":{"contains":"time","values":{"p(95)":124.49262279999996,"p(99)":170.85823803,"max":285.423209,"avg":68.75087723881101,"min":8.814416,"med":65.1681665,"p(50)":65.1681665},"type":"trend"},"http_req_duration":{"type":"trend","contains":"time","values":{"p(50)":65.10889599999999,"p(95)":124.42677049999993,"p(99)":170.76311382999998,"max":285.320542,"avg":68.68597299498883,"min":8.761792,"med":65.10889599999999}},"http_req_sending":{"type":"trend","contains":"time","values":{"avg":0.0034543495332234365,"min":0.001584,"med":0.002792,"p(50)":0.002792,"p(95)":0.006208,"p(99)":0.01331938999999999,"max":0.26975}},"vus_max":{"type":"gauge","contains":"default","values":{"max":50,"value":50,"min":50}},"http_req_waiting":{"type":"trend","contains":"time","values":{"med":65.091354,"p(50)":65.091354,"p(95)":124.40945404999994,"p(99)":170.74323988999998,"max":285.28225,"avg":68.662722514278,"min":8.744041}},"data_sent":{"values":{"count":6205968,"rate":309451.7658388326},"type":"counter","contains":"data"},"http_reqs":{"contains":"default","values":{"count":14568,"rate":726.4125958658042},"type":"counter"},"http_req_connecting":{"type":"trend","contains":"time","values":{"p(99)":0,"max":0.215833,"avg":0.0002200855985722131,"min":0,"med":0,"p(50)":0,"p(95)":0}},"http_req_blocked":{"type":"trend","contains":"time","values":{"max":0.747166,"avg":0.0026451466227346474,"min":0.000417,"med":0.000875,"p(50)":0.000875,"p(95)":0.00175,"p(99)":0.0033888599999999944}},"http_req_receiving":{"type":"trend","contains":"time","values":{"p(99)":0.07245757999999998,"max":0.47325,"avg":0.0197961311779242,"min":0.005834,"med":0.01675,"p(50)":0.01675,"p(95)":0.04008365}},"checks":{"contains":"default","values":{"rate":1,"passes":29136,"fails":0},"type":"rate"},"http_req_duration{expected_response:true}":{"type":"trend","contains":"time","values":{"max":285.320542,"avg":68.68597299498883,"min":8.761792,"med":65.10889599999999,"p(50)":65.10889599999999,"p(95)":124.42677049999993,"p(99)":170.76311382999998},"thresholds":{"max>=0":{"ok":true}}},"http_req_failed":{"type":"rate","contains":"default","values":{"rate":0,"passes":0,"fails":14568}},"iterations":{"type":"counter","contains":"default","values":{"count":14568,"rate":726.4125958658042}},"data_received":{"type":"counter","contains":"data","values":{"count":197105040,"rate":9828362.42206433}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"avg":0,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0}}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"name":"status 200","path":"::status 200","id":"fad9fa412b86fcb03bee97c80dcd61f1","passes":12343,"fails":0},{"path":"::full page","id":"736a4affc4111c8285c374c0b4d25aed","passes":12343,"fails":0,"name":"full page"}]},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":20001.053343},"metrics":{"vus":{"type":"gauge","contains":"default","values":{"value":1,"min":1,"max":1}},"checks":{"type":"rate","contains":"default","values":{"passes":24686,"fails":0,"rate":1}},"http_reqs":{"type":"counter","contains":"default","values":{"count":12343,"rate":617.1174981801557}},"http_req_sending":{"contains":"time","values":{"med":0.002667,"p(50)":0.002667,"p(95)":0.006,"p(99)":0.012024359999999996,"max":0.169083,"avg":0.0033005363363849266,"min":0.001541},"type":"trend"},"http_req_duration":{"values":{"p(50)":1.493583,"p(95)":1.8972332999999992,"p(99)":2.50387514,"max":17.021166,"avg":1.5582381024062248,"min":1.322084,"med":1.493583},"type":"trend","contains":"time"},"http_req_connecting":{"type":"trend","contains":"time","values":{"max":0.085042,"avg":0.000006889897107672365,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0}},"data_received":{"type":"counter","contains":"data","values":{"count":167000790,"rate":8349599.750377507}},"http_req_waiting":{"type":"trend","contains":"time","values":{"p(95)":1.8599128,"p(99)":2.4439636399999993,"max":16.987667,"avg":1.53535239026169,"min":1.305083,"med":1.4735,"p(50)":1.4735}},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0,"avg":0}},"http_req_receiving":{"type":"trend","contains":"time","values":{"avg":0.0195851758081504,"min":0.009875,"med":0.01625,"p(50)":0.01625,"p(95)":0.038167,"p(99)":0.06443699999999998,"max":0.539417}},"iteration_duration":{"contains":"time","values":{"p(50)":1.54675,"p(95)":1.9942377999999992,"p(99)":2.6182117199999992,"max":17.09975,"avg":1.6174639337276167,"min":1.369167,"med":1.54675},"type":"trend"},"http_req_duration{expected_response:true}":{"type":"trend","contains":"time","values":{"min":1.322084,"med":1.493583,"p(50)":1.493583,"p(95)":1.8972332999999992,"p(99)":2.50387514,"max":17.021166,"avg":1.5582381024062248},"thresholds":{"max>=0":{"ok":true}}},"iterations":{"type":"counter","contains":"default","values":{"count":12343,"rate":617.1174981801557}},"vus_max":{"type":"gauge","contains":"default","values":{"min":1,"max":1,"value":1}},"http_req_failed":{"values":{"passes":0,"fails":12343,"rate":0},"type":"rate","contains":"default"},"data_sent":{"contains":"data","values":{"count":5258118,"rate":262892.05422474636},"type":"counter"},"http_req_blocked":{"type":"trend","contains":"time","values":{"min":0.000458,"med":0.000958,"p(50)":0.000958,"p(95)":0.00175,"p(99)":0.002792,"max":0.406583,"avg":0.0011687448756380367}}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":20001.163954},"metrics":{"iteration_duration":{"type":"trend","contains":"time","values":{"med":1.542875,"p(50)":1.542875,"p(95)":1.9337833,"p(99)":2.450854239999999,"max":8.106375,"avg":1.599877635387455,"min":1.36775}},"vus_max":{"contains":"default","values":{"value":1,"min":1,"max":1},"type":"gauge"},"http_reqs":{"type":"counter","contains":"default","values":{"count":12479,"rate":623.9136896582634}},"http_req_duration":{"type":"trend","contains":"time","values":{"med":1.489333,"p(50)":1.489333,"p(95)":1.8472208999999995,"p(99)":2.3413039799999997,"max":7.923375,"avg":1.541809420225967,"min":1.31275}},"http_req_blocked":{"contains":"time","values":{"p(50)":0.000958,"p(95)":0.001708,"p(99)":0.002542,"max":0.731542,"avg":0.0011385226380319212,"min":0.000541,"med":0.000958},"type":"trend"},"http_req_sending":{"values":{"med":0.002625,"p(50)":0.002625,"p(95)":0.005375,"p(99)":0.011208,"max":0.20925,"avg":0.0032729924673450717,"min":0.001541},"type":"trend","contains":"time"},"checks":{"type":"rate","contains":"default","values":{"passes":24958,"fails":0,"rate":1}},"iterations":{"type":"counter","contains":"default","values":{"rate":623.9136896582634,"count":12479}},"data_received":{"type":"counter","contains":"data","values":{"count":168840870,"rate":8441552.221076304}},"http_req_duration{expected_response:true}":{"type":"trend","contains":"time","values":{"min":1.31275,"med":1.489333,"p(50)":1.489333,"p(95)":1.8472208999999995,"p(99)":2.3413039799999997,"max":7.923375,"avg":1.541809420225967},"thresholds":{"max>=0":{"ok":true}}},"data_sent":{"values":{"count":5316054,"rate":265787.2317944202},"type":"counter","contains":"data"},"http_req_failed":{"type":"rate","contains":"default","values":{"fails":12479,"rate":0,"passes":0}},"vus":{"type":"gauge","contains":"default","values":{"value":1,"min":1,"max":1}},"http_req_connecting":{"values":{"p(50)":0,"p(95)":0,"p(99)":0,"max":0.097458,"avg":0.000007809760397467746,"min":0,"med":0},"type":"trend","contains":"time"},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"p(99)":0,"max":0,"avg":0,"min":0,"med":0,"p(50)":0,"p(95)":0}},"http_req_waiting":{"type":"trend","contains":"time","values":{"med":1.46925,"p(50)":1.46925,"p(95)":1.8134749999999995,"p(99)":2.28870224,"max":7.834666,"avg":1.5194975530090569,"min":1.295792}},"http_req_receiving":{"type":"trend","contains":"time","values":{"med":0.01625,"p(50)":0.01625,"p(95)":0.03542529999999995,"p(99)":0.058753979999999977,"max":0.323375,"avg":0.019038874749579382,"min":0.008667}}},"root_group":{"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"id":"fad9fa412b86fcb03bee97c80dcd61f1","passes":12479,"fails":0,"name":"status 200","path":"::status 200"},{"passes":12479,"fails":0,"name":"full page","path":"::full page","id":"736a4affc4111c8285c374c0b4d25aed"}]},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true}}
|
||||
@@ -0,0 +1 @@
|
||||
{"root_group":{"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"name":"status 200","path":"::status 200","id":"fad9fa412b86fcb03bee97c80dcd61f1","passes":12335,"fails":0},{"name":"full page","path":"::full page","id":"736a4affc4111c8285c374c0b4d25aed","passes":12335,"fails":0}]},"options":{"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"],"summaryTimeUnit":"","noColor":true},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":20001.005537},"metrics":{"http_reqs":{"contains":"default","values":{"count":12335,"rate":616.7189933116811},"type":"counter"},"http_req_waiting":{"type":"trend","contains":"time","values":{"min":1.3085,"med":1.494792,"p(50)":1.494792,"p(95)":1.8127917999999998,"p(99)":2.2377572199999998,"max":8.686875,"avg":1.5367747835427634}},"data_sent":{"type":"counter","contains":"data","values":{"rate":262722.29115077615,"count":5254710}},"data_received":{"type":"counter","contains":"data","values":{"count":166892550,"rate":8344207.979507045}},"http_req_duration{expected_response:true}":{"thresholds":{"max>=0":{"ok":true}},"type":"trend","contains":"time","values":{"max":8.783208,"avg":1.5594072935549315,"min":1.325625,"med":1.515208,"p(50)":1.515208,"p(95)":1.8513998999999999,"p(99)":2.29545666}},"http_req_blocked":{"contains":"time","values":{"max":0.402375,"avg":0.001154845966761275,"min":0.000541,"med":0.000958,"p(50)":0.000958,"p(95)":0.001667,"p(99)":0.0026107199999999956},"type":"trend"},"http_req_receiving":{"type":"trend","contains":"time","values":{"avg":0.019426064856100503,"min":0.009959,"med":0.016416,"p(50)":0.016416,"p(95)":0.036125,"p(99)":0.06137199999999995,"max":0.635083}},"vus":{"type":"gauge","contains":"default","values":{"value":1,"min":1,"max":1}},"vus_max":{"type":"gauge","contains":"default","values":{"value":1,"min":1,"max":1}},"http_req_sending":{"type":"trend","contains":"time","values":{"p(95)":0.005375,"p(99)":0.010679779999999991,"max":0.228917,"avg":0.003206445156059928,"min":0.001541,"med":0.002625,"p(50)":0.002625}},"http_req_failed":{"type":"rate","contains":"default","values":{"rate":0,"passes":0,"fails":12335}},"checks":{"type":"rate","contains":"default","values":{"rate":1,"passes":24670,"fails":0}},"http_req_tls_handshaking":{"values":{"avg":0,"min":0,"med":0,"p(50)":0,"p(95)":0,"p(99)":0,"max":0},"type":"trend","contains":"time"},"iterations":{"type":"counter","contains":"default","values":{"count":12335,"rate":616.7189933116811}},"iteration_duration":{"type":"trend","contains":"time","values":{"avg":1.618535253182,"min":1.379166,"med":1.569208,"p(50)":1.569208,"p(95)":1.9353463,"p(99)":2.4061052199999997,"max":8.919125}},"http_req_duration":{"type":"trend","contains":"time","values":{"p(50)":1.515208,"p(95)":1.8513998999999999,"p(99)":2.29545666,"max":8.783208,"avg":1.5594072935549315,"min":1.325625,"med":1.515208}},"http_req_connecting":{"type":"trend","contains":"time","values":{"p(50)":0,"p(95)":0,"p(99)":0,"max":0.093041,"avg":0.00000754284556141062,"min":0,"med":0}}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"metrics":{"http_req_failed":{"type":"rate","contains":"default","values":{"rate":0,"passes":0,"fails":15441}},"iterations":{"type":"counter","contains":"default","values":{"count":15441,"rate":771.7643621375763}},"vus":{"type":"gauge","contains":"default","values":{"value":10,"min":10,"max":10}},"data_received":{"type":"counter","contains":"data","values":{"count":208916730,"rate":10441971.819721408}},"http_req_receiving":{"type":"trend","contains":"time","values":{"avg":0.01982543533449918,"min":0.0055,"med":0.016208,"p(50)":0.016208,"p(95)":0.039833,"p(99)":0.08335019999999999,"max":0.386458}},"iteration_duration":{"type":"trend","contains":"time","values":{"p(99)":31.608108,"max":53.511792,"avg":12.95141350087435,"min":6.295875,"med":12.266917,"p(50)":12.266917,"p(95)":16.952583}},"http_req_duration":{"type":"trend","contains":"time","values":{"p(50)":12.202,"p(95)":16.876458,"p(99)":31.543375,"max":53.452333,"avg":12.890483560455975,"min":6.24525,"med":12.202}},"http_reqs":{"type":"counter","contains":"default","values":{"count":15441,"rate":771.7643621375763}},"checks":{"contains":"default","values":{"rate":1,"passes":30882,"fails":0},"type":"rate"},"http_req_blocked":{"type":"trend","contains":"time","values":{"p(50)":0.000834,"p(95)":0.001708,"p(99)":0.0032915999999999996,"max":0.536625,"avg":0.0013554863674632934,"min":0.000416,"med":0.000834}},"http_req_connecting":{"contains":"time","values":{"p(99)":0,"max":0.185667,"avg":0.00008365714655786543,"min":0,"med":0,"p(50)":0,"p(95)":0},"type":"trend"},"http_req_sending":{"type":"trend","contains":"time","values":{"avg":0.0034850689074541054,"min":0.001542,"med":0.00275,"p(50)":0.00275,"p(95)":0.005959,"p(99)":0.012758799999999989,"max":0.358333}},"http_req_waiting":{"values":{"min":6.221667,"med":12.179083,"p(50)":12.179083,"p(95)":16.84525,"p(99)":31.518191199999997,"max":53.430333,"avg":12.867173056214002},"type":"trend","contains":"time"},"http_req_tls_handshaking":{"type":"trend","contains":"time","values":{"p(99)":0,"max":0,"avg":0,"min":0,"med":0,"p(50)":0,"p(95)":0}},"vus_max":{"type":"gauge","contains":"default","values":{"value":10,"min":10,"max":10}},"data_sent":{"type":"counter","contains":"data","values":{"count":6577866,"rate":328771.6182706075}},"http_req_duration{expected_response:true}":{"type":"trend","contains":"time","values":{"p(95)":16.876458,"p(99)":31.543375,"max":53.452333,"avg":12.890483560455975,"min":6.24525,"med":12.202,"p(50)":12.202},"thresholds":{"max>=0":{"ok":true}}}},"root_group":{"name":"","path":"","id":"d41d8cd98f00b204e9800998ecf8427e","groups":[],"checks":[{"name":"status 200","path":"::status 200","id":"fad9fa412b86fcb03bee97c80dcd61f1","passes":15441,"fails":0},{"name":"full page","path":"::full page","id":"736a4affc4111c8285c374c0b4d25aed","passes":15441,"fails":0}]},"options":{"summaryTimeUnit":"","noColor":true,"summaryTrendStats":["avg","min","med","p(50)","p(95)","p(99)","max"]},"state":{"isStdOutTTY":false,"isStdErrTTY":false,"testRunDurationMs":20007.402204}}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user