tools capa

tools-session-error-audit

Retrospective self-correction miner (sprint 3.97): finds the 'caught mistake -> mechanical fix' shape across the already-indexed, already-redacted session-transcripts corpus, counts it, pairs each error with its narrated fix where one exists, and persists bounded candidates -- never auto-filing anything.

Retrospective self-correction miner (sprint 3.97): finds the 'caught mistake -> mechanical fix' shape across the already-indexed, already-redacted session-transcripts corpus, counts it, pairs each error with its narrated fix where one exists, and persists bounded candidates -- never auto-filing anything.

Tiertools
Roleunclassified (baselined)
Pathcrates/tools/session-error-audit
Edition2021
Targetstools-session-error-audit, tools_session_error_audit, cli_test
Public items17 across 3 modules
Tests20

What it is for

tools-session-error-audit (sprint 3.97): finds the "caught mistake -> mechanical fix" shape retrospectively across the already-indexed, already-redacted session-transcripts corpus. See the sprint doc (docs/userstories/sprint-3.97-session-error-audit.md) for the full design.

Capabilities

AssistantChunk

Row types shared by scan.rs (pure pairing logic) and persist.rs (the

Item
pub struct AssistantChunk

ErrorHit

Row types shared by scan.rs (pure pairing logic) and persist.rs (the

Item
pub struct ErrorHit

PairedCandidate

Row types shared by scan.rs (pure pairing logic) and persist.rs (the

Item
pub struct PairedCandidate

SignalSeed

Row types shared by scan.rs (pure pairing logic) and persist.rs (the

Item
pub struct SignalSeed

persist (other)

US-3.97.1/3.97.2's write side: the error_candidate upsert against

Item
pub const MODULE_NAME: & str
async fn apply_migrations(pool : & PgPool) -> Result <u32, application_core::MigrationError>
async fn status_of(pool : & PgPool, source_ref : & str, chunk_id : Uuid, error_signal : & str,) -> Result <(String, Option <String>), sqlx::Error>

PersistReport

US-3.97.1/3.97.2's write side: the error_candidate upsert against

Item
pub struct PersistReport
async fn upsert_candidates(pool : & PgPool, candidates : & PairedCandidate, vocabulary_version : & str,) -> Result <PersistReport, sqlx::Error>

scan (other)

US-3.97.1/3.97.2: the read-side scan + pairing logic. Pure where

Item
fn parse_signal_seeds(tsv : & str) -> Vec <SignalSeed>
fn find_error_hits(chunks : & AssistantChunk, signals : & SignalSeed) -> Vec <ErrorHit>
fn pair_fixes(errors : & ErrorHit, chunks : & AssistantChunk, fix_signals : & SignalSeed, window : i32,) -> Vec <PairedCandidate>
fn dedup_by_content_hash(chunks : Vec <AssistantChunk>) -> Vec <AssistantChunk>
pub const DEFAULT_CHUNK_LIMIT: i64
async fn latest_indexed_at(pool : & PgPool,) -> Result <Option <chrono::DateTime <chrono::Utc>>, sqlx::Error>

ScanReadError

US-3.97.1/3.97.2: the read-side scan + pairing logic. Pure where

Item
pub enum ScanReadError
async fn load_assistant_chunks(pool : & PgPool, limit : i64,) -> Result <Vec <AssistantChunk>, ScanReadError>

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

tools_session_error_audit

flowchart TD
  n_tools_session_error_audit["tools_session_error_audit"]
  n_tools_session_error_audit --> n_model["model"]
  n_tools_session_error_audit --> n_persist["persist"]
  n_tools_session_error_audit --> n_scan["scan"]

Public surface

`model`

ItemWhat it is
pub struct SignalSeedOne docs/reference/session-error-signals.tsv / session-fix-signals.tsv row: phrase\tcategory\tadded_at\tprovenance
pub struct AssistantChunkOne assistant-role knowledge_chunk row, as read from tools_org_knowledge
pub struct ErrorHitOne error signal hit, before fix-pairing.
pub struct PairedCandidateA ErrorHit plus whatever fix-pairing found (or explicitly didn't -- paired = false is a stored fact, never an omitted row, per US-3.97.2's own AC).

`persist`

ItemWhat it is
pub const MODULE_NAME: & strThis story's own module name in forge_module_migrations (application_core::apply_module_migrations's per-module namespace) -- distinct from sprint 3.96's "org-knowledge-corpus"/ "infrastructure-knowledge-index" modules in the SAME shared forge_corpus_source database.
async fn apply_migrations(pool : & PgPool) -> Result <u32, application_core::MigrationError>Apply this story's own migration into pool (already the forge_corpus_source connection)
pub struct PersistReportWhat one scan run's persistence pass did.
async fn upsert_candidates(pool : & PgPool, candidates : & PairedCandidate, vocabulary_version : & str,) -> Result <PersistReport, sqlx::Error>Upsert every paired candidate into error_candidate, one transaction (Gate 1.5.6 §4: any per-row error rolls the WHOLE batch back, same contract as sprint 3.96's corpus ingest commands)
async fn status_of(pool : & PgPool, source_ref : & str, chunk_id : Uuid, error_signal : & str,) -> Result <(String, Option <String>), sqlx::Error>Read one candidate's (status, filed_as) back -- used by tests (and stats) to prove a rescan never clobbers a human-reviewed row

`scan`

ItemWhat it is
fn parse_signal_seeds(tsv : & str) -> Vec <SignalSeed>Parse phrase\tcategory\tadded_at\tprovenance rows (#-prefixed and blank lines skipped) -- same shape/skip rules as sprint 3.96's docs/reference/*.tsv seed-file parsers (ontology.rs::parse_vocabulary, edges.rs::parse_capability_index_crates)
fn find_error_hits(chunks : & AssistantChunk, signals : & SignalSeed) -> Vec <ErrorHit>Case-insensitive substring match of every seed phrase against every chunk
fn pair_fixes(errors : & ErrorHit, chunks : & AssistantChunk, fix_signals : & SignalSeed, window : i32,) -> Vec <PairedCandidate>For each error hit, search the SAME source_ref's chunks with turn_index in (error.turn_index, error.turn_index + window] (a fix narration comes AFTER the mistake is caught, never at or before it) for the first fix-signal match, ordered by turn_index (nearest fix wins)
fn dedup_by_content_hash(chunks : Vec <AssistantChunk>) -> Vec <AssistantChunk>Edge case 3: subagent/parent duplication -- de-dup by content_hash, keeping the first-seen chunk per hash (stable input order)
pub const DEFAULT_CHUNK_LIMIT: i64Gate 1.5.6 §1: bounded LIMIT on every read query against tools_org_knowledge -- this crate is read-only there and never writes back.
pub enum ScanReadError
async fn load_assistant_chunks(pool : & PgPool, limit : i64,) -> Result <Vec <AssistantChunk>, ScanReadError>Load every assistant-role knowledge_chunk row for corpus = 'session-transcripts', bounded by limit and QUERY_TIMEOUT -- the ONLY read this crate ever runs against tools_org_knowledge (US-3.97.1's own AC: the meta->>'role'='assistant' filter, invariant: never reads raw session JSONL, only this already-redacted index)
async fn latest_indexed_at(pool : & PgPool,) -> Result <Option <chrono::DateTime <chrono::Utc>>, sqlx::Error>The corpus's own staleness high-water mark -- reported every run (edge case 4: never a silent stale scan)

No pub use re-exports: every item above is declared in this crate.

Boundary

Reaches into application.

Shares tier tools with 84 other crates: tools-advisory-reach, tools-archive-guard, tools-artifact-scaffold, tools-ask-ai-core, tools-ask-ais, tools-ask-gemini, tools-book, tools-book-report, … (84 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)tools
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/tools/session-error-audit
Vocabulary in force (lexicon)current

Tier flow. Which tiers this crate's own edges cross.

flowchart LR
  n_tools["tools"] --> n_application["application"]

Dependencies

Runtime, in this workspace.

CrateTierOptionalOnly on
`application-core`applicationnoalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
chrono^0.4serdenoalways
clap^4derivenoalways
serde^1derive, derivenoalways
serde_json^1noalways
sqlx^0.8runtime-tokio, postgres, chrono, uuid, jsonnoalways
thiserror^2noalways
tokio^1full, macros, rt-multi-threadnoalways
url^2noalways
uuid^1v4, v7, serde, js, v4, serdenoalways

Development, in this workspace.

CrateTierOptionalOnly on
`foundation-test-support`foundationnoalways
`tools-cli-conformance`toolsnoalways

Build. None.

Depended on by. Nothing in this workspace.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  SELF["tools-session-error-audit"]
  SELF -->|development| n_foundation_test_support["foundation-test-support"]
  SELF -->|development| n_tools_cli_conformance["tools-cli-conformance"]
  SELF -->|runtime| n_application_core["application-core"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.

Targets

KindNameSource
bintools-session-error-audit`src/main.rs`
libtools_session_error_audit`src/lib.rs`
testcli_test`tests/cli_test.rs`

Error model

Error typeNamed by
ScanReadErrorload_assistant_chunks

Operational characteristics

PropertyEvidence
async public surfaceyes
async runtimeyes
database accessyes
network I/Onone detected
unsafe codenone detected
environment variablesyes

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

VariableRead in
DATABASE_URLsrc/persist.rs
FORGE_CORPUS_SOURCE_APP_DBsrc/main.rs
ORG_KNOWLEDGE_DBsrc/main.rs
TEST_DATABASE_URLsrc/persist.rs

No workspace crate depends on this one.

Verification

KindCount
Unit tests19
Integration tests1
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
model400
persist500
scan800

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc1617
Public modules with a //! block33
pie showData
    title Public items with rustdoc
    "Documented" : 16
    "No rustdoc detected" : 1

Metrics

MetricValue
Rust source files5
Source lines1336
Code lines1048
Public API items17
Public modules3
Tests20
Examples0
Cargo features0
Direct runtime dependencies10
Workspace reverse dependencies0
pie showData
    title Public API by kind
    "constant" : 2
    "enum" : 1
    "function" : 9
    "struct" : 5
pie showData
    title Rust source composition
    "Code" : 1048
    "Blank or comment" : 288

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

Todas las tools · Manual