Skip to content

Phase 7 — self-healing analyses re-point to map#272

Open
leeovery wants to merge 14 commits into
idea/inception-pr-6-refinementfrom
idea/inception-pr-7-self-healing
Open

Phase 7 — self-healing analyses re-point to map#272
leeovery wants to merge 14 commits into
idea/inception-pr-6-refinementfrom
idea/inception-pr-7-self-healing

Conversation

@leeovery
Copy link
Copy Markdown
Owner

Summary

  • Move research-analysis and discussion-gap-analysis out of workflow-discussion-entry into a shared location, dispatched by a new self-healing.md orchestrator at continue-epic boot-up and inception refinement entry.
  • Output target shifts: analyses now write phases.inception.items.{topic} directly (with source: research-analysis / gap-analysis, comma-joined when both surface the same theme) instead of the legacy surfaced_topics / gap_topics arrays. Items appear on the discovery map immediately; the user removes any unwanted ones via refinement, which adds them to phases.inception.dismissed[] so the same analysis won't re-add them.
  • pending_from_research / pending_from_gaps collapse — both concepts disappear from continue-epic discovery and display. New items render as ○ fresh map rows with their source provenance shown. A ⚑ N new topic(s) added to the map from {analysis} callout shows once at the boot-up that added them.
  • workflow-discussion-entry simplifies to a four-step flow (parse args, validate phase, gather context, invoke). The no-topic-epic branch becomes a one-line "what topic?" prompt — Phase 10 will reshape that further.
  • Refinement-session.md C. Self-Healing Check is wired up; the Self-Healing Arrivals section of the refinement session log now records analysis-added topics. Per the phase doc the continue resume path bypasses C — analyses ran on the prior entry, no need to re-run.
  • Migration 038 deletes the obsolete phases.research.surfaced_topics and phases.discussion.gap_topics fields from existing manifests. Cache fields (analysis_cache, gap_analysis_cache) stay.

Test plan

  • node --test tests/scripts/test-discovery-utils.cjs (113 tests — adds computeAnalysisCacheStatus + extended computeSourceProvenance suites)
  • node --test tests/scripts/test-discovery-for-continue-epic.cjs (71 tests — adds analysis_caches shape, drops pending_from_* coverage)
  • node --test tests/scripts/test-discovery-for-refinement.cjs (64 tests — adds analysis_caches suite)
  • node --test tests/scripts/test-discovery-*.cjs (404 tests across all discovery suites)
  • bash tests/scripts/test-migration-038.sh (21 tests covering happy path, idempotency, no-op, content preservation, dot-prefixed dir skip)
  • bash tests/scripts/test-workflow-manifest.sh (214 tests — no schema changes)
  • End-to-end smoke flows from the phase-07 doc (research-analysis trigger, gap-analysis trigger, cache-valid skip, refinement self-healing, dismissal persistence, source dedup, no-topic discussion-entry)

Stack

🤖 Generated with Claude Code

leeovery and others added 13 commits May 10, 2026 16:26
…omputeSourceProvenance

Adds a shared helper `computeAnalysisCacheStatus(manifest, workflowsDir, kind)`
that reports research-analysis / gap-analysis cache state for self-healing
dispatch. Extends `computeSourceProvenance` to handle comma-joined source
strings (e.g. `research-analysis,gap-analysis`) as `from research-analysis +
gap-analysis`. Keeps `computePendingFromResearch` / `computePendingFromGaps`
for now (still used by workflow-specification-entry).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds skills/workflow-shared/references/self-healing.md to dispatch
research-analysis and gap-analysis based on cache staleness, with shared
arrivals tracker. Extends workflow-inception-process/scripts/discovery.cjs
to surface analysis_caches state, and wires refinement-session.md C.
Self-Healing Check to the orchestrator (Phase 6 placeholder removed).
Refinement-template.md drops the forward-note about Phase 7 and describes
the actual Self-Healing Arrivals semantics.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ap-analysis

Relocates the analyses from skills/workflow-discussion-entry/references/ to
the shared location. Cache check is now handled by the orchestrator
(self-healing.md), so each analysis assumes it is being called because its
cache is stale. Save Results sections rewritten to:

- Filter candidates against active map and phases.inception.dismissed[].
- Write inception items via manifest CLI with source provenance
  (research-analysis or gap-analysis); when both surface the same theme
  the second analysis comma-joins onto the existing source.
- Append newly-added names to the caller's tracker (in-conversation memory).
- Update existing .state/research-analysis.md / .state/discussion-gap-analysis.md
  cache files with the topic list.
- Update analysis_cache / gap_analysis_cache shapes (unchanged).

The original discussion-entry copies stay until the simplification pass
deletes them.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…pts and orphaned references

Removes Steps 3-6 (Route Based on Scenario, Research Analysis, Discussion
Gap Analysis, Display Options) — analyses now run via the self-healing
orchestrator at continue-epic boot-up and refinement entry. The no-topic
epic path becomes a one-line "what topic?" prompt that flows into the
existing validate-phase + gather-context pipeline.

Deleted:
- references/research-analysis.md (relocated to workflow-shared)
- references/discussion-gap-analysis.md (relocated to workflow-shared)
- references/route-scenario.md (no scenarios after the analyses move out)
- references/display-options.md (no suggested-topics menu)
- references/name-topic.md (Step 1 now handles naming)
- references/gather-context-research.md (source=research no longer set)
- references/gather-context-gap-analysis.md (source=gap-analysis no longer set)
- scripts/discovery.cjs (only caller was Step 3 routing)
- tests/scripts/test-discovery-for-discussion.cjs (script is gone)

Step renumbering: existing Steps 1, 2, 7, 8 become 1, 2, 3, 4. Frontmatter
allowed-tools drops the discovery.cjs whitelist and the .state cache rm
permissions (now owned by the relocated analyses).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…arch / pending_from_gaps

discovery.cjs now surfaces analysis_caches per epic detail (research-analysis
and gap-analysis cache status) using the shared computeAnalysisCacheStatus
helper. Removes pending_from_research / pending_from_gaps arrays and their
format() output, and removes gating.has_pending_discussions /
gating.has_pending_gaps / gating.has_research fields (no remaining callers
after the pending-rows collapse). The "discovery_map fresh items with source
provenance" surface replaces the legacy pending-rows concept.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…number

Inserts a new Step 5: Self-Healing that reads analysis_caches from the
selected epic's detail and dispatches the shared self-healing orchestrator
when a cache is stale. On return, re-runs discovery so Step 6's display
sees auto-added items, and stores new_arrivals in conversation memory for
the callout. Renames previous Steps 5-6 to 6-7.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… from epic-display-and-menu

Adds the ⚑ N new topic(s) added to the map from {analysis} callout above the
Discovery Map, rendered when the caller passes a non-empty new_arrivals
tracker (set up by the Self-Healing step). Drops the pending-from-research
and pending-from-gaps tree rows from both populated branches, the synthetic
Discussion section that fired when no discussion items existed, the status
legend entries for those two terms, and the recommendation lines and
soft-gate condition that referenced gating.has_pending_discussions. Drops
the menu's pending counts on the d/discuss option.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…d gap_topics

Adds 038-drop-surfaced-and-gap-topics.sh to clean up obsolete
phases.research.surfaced_topics and phases.discussion.gap_topics fields
from existing manifests. After Phase 7 these have no consumers — the
analyses now write directly to phases.inception.items with source provenance.

Migration is idempotent and bash 3.2 compatible. Cache fields
(analysis_cache, gap_analysis_cache) and all other phase content stay
untouched. Tests cover happy path (each field individually + both),
no-op-when-absent, idempotency, content preservation, multiple work units,
dot-prefixed-dir skip, and missing workflows dir.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…nance; remove pending_from_* coverage

- test-discovery-utils.cjs:
  - Add computeSourceProvenance suite covering plain, colon-prefixed, and
    comma-joined sources (e.g. "research-analysis,gap-analysis" → "from
    research-analysis + gap-analysis").
  - Add computeAnalysisCacheStatus suite covering both kinds (research-
    analysis, gap-analysis), all three statuses (valid / stale / absent),
    and the gap-analysis include of research-analysis.md.

- test-discovery-for-continue-epic.cjs:
  - Drop pending_from_research / pending_from_gaps suites.
  - Drop has_pending_discussions / has_pending_gaps / has_research gating
    assertions.
  - Add analysis_caches detail-shape assertion and format-output assertion.

- test-discovery-for-refinement.cjs:
  - Add analysis_caches suite (absent / stale / valid for both kinds + a
    format-output check).
  - Update sections-in-order test to include analysis_caches between
    dismissed and latest_session.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…' D. Filter and Save

Per CONVENTIONS — top-level conditionals inside lettered sections are H4,
not bold (bold is reserved for nested conditionals or prelude/post-STOP
positions). Switches the three branches in research-analysis.md and
discussion-gap-analysis.md sections D from bold "**If ...:**" to "#### If
..." and adds a closing rule with the next-section route.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… references

Issues found and fixed during a self-review:

- self-healing.md: B. Dispatch Stale Caches mixed sequential check with H4
  branches, where research and gap conditionals could BOTH fire (not
  mutually exclusive). Restructured into B. Run Research Analysis if Stale
  + C. Run Gap Analysis if Stale, with each branch routing explicitly to
  the next section per CONVENTIONS. Renumbered Dedupe (C → D) and Return
  (D → E). Sub-step markers shrunk from 51-52 chars to the required 49.

- refinement-session.md D: each H4 branch (arrival captured / no arrivals)
  now self-contains both the file write AND the commit AND the routing,
  per CONVENTIONS' "every conditional branch must include its own routing
  instruction." Commit message reflects self-healing arrivals when present
  ("self-healing added N topic(s) to map; seed refinement session log")
  vs the plain seed message otherwise. Cross-reference to orchestrator's
  Dedupe section updated to D (was C).

- continue-epic/SKILL.md Step 6: switched from "Pass new_arrivals if Step 5
  captured any" to the canonical `with new_arrivals = {new_arrivals}`
  parameter-passing syntax.

- continue-epic/references/display-epic-map.md: still rendered
  pending_from_research as a Discussion sub-tree row and an "N topic(s)
  from research not yet discussed" insight. Both come out — the discovery
  map handles fresh inception items now.

- workflow-manifest/SKILL.md: pull-example used `<name>.research
  surfaced_topics` which is gone post-Phase-7. Switched to the still-
  current `<name>.inception dismissed` pattern.

Tests still green: 404 discovery, 21 migration 038, 214 manifest.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…from_research helpers

End-to-end logic review uncovered two real gaps that the original Phase 7
plan missed:

1. **workflow-bridge bypassed continue-epic Step 5.** When a research or
   discussion phase concludes, workflow-bridge runs continue-epic discovery
   directly and renders epic-display-and-menu inline — it does NOT invoke
   /continue-epic, so the new Self-Healing step never fired. Result:
   user sees the post-conclusion map without analysis-derived items
   until they later return to /continue-epic.

   Fix: insert a B. Self-Healing section into epic-continuation.md after
   A. Run Epic Discovery, mirroring continue-epic's Step 5. Renumbered
   B/C/D to C/D/E. Added workflow-inception-process/scripts/discovery.cjs
   to workflow-bridge SKILL.md allowed-tools (the orchestrator invokes it).
   The display call now passes new_arrivals so the callout renders.

   Inception-continuation is unaffected — it explicitly bridges through
   /continue-epic, which already runs Self-Healing.

2. **Spec-entry's pending_from_research_count / has_pending were dead
   fields.** workflow-specification-entry/scripts/discovery.cjs imported
   computePendingFromResearch and exposed pending_from_research_count
   and has_pending in current_state. Migration 038 deletes
   surfaced_topics, so the helper always returned [] post-migration —
   and no skill reference reads either field. Removed the import, the
   loop, and the two output fields. Removed the corresponding three
   spec-discovery test cases. Removed computePendingFromResearch and
   computePendingFromGaps from discovery-utils entirely (no callers
   remain) and dropped their test suites too.

Tests: 386 discovery (down 18 from 404 — pending-from-research suites
removed) + 21 migration 038 + 214 manifest, all pass.

Out-of-scope cosmetics flagged during review and left for Phase 13 docs
cleanup: design.md's "the bridge brings user back to continue-epic"
wording (the bridge now self-heals inline, not via continue-epic
indirection); refinement-session.md B's continue-skips-C path could use
an inline comment.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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