Skip to content

Add planner-based analysis pipeline and optional /api/analyze planner flow#44

Merged
rad1092 merged 1 commit into
mainfrom
codex/create-planner-with-intent-dataclasses
Feb 15, 2026
Merged

Add planner-based analysis pipeline and optional /api/analyze planner flow#44
rad1092 merged 1 commit into
mainfrom
codex/create-planner-with-intent-dataclasses

Conversation

@rad1092
Copy link
Copy Markdown
Owner

@rad1092 rad1092 commented Feb 15, 2026

Motivation

  • Provide a lightweight planner that can parse a natural-language analysis question into structured controls (top N, sample N, threshold, region, compare periods) and produce an executable plan.
  • Allow the web analysis endpoint to optionally run that plan and return a machine-readable execution result alongside the existing analysis payload.

Description

  • Add bitnet_tools/planner.py defining AnalysisIntent and AnalysisPlan dataclasses and implementing parse_question_to_intent, build_plan, execute_plan, and execute_plan_from_csv_text which build and run a filter -> groupby -> agg -> rank -> sample -> export execution graph and return table/sample/meta with graceful fallback on errors.
  • Integrate planner into bitnet_tools/web.py by importing parse_question_to_intent, build_plan, and execute_plan_from_csv_text and adding a use_planner boolean option on /api/analyze that appends planner.intent, planner.plan, and planner.execution to the response when enabled.
  • Add tests/test_planner.py to validate parsing, plan-node structure, and fallback behavior for invalid nodes.
  • Extend tests/test_web.py with an integration test verifying that /api/analyze returns the planner payload when use_planner is true.

Testing

  • Ran the new and updated automated tests with pytest -q tests/test_planner.py tests/test_web.py and all tests passed (15 passed in 1.74s).
  • Tests cover intent parsing, plan generation, executor fallback behavior, and the web API planner integration.

Codex Task

@rad1092 rad1092 merged commit 7d76335 into main Feb 15, 2026
4 checks passed
@rad1092 rad1092 deleted the codex/create-planner-with-intent-dataclasses branch February 15, 2026 05:08
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: 2a8dd7313c

ℹ️ 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 bitnet_tools/planner.py
Comment on lines +118 to +122
if re.fullmatch(r"[가-힣A-Za-z][가-힣A-Za-z0-9_-]+", tok):
if tok.lower() not in {"top", "sample", "threshold", "임계값", "상위", "샘플"}:
if tok in columns:
continue
intent.region = tok
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Exclude period tokens from region inference

When a question asks for a before/after comparison without naming a region (for example containing before, after, 이전, or 이후), this fallback path treats the first such token as intent.region. That makes the filter node run against region_column with a non-region value, which can drop all rows and return empty planner results for valid compare-period queries.

Useful? React with 👍 / 👎.

Comment thread bitnet_tools/web.py
result["planner"] = {
"intent": intent.__dict__,
"plan": {"nodes": plan.nodes, "warnings": plan.warnings, "fallback": plan.fallback},
"execution": execute_plan_from_csv_text(plan, str(request_payload.get("normalized_csv_text", "") or "")),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Execute planner on normalized input used by analysis

This execution step always reads request_payload.normalized_csv_text, but /api/analyze still accepts legacy csv_text and build_analysis_payload_from_request promotes it when normalized text is empty. In that common compatibility path, analysis summary is built from real rows while planner execution runs on an empty CSV, producing inconsistent/empty planner output despite a successful analysis response.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant