mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-13 08:15:14 +02:00
* feat(cli): profile ingest runs to find where wall-clock time goes Add opt-in profiling for `ktx ingest`. Each timed phase, work unit, and agent loop now records durationMs / step count / token usage in the trace, and a post-run aggregator rolls them up into a "where did the time go" report printed to stderr. Enable per run with KTX_PROFILE_INGEST (1/true -> human table, json -> raw structured profile) or persistently via `ingest.profile` in ktx.yaml. The json form emits raw milliseconds, token counts, and a summary.headline one-line diagnosis so coding agents can parse it directly; json wins when both env and config request profiling. - runtime-port: RunLoopMetrics (totalMs, usage, stepCount, stepBoundariesMs) plus onMetrics callbacks on text/object generation - ai-sdk + claude-code runtimes: capture per-loop timing and token usage - work-unit-executor and stages 3/4: thread metrics into trace events - ingest-bundle.runner: time worktree / triage / clustering / index / reconcile / squash phases and emit the profile in a finally block (best-effort; never affects the run outcome) - ingest-profile: new trace+transcript aggregator with table/json formatters - config: ingest.profile flag; docs: profiling section in ktx-ingest.mdx * fix(cli): flush tool-call logs before reading ingest profile Tool transcripts are appended fire-and-forget so the agent hot path never blocks on logging. The ingest profiler read them before the writes settled, so per-work-unit toolMs (and the model-vs-tool split derived from it) could be incomplete. Track in-flight appends and expose flushToolCallLogs() — bounded by a timeout so it can never hang — and flush before the profiler reads the transcript. |
||
|---|---|---|
| .. | ||
| adapters | ||
| clustering | ||
| context-candidates | ||
| context-evidence | ||
| dbt-shared | ||
| historic-sql-probes | ||
| isolated-diff | ||
| memory-flow | ||
| page-triage | ||
| stages | ||
| tools | ||
| action-identity.test.ts | ||
| artifact-gates.test.ts | ||
| canonical-pins.test.ts | ||
| diff-set.service.test.ts | ||
| final-gate-repair.test.ts | ||
| finalization-scope.test.ts | ||
| historic-sql-probes.test.ts | ||
| ingest-bundle.runner.isolated-diff.test.ts | ||
| ingest-bundle.runner.test.ts | ||
| ingest-profile.test.ts | ||
| ingest-prompts.test.ts | ||
| ingest-runtime-assets.test.ts | ||
| ingest-trace.test.ts | ||
| local-adapters.test.ts | ||
| local-bundle-ingest.test.ts | ||
| local-bundle-runtime.test.ts | ||
| local-embedding-provider.integration.test.ts | ||
| local-mapping-reconcile.test.ts | ||
| local-metabase-ingest.test.ts | ||
| local-stage-ingest.test.ts | ||
| raw-sources-paths.test.ts | ||
| repo-fetch.test.ts | ||
| report-snapshot.test.ts | ||
| reports.test.ts | ||
| semantic-layer-target-policy.test.ts | ||
| source-adapter-registry.test.ts | ||
| sqlite-bundle-ingest-store.test.ts | ||
| sqlite-local-ingest-store.test.ts | ||
| wiki-body-refs.test.ts | ||
| wiki-sl-ref-repair.test.ts | ||