Skip to content

Codex bootstrap for #1313 - #1365

Closed
stranske wants to merge 1 commit into
mainfrom
codex/issue-1313
Closed

stranske wants to merge 1 commit into
mainfrom
codex/issue-1313

Conversation

@stranske

@stranske stranske commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Keepalive: OFF

Source Issue #1313: [Audit] Consolidate duplicated dialect/DB/chain helpers into shared modules

Base: main
Head: codex/issue-1313

Source: #1313

Automated Status Summary

Scope

The dual-dialect DB layer is implemented by per-module copies of the same helpers instead of shared functions, so every new flow re-implements (and can drift on) dialect handling. Verified copies at e5764a5:

  • _placeholder(conn) / _is_sqlite(conn) (pick ? vs %s, isinstance(conn, sqlite3.Connection)) duplicated across 12 modules: etl/{activism_detection,activism_flow,conviction_flow,daily_diff_flow,digest_flow,edgar_flow,evaluation_flow,ingest_flow,news_flow}.py, api/{signals,chat,activism}.py.
  • _columns / _get_columns (SQLite PRAGMA/pragma_table_info vs PG information_schema.columns) in etl/digest_flow.py:84, etl/edgar_flow.py:62, api/search.py:47.
  • api_usage table DDL in etl/evaluation_flow.py:101, llm/cost_tracking.py:25, adapters/base.py:83/102.
  • Chain helpers: _extract_json_text (chains/filing_summary.py:169, chains/holdings_analysis.py:155), _cursor_rows_to_dicts (same two), _guard_context/_acquire_connection (chains/rag_search.py, chains/nl_query.py), _normalize_cik (api/managers.py:245, scripts/seed_universe.py:23, scripts/resolve_aliases.py:29).

Est. ~210 LOC of duplication; the risk is divergence (a fix applied to one copy and not the others) — the same defect class behind several other audit findings.

Tasks

  • Add is_sqlite(conn), get_placeholder(conn), get_table_columns(conn, table), and public ensure_api_usage_schema(conn) to adapters/base.py; replace the 12+3+3 call sites.
  • Add extract_json_text() and rows_to_dicts() to chains/utils.py; replace the chain copies. Centralize _guard_context/_acquire_connection.
  • Add a shared normalize_cik() and replace the 3 copies.

Acceptance Criteria

  • Existing suite stays green; no behavior change.
  • A grep gate (or test) asserts there is exactly one definition of each consolidated helper (no per-module re-definitions reintroduced).
  • Deliberate-break demonstration: re-adding a local _placeholder copy in any module trips the single-definition gate.
Full Issue Text

Why

The dual-dialect DB layer is implemented by per-module copies of the same helpers instead of shared functions, so every new flow re-implements (and can drift on) dialect handling. Verified copies at e5764a5:

  • _placeholder(conn) / _is_sqlite(conn) (pick ? vs %s, isinstance(conn, sqlite3.Connection)) duplicated across 12 modules: etl/{activism_detection,activism_flow,conviction_flow,daily_diff_flow,digest_flow,edgar_flow,evaluation_flow,ingest_flow,news_flow}.py, api/{signals,chat,activism}.py.
  • _columns / _get_columns (SQLite PRAGMA/pragma_table_info vs PG information_schema.columns) in etl/digest_flow.py:84, etl/edgar_flow.py:62, api/search.py:47.
  • api_usage table DDL in etl/evaluation_flow.py:101, llm/cost_tracking.py:25, adapters/base.py:83/102.
  • Chain helpers: _extract_json_text (chains/filing_summary.py:169, chains/holdings_analysis.py:155), _cursor_rows_to_dicts (same two), _guard_context/_acquire_connection (chains/rag_search.py, chains/nl_query.py), _normalize_cik (api/managers.py:245, scripts/seed_universe.py:23, scripts/resolve_aliases.py:29).

Est. ~210 LOC of duplication; the risk is divergence (a fix applied to one copy and not the others) — the same defect class behind several other audit findings.

Scope

Consolidate the duplicated dialect/DB/chain helpers into shared locations (adapters/base.py for DB; chains/utils.py for chain helpers; a utils normalizer for CIK) and update call sites to import them.

Non-Goals

  • Do NOT change runtime behavior — this is a behavior-preserving consolidation.
  • Do NOT alter the check_dialect_portability.py gate semantics.

Tasks

  • Add is_sqlite(conn), get_placeholder(conn), get_table_columns(conn, table), and public ensure_api_usage_schema(conn) to adapters/base.py; replace the 12+3+3 call sites.
  • Add extract_json_text() and rows_to_dicts() to chains/utils.py; replace the chain copies. Centralize _guard_context/_acquire_connection.
  • Add a shared normalize_cik() and replace the 3 copies.

Acceptance Criteria

  • Existing suite stays green; no behavior change.
  • A grep gate (or test) asserts there is exactly one definition of each consolidated helper (no per-module re-definitions reintroduced).
  • Deliberate-break demonstration: re-adding a local _placeholder copy in any module trips the single-definition gate.

Implementation Notes

Audit baseline: main @ e5764a5 on 2026-06-28. Call sites enumerated by the duplication sweep (Code/Audits/Manager-Database/2026-06-28-02-duplication-quality.md).


PR created automatically to engage Codex.

Copilot AI review requested due to automatic review settings July 1, 2026 21:25
@stranske-automation-bot stranske-automation-bot added the agent:codex Assign to Codex agent label Jul 1, 2026
@stranske-automation-bot

Copy link
Copy Markdown
Collaborator

Issue #1313: [Audit] Consolidate duplicated dialect/DB/chain helpers into shared modules

Automated Status Summary

Scope

The dual-dialect DB layer is implemented by per-module copies of the same helpers instead of shared functions, so every new flow re-implements (and can drift on) dialect handling. Verified copies at e5764a5:

  • _placeholder(conn) / _is_sqlite(conn) (pick ? vs %s, isinstance(conn, sqlite3.Connection)) duplicated across 12 modules: etl/{activism_detection,activism_flow,conviction_flow,daily_diff_flow,digest_flow,edgar_flow,evaluation_flow,ingest_flow,news_flow}.py, api/{signals,chat,activism}.py.
  • _columns / _get_columns (SQLite PRAGMA/pragma_table_info vs PG information_schema.columns) in etl/digest_flow.py:84, etl/edgar_flow.py:62, api/search.py:47.
  • api_usage table DDL in etl/evaluation_flow.py:101, llm/cost_tracking.py:25, adapters/base.py:83/102.
  • Chain helpers: _extract_json_text (chains/filing_summary.py:169, chains/holdings_analysis.py:155), _cursor_rows_to_dicts (same two), _guard_context/_acquire_connection (chains/rag_search.py, chains/nl_query.py), _normalize_cik (api/managers.py:245, scripts/seed_universe.py:23, scripts/resolve_aliases.py:29).

Est. ~210 LOC of duplication; the risk is divergence (a fix applied to one copy and not the others) — the same defect class behind several other audit findings.

Tasks

  • Add is_sqlite(conn), get_placeholder(conn), get_table_columns(conn, table), and public ensure_api_usage_schema(conn) to adapters/base.py; replace the 12+3+3 call sites.
  • Add extract_json_text() and rows_to_dicts() to chains/utils.py; replace the chain copies. Centralize _guard_context/_acquire_connection.
  • Add a shared normalize_cik() and replace the 3 copies.

Acceptance Criteria

  • Existing suite stays green; no behavior change.
  • A grep gate (or test) asserts there is exactly one definition of each consolidated helper (no per-module re-definitions reintroduced).
  • Deliberate-break demonstration: re-adding a local _placeholder copy in any module trips the single-definition gate.
Full Issue Text

Why

The dual-dialect DB layer is implemented by per-module copies of the same helpers instead of shared functions, so every new flow re-implements (and can drift on) dialect handling. Verified copies at e5764a5:

  • _placeholder(conn) / _is_sqlite(conn) (pick ? vs %s, isinstance(conn, sqlite3.Connection)) duplicated across 12 modules: etl/{activism_detection,activism_flow,conviction_flow,daily_diff_flow,digest_flow,edgar_flow,evaluation_flow,ingest_flow,news_flow}.py, api/{signals,chat,activism}.py.
  • _columns / _get_columns (SQLite PRAGMA/pragma_table_info vs PG information_schema.columns) in etl/digest_flow.py:84, etl/edgar_flow.py:62, api/search.py:47.
  • api_usage table DDL in etl/evaluation_flow.py:101, llm/cost_tracking.py:25, adapters/base.py:83/102.
  • Chain helpers: _extract_json_text (chains/filing_summary.py:169, chains/holdings_analysis.py:155), _cursor_rows_to_dicts (same two), _guard_context/_acquire_connection (chains/rag_search.py, chains/nl_query.py), _normalize_cik (api/managers.py:245, scripts/seed_universe.py:23, scripts/resolve_aliases.py:29).

Est. ~210 LOC of duplication; the risk is divergence (a fix applied to one copy and not the others) — the same defect class behind several other audit findings.

Scope

Consolidate the duplicated dialect/DB/chain helpers into shared locations (adapters/base.py for DB; chains/utils.py for chain helpers; a utils normalizer for CIK) and update call sites to import them.

Non-Goals

  • Do NOT change runtime behavior — this is a behavior-preserving consolidation.
  • Do NOT alter the check_dialect_portability.py gate semantics.

Tasks

  • Add is_sqlite(conn), get_placeholder(conn), get_table_columns(conn, table), and public ensure_api_usage_schema(conn) to adapters/base.py; replace the 12+3+3 call sites.
  • Add extract_json_text() and rows_to_dicts() to chains/utils.py; replace the chain copies. Centralize _guard_context/_acquire_connection.
  • Add a shared normalize_cik() and replace the 3 copies.

Acceptance Criteria

  • Existing suite stays green; no behavior change.
  • A grep gate (or test) asserts there is exactly one definition of each consolidated helper (no per-module re-definitions reintroduced).
  • Deliberate-break demonstration: re-adding a local _placeholder copy in any module trips the single-definition gate.

Implementation Notes

Audit baseline: main @ e5764a5 on 2026-06-28. Call sites enumerated by the duplication sweep (Code/Audits/Manager-Database/2026-06-28-02-duplication-quality.md).

@stranske-automation-bot

Copy link
Copy Markdown
Collaborator

PR created.
Comment @codex start to request the plan.
Tell Codex to reuse scope and acceptance criteria from the source issue.
Also reuse the task list from the source issue.
Publish them here with - [ ] checklists so keepalive keeps watching.
After Codex replies, follow the instructions posted on the source issue.
Then begin execution.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 48 minutes

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 823f2eb8-faf1-4f98-a1a6-f62d46eb5566

📥 Commits

Reviewing files that changed from the base of the PR and between 06eb505 and f9a727a.

📒 Files selected for processing (1)
  • agents/codex-1313.md
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/issue-1313

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR appears to be an automated “bootstrap” commit for Issue #1313, but it does not include any of the described consolidation work (shared DB/dialect helpers, chain utils, CIK normalization, or the single-definition/grep gate).

Changes:

  • Adds a single bootstrap marker file for Codex tracking on issue #1313.

Comment thread agents/codex-1313.md
@@ -0,0 +1 @@
<!-- bootstrap for codex on issue #1313 -->
@stranske

stranske commented Jul 1, 2026

Copy link
Copy Markdown
Owner Author

Closing this bootstrap PR as duplicate cap clutter. Source issue #1313 was already implemented by PR #1361, which merged at 2026-07-01T21:24Z and has verify:compare sequencing pending on the reopened source issue. This PR only contains the generated agents/codex-1313.md bootstrap file, has Keepalive OFF, and should not consume opener capacity.

@stranske stranske closed this Jul 1, 2026
@stranske
stranske deleted the codex/issue-1313 branch August 6, 2026 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:codex Assign to Codex agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants