Skip to content

feat: add discovery sessions (DS-xxx) - #77

Merged
ablanrob merged 3 commits into
mainfrom
feat/discovery-sessions
Apr 24, 2026
Merged

ablanrob merged 3 commits into
mainfrom
feat/discovery-sessions

Conversation

@ablanrob

Copy link
Copy Markdown
Owner

Summary

  • Adds a new discovery artifact type (DS-xxx) with a 9-tool lifecycle for structured stakeholder requirements elicitation
  • Tools: start_discovery, record_finding, record_gap, complete_discovery, list_discoveries, get_discovery, add_discovery_review, resolve_gap, request_followup
  • Integrates with onboarding (new step 3: "Conduct discovery sessions"), health checks (no-discoveries recommendation), persona document types, and prompt fragments for both generic-agile and sap-aem plugins
  • Updates docs: personas guide and document types reference

Key design decisions

  • Discovery sessions support chaining via parent — open gaps carry forward automatically and session increments
  • record_gap with spawn_question: true creates a linked Q-xxx with discovery:DS-xxx tag; resolve_gap auto-updates the spawned question to answered
  • Content manipulation uses simple string operations (indexOf, split, replace) consistent with existing tools — no markdown parser dependency
  • Status flow: draft -> in-review -> needs-input -> accepted | parked

Test plan

  • 23 new test cases in test/plugins/tools/discoveries.test.ts covering all 9 tools
  • 3 new health check tests in test/doctor/health/engine.test.ts
  • Updated onboarding tests for 8-step checklist
  • Updated registry test for new tool count (44)
  • npm run typecheck — passes
  • npm test — 875/875 passing
  • npm run lint — 0 errors
  • npm run build — clean

…citation

Introduce a new "discovery" artifact type with a 9-tool lifecycle for
conducting stakeholder elicitation sessions, recording findings and gaps,
reviewing outcomes, and iterating via follow-ups.

Tools: start_discovery, record_finding, record_gap, complete_discovery,
list_discoveries, get_discovery, add_discovery_review, resolve_gap,
request_followup.

Also adds onboarding step, health check, persona/prompt integration,
and plugin prompt fragments for both generic-agile and sap-aem.
…sions

Add discovery to persona document type lists and include the new DS-xxx
type in the document types reference table with its statuses and fields.
@coderabbitai

coderabbitai Bot commented Apr 24, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@ablanrob has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 42 minutes and 51 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 42 minutes and 51 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 75efe508-9870-42c4-bb3d-e3a105fabf8f

📥 Commits

Reviewing files that changed from the base of the PR and between e56c10a and 692fc4f.

📒 Files selected for processing (3)
  • src/doctor/health/onboarding.ts
  • src/plugins/builtin/tools/discoveries.ts
  • test/plugins/tools/discoveries.test.ts
📝 Walkthrough

Walkthrough

This change introduces a new discovery document type for capturing stakeholder discovery sessions across the system, including health checks, onboarding steps, persona support, plugin implementations, and comprehensive tool infrastructure for managing the complete discovery lifecycle.

Changes

Cohort / File(s) Summary
Documentation
docs/guides/personas.md, docs/reference/document-types.md
Updated persona guides and document type reference to include the new discovery type with its storage directory (discoveries), ID prefix (DS), and supported lifecycle statuses.
Core Status Definition
src/core/statuses.ts
Added new exported constant DISCOVERY_STATUSES defining five valid states for discovery artifacts.
Health Check System
src/doctor/health/checks/index.ts, src/doctor/health/checks/no-discoveries.ts
Introduced noDiscoveriesCheck health check that detects missing discovery sessions when features exist, integrated into health-check registry.
Onboarding Steps
src/doctor/health/onboarding.ts
Added "Conduct discovery sessions" as a new onboarding step before decision capture, with tracking via ctx.store.counts().
Persona Definitions
src/personas/builtin/product-owner.ts, src/personas/builtin/delivery-manager.ts, src/personas/builtin/tech-lead.ts
Extended documentTypes configuration for all three personas to include "discovery".
Persona Prompts
src/personas/prompt-builder.ts
Updated system prompt to include Discoveries (DS-xxx) in the available tools list.
Plugin: Generic Agile
src/plugins/builtin/generic-agile.ts
Added discovery document type and comprehensive discovery-centric prompt fragments for Product Owner, Tech Lead, and Delivery Manager roles, including gap tracking and session chaining workflows.
Plugin: SAP AEM
src/plugins/builtin/sap-aem.ts
Added discovery document type and augmented persona prompts with discovery capabilities for business process validation and technical feasibility assessment.
Discovery Tools & Registration
src/plugins/builtin/tools/discoveries.ts, src/plugins/common.ts
Implemented comprehensive createDiscoveryTools(store) module supporting full discovery lifecycle (create, record findings/gaps, complete, review, resolve gaps, request follow-up); registered discovery type in COMMON_REGISTRATIONS.
Health Check Tests
test/doctor/health/engine.test.ts
Added test registration of discovery document type and three new test cases validating no-discoveries finding behavior for various feature/discovery presence scenarios.
Onboarding Tests
test/doctor/health/onboarding.test.ts
Expanded onboarding tests to include the new discovery step, added assertions for 8-step sequence, and added test verifying discovery step completion tracking.
Plugin Registry Tests
test/plugins/registry.test.ts
Updated generic-agile plugin tool count from 35 to 44 to reflect nine new discovery-related tools.
Discovery Tools Tests
test/plugins/tools/discoveries.ts
Added comprehensive test suite covering discovery lifecycle workflows: creation, gap/finding recording, session completion, review annotations, gap resolution, and follow-up request handling.

Sequence Diagram(s)

sequenceDiagram
    participant PO as Product Owner
    participant Tools as Discovery Tools
    participant Store as DocumentStore
    participant Plugins as Plugins

    PO->>Tools: start_discovery()
    Tools->>Store: create Discovery (DS-1, draft)
    Tools->>Store: inject parent gaps if chained
    
    PO->>Tools: record_finding(session_id, finding)
    Tools->>Store: append F-N block
    
    PO->>Tools: record_gap(session_id, gap)
    Tools->>Store: append GAP-N block (open)
    Tools->>Store: optionally spawn Question artifact
    
    PO->>Tools: complete_discovery(session_id)
    Tools->>Store: transition to in-review
    Tools->>Store: append summary (finding/gap counts)
    
    PO->>Tools: review_discovery(session_id, annotation)
    Tools->>Store: append review annotation
    
    PO->>Tools: resolve_gap(session_id, gap_id, rationale)
    Tools->>Store: update GAP-N to resolved
    Tools->>Store: mark spawned Question as answered
    
    PO->>Tools: request_follow_up(session_id)
    Tools->>Store: transition to needs-input
    Tools->>Store: append follow-up section
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • PR #74: Modifies the doctor/health subsystem by adding health checks and updating the health-check registry, complementary to the new noDiscoveriesCheck integration.
  • PR #75: Modifies onboarding guide logic and adds onboarding steps, directly related to the new "Conduct discovery sessions" step introduced here.
  • PR #66: Updates src/core/statuses.ts with exported status constants, similar pattern to the new DISCOVERY_STATUSES export in this PR.

Poem

🐰 Hopping through sessions, we gather the clues,
Discoveries blooming in structured reviews,
From gaps to findings, the stories take flight,
Gap-tracking, gap-closing—what a delight!
DS-one, DS-two, the sessions align,
Discovery magic—simply divine! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: add discovery sessions (DS-xxx)' clearly and concisely summarizes the main change—introducing a new discovery artifact type with a structured lifecycle.
Description check ✅ Passed The PR description includes a comprehensive summary, key design decisions, and test plan, covering all critical aspects. It references the template's Type of Change, Testing, and Checklist sections implicitly through its content, though the formal template checkboxes are not explicitly marked.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/discovery-sessions

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/doctor/health/onboarding.ts (1)

86-134: ⚠️ Potential issue | 🟡 Minor

Step-number comments are now stale.

With the new discovery step inserted as Step 3, the subsequent inline comments no longer match: Line 96 says "Step 4: Break down into epics" (now 5), Line 107 says "Step 5: Set up Sprint 0" (now 6), Line 117 says "Step 6: Configure Jira integration" (now 7), and Line 126 says "Step 7: Run a health check" (now 8). Line 86 was correctly updated to "Step 4". Functionality is unaffected (orders come from order++), but the comments are misleading for future readers.

✏️ Proposed fix
-  // Step 4: Break down into epics
+  // Step 5: Break down into epics
   steps.push({
     order: order++,
     title: "Break work into epics",
@@
-  // Step 5: Set up Sprint 0
+  // Step 6: Set up Sprint 0
   steps.push({
     order: order++,
     title: "Set up Sprint 0",
@@
-  // Step 6: Configure Jira integration
+  // Step 7: Configure Jira integration
   steps.push({
     order: order++,
     title: "Configure Jira integration",
@@
-  // Step 7: Run a health check
+  // Step 8: Run a health check
   steps.push({
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/doctor/health/onboarding.ts` around lines 86 - 134, The inline
step-number comments are stale after inserting the discovery step; update the
comment text in the subsequent steps so they match their actual sequence
generated by order++ (e.g., change "Step 4: Break down into epics" etc. to the
correct numbers); find the steps created via the repeated steps.push({ ... })
blocks (look for the objects with title "Break work into epics", "Set up Sprint
0", "Configure Jira integration", and "Run a health check") and edit their
leading comment lines to reflect the new step numbers while leaving the order++
logic and fields (tool, done, description) unchanged.
🧹 Nitpick comments (1)
src/plugins/builtin/tools/discoveries.ts (1)

57-83: Refactor duplicated gap-block parser.

The line-by-line GAP block scanner is repeated almost identically in start_discovery (parent carry-forward) and request_followup (unresolved items). Extracting a small helper such as collectOpenGapBlocks(content: string): { heading: string; block: string }[] would remove duplication, make the two call sites declarative, and centralize any future fix (e.g., handling #### subheadings or resolved-in-child gaps).

Also applies to: 479-506

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/plugins/builtin/tools/discoveries.ts` around lines 57 - 83, The GAP-block
parsing logic is duplicated in start_discovery and request_followup; extract it
into a small helper (suggested name collectOpenGapBlocks(content: string): {
heading: string; block: string }[]) that takes document content and returns an
array of open gap objects (heading and full block text). Replace the inlined
scanner in both start_discovery and request_followup with calls to this helper,
and ensure the helper preserves the existing behavior (detecting "### GAP-<n>:"
headings, collecting until the next "### " heading, and only returning blocks
containing "**Status:** open"); centralize any future parsing adjustments (e.g.,
handling deeper subheadings or resolved-in-child logic) in this new function.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/plugins/builtin/tools/discoveries.ts`:
- Around line 248-271: The current completion path appends a new "## Session
Summary" to doc.content every time, causing duplicate summaries when
transitioning from needs-input to in-review again; update the logic in the
completion handler (the block that reads doc.frontmatter.status, computes
findingCount/gapCount, builds summary, and calls store.update) to detect an
existing "## Session Summary" section in doc.content and either replace that
section with the new summary or skip appending if the existing summary is
already up-to-date; use the existing utilities (e.g., countBlocks) to compute
counts, locate the existing summary by searching for the header line "## Session
Summary" and the section that follows it, and then call store.update(args.id, {
status: "in-review" }, newContent) with the modified content instead of always
appending.
- Around line 408-426: The handler currently only checks for gapHeading but then
unconditionally runs the replace and store.update; detect whether the GAP is
already resolved by testing doc.content for the open-status pattern before
performing the replace: use the same regex (or a RegExp.test) that matches `###
GAP-${args.gap_number}:[^]*?\\*\\*Status:\\*\\* open` to determine if the gap is
open, and only perform the replace and call store.update(args.id, {},
newContent) when that test passes; if the test fails (status not open) return an
explicit already-resolved response (or an error) instead of claiming a
successful resolution.

In `@test/plugins/tools/discoveries.test.ts`:
- Around line 88-91: The inline comment "Resolve one gap" is misleading because
the test calls complete_discovery (function complete_discovery) which only
transitions discovery status and appends a summary, it does not resolve gaps;
update or remove that comment in the test
(test/plugins/tools/discoveries.test.ts) so it accurately describes the action
(e.g., "Mark discovery complete / append summary") or simply delete the line to
avoid confusion with the following assertions that gaps remain open.

---

Outside diff comments:
In `@src/doctor/health/onboarding.ts`:
- Around line 86-134: The inline step-number comments are stale after inserting
the discovery step; update the comment text in the subsequent steps so they
match their actual sequence generated by order++ (e.g., change "Step 4: Break
down into epics" etc. to the correct numbers); find the steps created via the
repeated steps.push({ ... }) blocks (look for the objects with title "Break work
into epics", "Set up Sprint 0", "Configure Jira integration", and "Run a health
check") and edit their leading comment lines to reflect the new step numbers
while leaving the order++ logic and fields (tool, done, description) unchanged.

---

Nitpick comments:
In `@src/plugins/builtin/tools/discoveries.ts`:
- Around line 57-83: The GAP-block parsing logic is duplicated in
start_discovery and request_followup; extract it into a small helper (suggested
name collectOpenGapBlocks(content: string): { heading: string; block: string
}[]) that takes document content and returns an array of open gap objects
(heading and full block text). Replace the inlined scanner in both
start_discovery and request_followup with calls to this helper, and ensure the
helper preserves the existing behavior (detecting "### GAP-<n>:" headings,
collecting until the next "### " heading, and only returning blocks containing
"**Status:** open"); centralize any future parsing adjustments (e.g., handling
deeper subheadings or resolved-in-child logic) in this new function.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9202e768-8b9f-429c-95fa-5a2148267032

📥 Commits

Reviewing files that changed from the base of the PR and between 8163014 and e56c10a.

📒 Files selected for processing (18)
  • docs/guides/personas.md
  • docs/reference/document-types.md
  • src/core/statuses.ts
  • src/doctor/health/checks/index.ts
  • src/doctor/health/checks/no-discoveries.ts
  • src/doctor/health/onboarding.ts
  • src/personas/builtin/delivery-manager.ts
  • src/personas/builtin/product-owner.ts
  • src/personas/builtin/tech-lead.ts
  • src/personas/prompt-builder.ts
  • src/plugins/builtin/generic-agile.ts
  • src/plugins/builtin/sap-aem.ts
  • src/plugins/builtin/tools/discoveries.ts
  • src/plugins/common.ts
  • test/doctor/health/engine.test.ts
  • test/doctor/health/onboarding.test.ts
  • test/plugins/registry.test.ts
  • test/plugins/tools/discoveries.test.ts

Comment thread src/plugins/builtin/tools/discoveries.ts Outdated
Comment thread src/plugins/builtin/tools/discoveries.ts
Comment thread test/plugins/tools/discoveries.test.ts Outdated
- Extract shared gap-parsing logic into collectOpenGaps() helper,
  replacing duplicated scanners in start_discovery and request_followup
- Replace existing "## Session Summary" on re-completion instead of
  appending a duplicate (needs-input -> in-review path)
- Return explicit error when resolve_gap targets an already-resolved gap
- Fix misleading test comment about complete_discovery
- Renumber stale step comments in onboarding.ts (steps 5-8)
- Add test for duplicate summary prevention and already-resolved gap
@ablanrob
ablanrob merged commit 7c92b74 into main Apr 24, 2026
2 checks passed
@ablanrob
ablanrob deleted the feat/discovery-sessions branch April 24, 2026 19:40
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