feat(llm): add LLM integration module with OpenRouter and Claude Code adapters
Implements markitect/llm/ package with concrete LLMAdapter implementations:
- OpenRouterAdapter: HTTP via urllib with retry/backoff on 429/5xx
- ClaudeCodeAdapter: subprocess-based Claude CLI with stdin piping
- Factory pattern: create_adapter("openrouter") or create_adapter("claude-code")
- API key resolution chain: constructor > env var > project-root key file
- 42 unit tests, 2 integration tests (gated on API key / CLI availability)
Also adds the infospace-with-history example with Wealth of Nations VSM
analysis pipeline, templates, schemas, source chapters, and processed
output for chapters 1-2. process_chapters.py now supports --provider
and --model flags for automatic LLM-driven processing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
# Chapter Analysis Schema v1.0
|
||||
|
||||
Schema definition for per-chapter VSM analysis documents.
|
||||
|
||||
## Required Sections
|
||||
|
||||
### Chapter Summary
|
||||
A concise summary of the chapter's main economic arguments and themes (50-300 words).
|
||||
|
||||
### Entities Extracted
|
||||
A bulleted list of all economic entities extracted from this chapter.
|
||||
Each entry should include the entity name and a brief description.
|
||||
Must list at least one entity.
|
||||
|
||||
### VSM Mappings
|
||||
A bulleted list of all entity-to-VSM mappings derived from this chapter.
|
||||
Each entry should include the entity name, the VSM concept, and the mapping strength.
|
||||
|
||||
### VSM Coverage
|
||||
Assessment of which VSM systems are represented by the mappings from this chapter:
|
||||
- System 1 (Operations): covered/not covered
|
||||
- System 2 (Coordination): covered/not covered
|
||||
- System 3 (Control): covered/not covered
|
||||
- System 3* (Audit): covered/not covered
|
||||
- System 4 (Intelligence): covered/not covered
|
||||
- System 5 (Policy): covered/not covered
|
||||
|
||||
Must assess coverage for all six system levels.
|
||||
|
||||
### Gaps & Observations
|
||||
Identification of:
|
||||
- VSM systems not yet covered by entities from this chapter
|
||||
- Entities that were difficult to map
|
||||
- Notable patterns or themes in the mappings
|
||||
- Suggestions for further analysis
|
||||
|
||||
## Optional Sections
|
||||
|
||||
### Cross-chapter References
|
||||
References to entities or themes in other chapters that relate to
|
||||
findings in this chapter. Useful for building cross-chapter coherence.
|
||||
|
||||
## Validation Rules
|
||||
|
||||
1. The document MUST contain an H1 heading with the chapter analysis title.
|
||||
2. The document MUST contain all five required sections.
|
||||
3. The Entities Extracted section MUST list at least one entity.
|
||||
4. The VSM Coverage section MUST assess all six VSM system levels.
|
||||
@@ -0,0 +1,37 @@
|
||||
# Economic Entity Schema v1.0
|
||||
|
||||
Schema definition for economic entities extracted from source texts.
|
||||
|
||||
## Required Sections
|
||||
|
||||
### Definition
|
||||
A clear, analytical definition of the economic entity (20-150 words).
|
||||
|
||||
### Source Chapter
|
||||
The specific chapter from which this entity was extracted,
|
||||
including book and chapter number.
|
||||
|
||||
### Context
|
||||
The broader context in which this entity appears within the source text.
|
||||
Describe the argument or passage where the entity is discussed.
|
||||
|
||||
### Economic Domain
|
||||
The area of economics this entity belongs to (e.g., labour economics,
|
||||
trade theory, market theory, institutional economics).
|
||||
|
||||
## Optional Sections
|
||||
|
||||
### Smith's Original Wording
|
||||
A direct quotation from Adam Smith's text that defines or describes
|
||||
this entity. Must be enclosed in quotation marks with chapter reference.
|
||||
|
||||
### Modern Interpretation
|
||||
How this entity is understood in modern economic theory, including
|
||||
any evolution in meaning since Smith's time.
|
||||
|
||||
## Validation Rules
|
||||
|
||||
1. The document MUST contain an H1 heading with the entity name.
|
||||
2. The document MUST contain all four required sections: Definition, Source Chapter, Context, Economic Domain.
|
||||
3. The Definition section MUST be between 20 and 150 words.
|
||||
4. The Source Chapter section MUST cite a specific chapter (e.g., "Book I, Chapter 1").
|
||||
@@ -0,0 +1,40 @@
|
||||
# VSM Concept Schema v1.0
|
||||
|
||||
Schema definition for Viable System Model concept documents.
|
||||
|
||||
## Required Sections
|
||||
|
||||
### Definition
|
||||
A clear, concise definition of the VSM concept (20-200 words).
|
||||
|
||||
### System Classification
|
||||
Which VSM system(s) this concept belongs to. Must reference at least one of:
|
||||
- System 1 (Operations)
|
||||
- System 2 (Coordination)
|
||||
- System 3 (Control)
|
||||
- System 3* (Audit)
|
||||
- System 4 (Intelligence)
|
||||
- System 5 (Policy)
|
||||
|
||||
### Key Properties
|
||||
Bulleted list of essential properties or characteristics of this concept.
|
||||
|
||||
### Relationships
|
||||
How this concept relates to other VSM concepts. List related concepts
|
||||
and the nature of the relationship (e.g., "regulates", "enables", "constrains").
|
||||
|
||||
## Optional Sections
|
||||
|
||||
### Examples
|
||||
Concrete examples illustrating the concept in organisational contexts.
|
||||
|
||||
### Beer's Original Formulation
|
||||
Direct reference to how Stafford Beer originally described or defined
|
||||
this concept, with citation to the relevant work.
|
||||
|
||||
## Validation Rules
|
||||
|
||||
1. The document MUST contain an H1 heading with the concept name.
|
||||
2. The document MUST contain all four required sections: Definition, System Classification, Key Properties, Relationships.
|
||||
3. The Definition section MUST be between 20 and 200 words.
|
||||
4. The System Classification section MUST reference at least one VSM system (S1-S5 or S3*).
|
||||
@@ -0,0 +1,41 @@
|
||||
# VSM Mapping Schema v1.0
|
||||
|
||||
Schema definition for entity-to-VSM concept mapping documents.
|
||||
|
||||
## Required Sections
|
||||
|
||||
### Economic Entity Reference
|
||||
The name and identifier of the economic entity being mapped.
|
||||
Must correspond to an existing entity in the entities collection.
|
||||
|
||||
### VSM Concept Reference
|
||||
The name and identifier of the VSM concept being mapped to.
|
||||
Must correspond to an existing concept in the concepts collection.
|
||||
|
||||
### Mapping Rationale
|
||||
A detailed explanation of why this economic entity maps to this VSM concept.
|
||||
Should reference specific properties of both the entity and the concept
|
||||
that justify the mapping (minimum 30 words).
|
||||
|
||||
### Mapping Strength
|
||||
One of:
|
||||
- **Strong**: Direct structural or functional correspondence
|
||||
- **Moderate**: Clear conceptual parallel with some differences
|
||||
- **Weak**: Loose analogy or partial overlap
|
||||
|
||||
## Optional Sections
|
||||
|
||||
### Counter-arguments
|
||||
Reasons why this mapping might be contested or why the entity
|
||||
might not fit the VSM concept perfectly.
|
||||
|
||||
### Alternative Mappings
|
||||
Other VSM concepts this entity could plausibly map to,
|
||||
with brief rationale for each alternative.
|
||||
|
||||
## Validation Rules
|
||||
|
||||
1. The document MUST contain an H1 heading in the format "Entity Name -> VSM Concept Name".
|
||||
2. The document MUST contain all four required sections: Economic Entity Reference, VSM Concept Reference, Mapping Rationale, Mapping Strength.
|
||||
3. The Mapping Strength MUST be one of: Strong, Moderate, Weak.
|
||||
4. The document MUST reference both an economic entity and a VSM concept.
|
||||
Reference in New Issue
Block a user