Deduplicate core research engine helpers across STORM, Co-STORM, Graft, OTel, and Tools

Open
#208 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
15/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
r
Domain
backend

Research direction

Start by reading the named helpers in R/costorm.R, R/research-review.R, and R/enriched-execution.R to understand the proposed shared promise awaiter. Then map the other listed duplication groups and their tests before attempting the broader consolidation. Done means all listed helpers and tiny files are consolidated without behavior or public API changes, OTel and progress events share their vocabulary source, and the affected suites plus air format --check . pass.

Written by the indexing model from the issue text.

Description

Problem

Core research engine modules contain significant cross-file and intra-file duplication across STORM, Co-STORM, sync/async stage execution, Graft memory/artifacts, OTel/progress events, and small single-function files.

Scope

  1. Unify synchronous promise awaiters
    • Replace tempest_costorm_await() (R/costorm.R:123–157), tempest_research_review_await() (R/research-review.R:1380–1426), and tempest_enriched_await_promise() (R/enriched-execution.R:28–69) with one shared tempest_await_promise() helper.
  2. Deduplicate STORM, Co-STORM, and sync/async execution flows
    • Extract the verbatim 40-line research loop body duplicated in R/storm.R:1143–1183 and L1211–1251.
    • Share stage preparation between sync and async fact extraction (R/storm-research.R:514–676), expert generation (R/storm-perspectives.R:88–191), and stage fallback/attempt preflight (R/stage-record.R:4437–4927, including 56 verbatim lines).
    • Share Deputy trace base validation between tempest_storm_deputy_trace() (R/storm-research.R:23–57) and tempest_costorm_deputy_trace() (R/costorm.R:235–302).
    • Share pending-run lookup/identity/removal between tempest_session_settle_agent_completion() and tempest_session_settle_agent_terminal() (R/costorm.R:2230–2361), and extract the repeated quiescence guard in R/costorm-report.R:470–499.
  3. Deduplicate Graft, knowledge-artifact, review, retriever, and contract helpers
    • R/graft-memory.R:428–568: share review input validation and expected-head resolution between tempest_graft_accept_selection() and tempest_graft_withdraw_stream() (also resolving the current_head vs expected return inconsistency at L487 vs L557).
    • R/graft-artifacts.R:315–357: extract repeated graft_recall() accepted-decision check in tempest_reuse_artifact_research().
    • R/knowledge-artifacts.R: extract repeated exact-ID check (L48–59 vs L84–95) and 1 MiB byte-limit check (L229–243 vs L285–296).
    • R/research-review.R:221–268 vs R/research-review-types.R:138–184: unify dossier evidence-quote validation.
    • R/retriever.R:342–517: share URL validation and PDF detection between tempest_fetch_url_markdown() and tempest_fetch_url_text().
    • R/research-manifest.R:13–24: derive tempest_opaque_identifier_stages from tempest_program_set_stages().
    • R/stage-record.R:4100–4115: reuse tempest_dsprrr_contract_condition() from R/dsprrr.R.
  4. Reconcile diverging OTel & progress-event vocabularies
    • Unify stage/step name sources between R/otel.R:40–78 and R/progress-events.R:584–632 so OTel and progress events cannot silently drift (e.g., "persist" and "expert_question" currently missing from otel.R).
  5. Consolidate tiny fragmented R/ files and misplaced helpers
    • Fold single-function / tiny files into their natural owners (updating DESCRIPTION Collate as needed): R/suggestions.R (21L), R/prompts.R (22L), R/storm-polish.R (26L), R/citations.R (44L), R/storm-evidence.R (49L), R/execution-events.R (101L), R/research-tools.R (125L).
    • Move misplaced tempest_generate_single_expert() from R/tools.R:1045–1099 to R/storm-perspectives.R.

Acceptance Criteria

  • Listed duplications and tiny fragmented files are consolidated with no behavioral or public-API changes.
  • OTel and progress-event stage/step vocabularies derive from a single source of truth.
  • Full affected test suites and air format --check . pass.
Dominant language
R
Stars
1
Forks
0
Avg merge
19h 6m
Merged PRs (30d)
12

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from JamesHWade/tempest

All issues in JamesHWade/tempest

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.