Skip to content

Conversation

@TabishB
Copy link
Contributor

@TabishB TabishB commented Dec 28, 2025

Summary

  • Add instruction-loader module providing template loading and change context enrichment
  • Implements Slice 3 of the artifact-graph system, building on graph operations (Slice 1) and change creation utilities (Slice 2)
  • New functions: loadTemplate, loadChangeContext, generateInstructions, formatChangeStatus

Test plan

  • Build passes
  • All 21 new instruction-loader tests pass
  • Change validates with openspec validate add-instruction-loader

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features
    • Added instruction loader system for managing artifact templates and workflow state
    • Introduced change context assembly with automatic completion detection across artifacts
    • Implemented dependency tracking showing completion status (ready, blocked, done)
    • Added formatted status output with per-artifact paths and missing dependency details
    • Enhanced template loading with error handling and schema resolution

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 28, 2025

Warning

Rate limit exceeded

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

⌛ 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 7f2fd97 and 8150846.

📒 Files selected for processing (1)
  • openspec/specs/instruction-loader/spec.md
📝 Walkthrough

Walkthrough

A new instruction-loader module is introduced to the artifact-graph core, providing utilities for loading templates, constructing change contexts from project state, generating enriched artifact instructions with dependency metadata, and formatting comprehensive change status reports. Public APIs are re-exported from the main index.

Changes

Cohort / File(s) Summary
Core implementation
src/core/artifact-graph/instruction-loader.ts, src/core/artifact-graph/index.ts
Adds instruction-loader module with TemplateLoadError exception class, five type interfaces (ChangeContext, ArtifactInstructions, DependencyStatus, ArtifactStatus, ChangeStatus), and six public functions (loadTemplate, loadChangeContext, generateInstructions, formatChangeStatus) plus two internal helpers. Index file re-exports all public exports.
Test suite
test/core/artifact-graph/instruction-loader.test.ts
Comprehensive test coverage for all public functions including template loading with error cases, change context construction with schema resolution, instruction generation with dependency tracking, and change status formatting with artifact ordering. Uses temporary directories and filesystem mocking.
Specification & documentation
openspec/specs/instruction-loader/spec.md, openspec/changes/archive/2025-12-28-add-instruction-loader/*, openspec/changes/add-instruction-loader/tasks.md
Adds specification document defining template loading scenarios, error handling, change context assembly, instruction enrichment (metadata, dependencies, unlocked artifacts), and status formatting. Task files updated to reflect completed implementation and archived for change management.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant SchemaResolver
    participant FileSystem
    participant ArtifactGraph
    participant InstructionLoader

    rect rgb(230, 245, 250)
    Note over Caller,InstructionLoader: Load Change Context
    Caller->>InstructionLoader: loadChangeContext(projectRoot, changeName, schemaName?)
    InstructionLoader->>SchemaResolver: resolve schema
    InstructionLoader->>ArtifactGraph: create graph from manifest
    InstructionLoader->>FileSystem: detect completed artifacts (proposal.md)
    InstructionLoader-->>Caller: ChangeContext
    end

    rect rgb(240, 250, 240)
    Note over Caller,InstructionLoader: Generate Instructions
    Caller->>InstructionLoader: generateInstructions(context, artifactId)
    InstructionLoader->>FileSystem: loadTemplate(schemaName, templatePath)
    InstructionLoader->>ArtifactGraph: compute dependency status
    InstructionLoader->>ArtifactGraph: get unlocked artifacts
    InstructionLoader-->>Caller: ArtifactInstructions
    end

    rect rgb(250, 240, 240)
    Note over Caller,InstructionLoader: Format Change Status
    Caller->>InstructionLoader: formatChangeStatus(context)
    loop for each artifact
        InstructionLoader->>ArtifactGraph: determine status (ready/blocked/done)
    end
    InstructionLoader->>ArtifactGraph: sort by build order
    InstructionLoader-->>Caller: ChangeStatus
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Possibly related PRs

Poem

🐰 Hop, hop, templates load with care,
Graphs and schemas everywhere!
Context crafted, instructions shine,
Status formatted, everything's fine!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main addition: an instruction-loader module for template loading and change context enrichment. It reflects the primary feature being introduced in this pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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.

@vibe-kanban-cloud
Copy link

Review Complete

Your review story is ready!

View Story

Comment !reviewfast on this PR to re-generate the story.

Add the instruction-loader module that provides:
- loadTemplate: Load templates from schema directories
- loadChangeContext: Combine artifact graph with completion state
- generateInstructions: Enrich templates with change-specific context
- formatChangeStatus: Format change status as readable output

This is Slice 3 of the artifact-graph system, building on the graph
operations (Slice 1) and change creation utilities (Slice 2).
@TabishB TabishB force-pushed the feat/add-instruction-loader branch from 9aab4bd to bb97257 Compare December 28, 2025 06:22
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9aab4bd and bb97257.

📒 Files selected for processing (5)
  • openspec/changes/add-instruction-loader/specs/instruction-loader/spec.md
  • openspec/changes/add-instruction-loader/tasks.md
  • src/core/artifact-graph/index.ts
  • src/core/artifact-graph/instruction-loader.ts
  • test/core/artifact-graph/instruction-loader.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/core/artifact-graph/index.ts
🧰 Additional context used
📓 Path-based instructions (3)
openspec/changes/**/*.md

📄 CodeRabbit inference engine (openspec/AGENTS.md)

Scaffold proposal using proposal.md, tasks.md, optional design.md, and delta specs under openspec/changes/<id>/

Files:

  • openspec/changes/add-instruction-loader/tasks.md
  • openspec/changes/add-instruction-loader/specs/instruction-loader/spec.md
openspec/changes/*/tasks.md

📄 CodeRabbit inference engine (openspec/AGENTS.md)

Ensure tasks.md contains implementation checklist with numbered sections and checkbox items

Files:

  • openspec/changes/add-instruction-loader/tasks.md
openspec/changes/**/specs/**/spec.md

📄 CodeRabbit inference engine (openspec/AGENTS.md)

openspec/changes/**/specs/**/spec.md: Use ## ADDED|MODIFIED|REMOVED|RENAMED Requirements headers in spec delta files
Include at least one #### Scenario: per requirement in spec delta files
Use #### Scenario: Name format (4 hashtags) for scenario headers, not bullets or bold text
Use ## ADDED Requirements for new orthogonal capabilities that can stand alone; use ## MODIFIED Requirements for behavior changes of existing requirements
When using MODIFIED Requirements, paste the full requirement block including header and all scenarios

Files:

  • openspec/changes/add-instruction-loader/specs/instruction-loader/spec.md
🧠 Learnings (8)
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/*/tasks.md : Ensure `tasks.md` contains implementation checklist with numbered sections and checkbox items

Applied to files:

  • openspec/changes/add-instruction-loader/tasks.md
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/**/*.md : Scaffold proposal using `proposal.md`, `tasks.md`, optional `design.md`, and delta specs under `openspec/changes/<id>/`

Applied to files:

  • openspec/changes/add-instruction-loader/tasks.md
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/*/proposal.md : Ensure `proposal.md` includes sections: Why (1-2 sentences), What Changes (bullet list with breaking change markers), and Impact (affected specs and code)

Applied to files:

  • openspec/changes/add-instruction-loader/tasks.md
  • openspec/changes/add-instruction-loader/specs/instruction-loader/spec.md
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/**/specs/**/spec.md : Use `## ADDED|MODIFIED|REMOVED|RENAMED Requirements` headers in spec delta files

Applied to files:

  • openspec/changes/add-instruction-loader/specs/instruction-loader/spec.md
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/**/specs/**/spec.md : Use `## ADDED Requirements` for new orthogonal capabilities that can stand alone; use `## MODIFIED Requirements` for behavior changes of existing requirements

Applied to files:

  • openspec/changes/add-instruction-loader/specs/instruction-loader/spec.md
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/**/specs/**/spec.md : When using MODIFIED Requirements, paste the full requirement block including header and all scenarios

Applied to files:

  • openspec/changes/add-instruction-loader/specs/instruction-loader/spec.md
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/**/specs/**/spec.md : Include at least one `#### Scenario:` per requirement in spec delta files

Applied to files:

  • openspec/changes/add-instruction-loader/specs/instruction-loader/spec.md
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/**/specs/**/spec.md : Use `#### Scenario: Name` format (4 hashtags) for scenario headers, not bullets or bold text

Applied to files:

  • openspec/changes/add-instruction-loader/specs/instruction-loader/spec.md
🧬 Code graph analysis (1)
test/core/artifact-graph/instruction-loader.test.ts (1)
src/core/artifact-graph/instruction-loader.ts (5)
  • loadTemplate (105-132)
  • TemplateLoadError (11-19)
  • loadChangeContext (142-159)
  • generateInstructions (169-192)
  • formatChangeStatus (228-269)
🔇 Additional comments (9)
openspec/changes/add-instruction-loader/tasks.md (1)

1-13: LGTM! Well-structured task checklist.

The tasks.md file properly follows the coding guidelines with a clear implementation checklist using numbered sections and checkbox items. All tasks are concrete, verifiable, and align well with the actual implementation delivered in this PR.

test/core/artifact-graph/instruction-loader.test.ts (1)

1-264: LGTM! Excellent test coverage.

The test suite is comprehensive and well-structured, covering all public APIs with 21 test cases across happy paths, error scenarios, and edge cases. The use of temporary directories with proper setup/teardown is a good practice. The tests validate:

  • Template loading from schemas with proper error handling
  • Change context construction with schema resolution and completion detection
  • Instruction generation with metadata, dependencies, and unlock information
  • Status formatting with correct artifact state transitions and build ordering
src/core/artifact-graph/instruction-loader.ts (7)

8-19: LGTM! Well-designed error class.

The TemplateLoadError class properly extends Error and includes the templatePath context, which is valuable for debugging template loading issues. Setting the name property enables better error identification in logs and error handlers.


21-95: LGTM! Clear and well-documented type definitions.

The interfaces are comprehensive and well-structured:

  • ChangeContext effectively combines graph state with metadata
  • ArtifactInstructions provides all necessary context for artifact creation
  • ArtifactStatus uses a discriminated union pattern correctly with missingDeps optional for non-blocked states
  • All types have clear JSDoc documentation

97-132: LGTM! Robust template loading with proper error handling.

The function correctly validates the schema and template existence before reading, and wraps all errors in the custom TemplateLoadError with appropriate context. The use of synchronous file operations is appropriate for this template-loading use case.


134-159: LGTM! Clean context loading implementation.

The function effectively composes the schema resolver, graph builder, and completion detector to create a comprehensive ChangeContext. The default schema parameter of 'spec-driven' is a sensible choice for the primary use case.


161-192: LGTM! Well-composed instruction generator.

The function properly validates artifact existence with a contextual error message, then composes the template loader and helper functions to build comprehensive ArtifactInstructions including all metadata, dependencies, and unlock information.


194-220: LGTM! Clean helper functions.

Both helpers are well-implemented:

  • getDependencyStatus correctly maps dependencies with completion status
  • getUnlockedArtifacts finds reverse dependencies and sorts for consistency

The O(n) iteration in getUnlockedArtifacts is appropriate for typical artifact graph sizes.


222-269: LGTM! Correct status formatting logic.

The function properly determines artifact states (done/ready/blocked) using graph methods and correctly:

  • Includes missingDeps only for blocked artifacts
  • Sorts results by build order for consistency
  • Computes overall completion status via graph.isComplete()

## Purpose
Load templates from schema directories and enrich them with change-specific context for guiding artifact creation.

## Requirements
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Use ## ADDED Requirements header per coding guidelines.

The spec delta file should use ## ADDED Requirements instead of ## Requirements. Since this introduces new orthogonal capabilities (template loading, context loading, instruction generation, status formatting) that can stand alone, the ADDED header is appropriate.

As per coding guidelines, spec delta files must use ## ADDED|MODIFIED|REMOVED|RENAMED Requirements headers.

🔎 Proposed fix
-## Requirements
+## ADDED Requirements
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## Requirements
## ADDED Requirements
🤖 Prompt for AI Agents
In openspec/changes/add-instruction-loader/specs/instruction-loader/spec.md
around line 6, the header currently reads "## Requirements" but per spec-delta
guidelines it must be one of the delta types; update the header to "## ADDED
Requirements" (exact casing and spacing) so the file uses the required spec
delta header for newly introduced capabilities.

- Move change to archive as 2025-12-28-add-instruction-loader
- Create instruction-loader spec with 4 requirements
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bb97257 and 7f2fd97.

📒 Files selected for processing (5)
  • openspec/changes/archive/2025-12-28-add-instruction-loader/design.md
  • openspec/changes/archive/2025-12-28-add-instruction-loader/proposal.md
  • openspec/changes/archive/2025-12-28-add-instruction-loader/specs/instruction-loader/spec.md
  • openspec/changes/archive/2025-12-28-add-instruction-loader/tasks.md
  • openspec/specs/instruction-loader/spec.md
🧰 Additional context used
📓 Path-based instructions (3)
openspec/changes/**/*.md

📄 CodeRabbit inference engine (openspec/AGENTS.md)

Scaffold proposal using proposal.md, tasks.md, optional design.md, and delta specs under openspec/changes/<id>/

Files:

  • openspec/changes/archive/2025-12-28-add-instruction-loader/tasks.md
  • openspec/changes/archive/2025-12-28-add-instruction-loader/specs/instruction-loader/spec.md
openspec/specs/**/spec.md

📄 CodeRabbit inference engine (openspec/AGENTS.md)

Use SHALL/MUST for normative requirements in spec files; avoid should/may unless intentionally non-normative

Files:

  • openspec/specs/instruction-loader/spec.md
openspec/changes/**/specs/**/spec.md

📄 CodeRabbit inference engine (openspec/AGENTS.md)

openspec/changes/**/specs/**/spec.md: Use ## ADDED|MODIFIED|REMOVED|RENAMED Requirements headers in spec delta files
Include at least one #### Scenario: per requirement in spec delta files
Use #### Scenario: Name format (4 hashtags) for scenario headers, not bullets or bold text
Use ## ADDED Requirements for new orthogonal capabilities that can stand alone; use ## MODIFIED Requirements for behavior changes of existing requirements
When using MODIFIED Requirements, paste the full requirement block including header and all scenarios

Files:

  • openspec/changes/archive/2025-12-28-add-instruction-loader/specs/instruction-loader/spec.md
🧠 Learnings (8)
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/*/tasks.md : Ensure `tasks.md` contains implementation checklist with numbered sections and checkbox items

Applied to files:

  • openspec/changes/archive/2025-12-28-add-instruction-loader/tasks.md
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/**/*.md : Scaffold proposal using `proposal.md`, `tasks.md`, optional `design.md`, and delta specs under `openspec/changes/<id>/`

Applied to files:

  • openspec/changes/archive/2025-12-28-add-instruction-loader/tasks.md
  • openspec/specs/instruction-loader/spec.md
  • openspec/changes/archive/2025-12-28-add-instruction-loader/specs/instruction-loader/spec.md
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/**/specs/**/spec.md : Use `## ADDED Requirements` for new orthogonal capabilities that can stand alone; use `## MODIFIED Requirements` for behavior changes of existing requirements

Applied to files:

  • openspec/specs/instruction-loader/spec.md
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/**/specs/**/spec.md : Use `## ADDED|MODIFIED|REMOVED|RENAMED Requirements` headers in spec delta files

Applied to files:

  • openspec/specs/instruction-loader/spec.md
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/**/specs/**/spec.md : Include at least one `#### Scenario:` per requirement in spec delta files

Applied to files:

  • openspec/specs/instruction-loader/spec.md
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/**/specs/**/spec.md : When using MODIFIED Requirements, paste the full requirement block including header and all scenarios

Applied to files:

  • openspec/specs/instruction-loader/spec.md
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/*/proposal.md : Ensure `proposal.md` includes sections: Why (1-2 sentences), What Changes (bullet list with breaking change markers), and Impact (affected specs and code)

Applied to files:

  • openspec/specs/instruction-loader/spec.md
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/**/specs/**/spec.md : Use `#### Scenario: Name` format (4 hashtags) for scenario headers, not bullets or bold text

Applied to files:

  • openspec/specs/instruction-loader/spec.md
🔇 Additional comments (2)
openspec/changes/archive/2025-12-28-add-instruction-loader/specs/instruction-loader/spec.md (1)

1-70: Spec delta structure is compliant and well-organized.

The archived spec delta correctly uses ## ADDED Requirements header, follows 4-hashtag scenario naming conventions, and includes multiple scenarios per requirement with normative "SHALL" statements. The content aligns well with the implementation functions described in the PR summary.

openspec/changes/archive/2025-12-28-add-instruction-loader/tasks.md (1)

1-13: Tasks checklist is complete and well-scoped.

All 9 implementation tasks are marked complete, covering spec creation, function implementations, public API exports, comprehensive test coverage, and build verification. The checklist aligns with PR objectives.

@TabishB TabishB merged commit 11e1955 into main Dec 28, 2025
7 checks passed
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.

2 participants