Skip to content

refactor: restructure CLI — analyze includes ingest pipeline, move ingest under debug#15

Merged
STRRL merged 4 commits intomasterfrom
feat/otel
Mar 5, 2026
Merged

refactor: restructure CLI — analyze includes ingest pipeline, move ingest under debug#15
STRRL merged 4 commits intomasterfrom
feat/otel

Conversation

@STRRL
Copy link
Copy Markdown
Owner

@STRRL STRRL commented Feb 28, 2026

  • analyze now runs the full ingest pipeline (Drain + semantic labeling +
    DuckDB storage) before launching the AI agent
  • Move ingest command under debug ingest for step-by-step debugging
  • Extract shared pipeline helpers into cmd/lapp/pipeline.go
  • Remove top-level templates command
  • Add workspace path constraint to analyzer system prompt to prevent
    the agent from scanning files outside the workspace directory
  • Add Langfuse tracing support with docker-compose for local dev
  • Update CLAUDE.md with new CLI structure and code style notes

…gest under debug

- `analyze` now runs the full ingest pipeline (Drain + semantic labeling +
  DuckDB storage) before launching the AI agent
- Move `ingest` command under `debug ingest` for step-by-step debugging
- Extract shared pipeline helpers into `cmd/lapp/pipeline.go`
- Remove top-level `templates` command
- Add workspace path constraint to analyzer system prompt to prevent
  the agent from scanning files outside the workspace directory
- Add Langfuse tracing support with docker-compose for local dev
- Update CLAUDE.md with new CLI structure and code style notes
Instrument the entire pipeline with OTel spans: CLI commands, multiline
merge, Drain parsing, semantic labeling, DuckDB storage, and analyzer.
HTTP clients for LLM calls use otelhttp transport for deep request traces.

- Add pkg/tracing/otel.go with OTLP HTTP exporter (env-gated via OTEL_TRACING_ENABLED)
- Add Jaeger service to docker-compose.yml (UI on port 16686)
- Wire InitOTel in main.go with graceful shutdown
- Add ctx parameter to DrainParser.Feed/Templates and multiline.Merge/MergeSlice
- Wrap eino OpenRouter HTTP clients with otelhttp.NewTransport
@STRRL
Copy link
Copy Markdown
Owner Author

STRRL commented Mar 1, 2026

@codex review please

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5bd60cfeb6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cmd/lapp/analyze.go Outdated
Comment thread cmd/lapp/analyze.go
Extract AnalyzeWithTemplates() that accepts pre-computed templates,
so the analyze command passes the same DrainParser output to both
DuckDB storage and the workspace builder. Previously, Analyze()
created a second DrainParser with fresh UUIDs, causing template IDs
in the workspace to diverge from those in the database.
@STRRL
Copy link
Copy Markdown
Owner Author

STRRL commented Mar 4, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3ba13ad2d1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cmd/lapp/analyze.go
Comment on lines +90 to +94
if err := s.Init(ctx); err != nil {
return errors.Errorf("store init: %w", err)
}

semanticIDMap, patternCount, templateCount, err := discoverAndSavePatterns(ctx, s, drainParser, mergedLines, semantic.Config{
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid appending analyze runs into the shared DB

analyze now always opens --db and inserts patterns/log entries, but this flow never scopes data to a run or clears prior rows before writing. Because the schema/query APIs have no source-file/run discriminator, rerunning lapp analyze (especially on different files) silently mixes datasets and inflates counts, which corrupts later PatternSummaries/query results for that DB path. This command previously had no persistent side effects, so the new default behavior is a data-integrity regression for repeated analyses.

Useful? React with 👍 / 👎.

Adds a pre-flight check in both analyze and debug ingest commands that
errors out if the target DB file already exists, preventing accidental
re-entry that would silently corrupt query results.
@STRRL
Copy link
Copy Markdown
Owner Author

STRRL commented Mar 5, 2026

@codex review please

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8af29fbad2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cmd/lapp/analyze.go
Comment on lines +79 to +80
if _, err := os.Stat(dbPath); err == nil {
return errors.Errorf("database %q already exists; remove it first or choose a different --db path", dbPath)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove partially created DB on ingest failure

This existence guard makes retries fail after transient errors: runAnalyze creates and initializes dbPath before the LLM labeling/storage steps, but if discoverAndSavePatterns or later ingest work returns an error (for example, temporary OpenRouter/API failures), the command exits without deleting the new file; the next invocation with the same --db immediately aborts here with "database already exists." That turns a recoverable failure into manual cleanup work for every retry.

Useful? React with 👍 / 👎.

@STRRL STRRL merged commit f9853d3 into master Mar 5, 2026
2 checks passed
@STRRL STRRL deleted the feat/otel branch March 5, 2026 07:29
STRRL added a commit that referenced this pull request Mar 5, 2026
Keep workspace-based CLI from our branch, discard old analyze/debug/ingest
commands and pipeline.go that master modified. Preserve OTel tracing from
both branches.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant