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:
152
examples/infospace-with-history/output/metrics/metrics-report.md
Normal file
152
examples/infospace-with-history/output/metrics/metrics-report.md
Normal file
@@ -0,0 +1,152 @@
|
||||
# Infospace Metrics Report
|
||||
|
||||
**Report Date:** 2026-02-10
|
||||
**Chapters Processed:** 1 of 35
|
||||
|
||||
---
|
||||
|
||||
## Completeness Metrics
|
||||
|
||||
### VSM Concept Coverage
|
||||
|
||||
**Coverage: 5 of 12 concepts (41.7%)**
|
||||
|
||||
| Concept | Covered | Mapping Count |
|
||||
|---------|---------|---------------|
|
||||
| S1 (Operations) | Yes | 8 |
|
||||
| S2 (Coordination) | Yes | 3 |
|
||||
| S3 (Control) | No | 0 |
|
||||
| S3* (Audit) | No | 0 |
|
||||
| S4 (Intelligence) | Yes | 2 |
|
||||
| S5 (Policy) | No | 0 |
|
||||
| Recursion | Yes | 1 |
|
||||
| Variety | No | 0 |
|
||||
| Requisite Variety | No | 0 |
|
||||
| Attenuation/Amplification | No | 0 |
|
||||
| Algedonic Signals | No | 0 |
|
||||
| Viability | Yes | 1 |
|
||||
| Autonomy | No | 0 |
|
||||
|
||||
**Uncovered concepts:** S3, S3*, S5, Variety, Requisite Variety,
|
||||
Attenuation/Amplification, Algedonic Signals, Autonomy
|
||||
|
||||
**Assessment:** Coverage is concentrated on S1 (Operations), which is expected
|
||||
for the opening chapter focused on production. The remaining concepts require
|
||||
chapters addressing regulation (S3), policy (S5), and information management
|
||||
(S3*, variety engineering).
|
||||
|
||||
### Chapter Coverage
|
||||
|
||||
**Coverage: 1 of 35 chapters (2.9%)**
|
||||
|
||||
| Book | Chapters Available | Chapters Processed |
|
||||
|------|-------------------|-------------------|
|
||||
| Introduction | 1 | 0 |
|
||||
| Book I | 11 | 1 |
|
||||
| Book II | 6 | 0 |
|
||||
| Book III | 4 | 0 |
|
||||
| Book IV | 10 | 0 |
|
||||
| Book V | 3 | 0 |
|
||||
|
||||
### Entity Count
|
||||
|
||||
**Total distinct entities: 13**
|
||||
|
||||
| Economic Domain | Count |
|
||||
|----------------|-------|
|
||||
| Production | 10 |
|
||||
| Distribution | 1 |
|
||||
| Exchange | 1 |
|
||||
| General Theory | 1 |
|
||||
| Consumption | 0 |
|
||||
| Accumulation | 0 |
|
||||
| Regulation | 0 |
|
||||
|
||||
**Assessment:** Entity extraction is heavily skewed toward Production, reflecting
|
||||
the chapter's content. Domains like Accumulation and Regulation will require
|
||||
Book II and Book V chapters respectively.
|
||||
|
||||
### Mapping Count
|
||||
|
||||
**Total mappings: 14**
|
||||
|
||||
Mapping strength distribution:
|
||||
- Strong: 11 (78.6%)
|
||||
- Moderate: 3 (21.4%)
|
||||
- Weak: 0 (0.0%)
|
||||
|
||||
---
|
||||
|
||||
## Consistency Metrics
|
||||
|
||||
### Terminology Consistency
|
||||
|
||||
**Score: 1.0**
|
||||
|
||||
With only one chapter processed, no cross-chapter terminology conflicts exist.
|
||||
All entity names follow Smith's own terminology and the naming conventions
|
||||
specified in the extraction rules. No synonyms detected.
|
||||
|
||||
**Flagged issues:** None
|
||||
|
||||
### Cross-reference Integrity
|
||||
|
||||
**Score: 1.0**
|
||||
|
||||
All entity references in mapping documents point to entities defined in the
|
||||
entities output. No broken references detected.
|
||||
|
||||
**Flagged issues:** None
|
||||
|
||||
### Schema Compliance
|
||||
|
||||
**Compliance: 100%**
|
||||
|
||||
| Document Type | Total | Compliant | Non-compliant |
|
||||
|--------------|-------|-----------|---------------|
|
||||
| Entity documents | 13 | 13 | 0 |
|
||||
| Mapping documents | 14 | 14 | 0 |
|
||||
| Analysis documents | 1 | 1 | 0 |
|
||||
|
||||
All documents contain their required sections as defined by their respective
|
||||
schemas.
|
||||
|
||||
---
|
||||
|
||||
## Recommendations
|
||||
|
||||
### Priority Actions
|
||||
|
||||
1. **Process remaining Book I chapters** to build S2 and S3 coverage through
|
||||
price theory (Chapters 5-7) and wage/profit regulation (Chapters 8-10).
|
||||
|
||||
2. **Process Book IV chapters** for S5 (Policy) coverage, as these address
|
||||
political economy systems (mercantilism, free trade).
|
||||
|
||||
3. **Process Book V chapters** for S3 (Control) coverage through sovereign
|
||||
revenue and public administration.
|
||||
|
||||
### Coverage Gaps to Watch
|
||||
|
||||
- **Variety and requisite variety** are core VSM concepts that may not map
|
||||
directly to Smith's vocabulary. Consider whether Smith's discussions of
|
||||
market size, competition, and information asymmetry can be mapped to
|
||||
variety management.
|
||||
|
||||
- **Algedonic signals** may appear in discussions of famine, market crises,
|
||||
or economic distress in later chapters.
|
||||
|
||||
- **S3* (Audit)** is the most difficult system to map in classical economics.
|
||||
Watch for discussions of market inspections, trade regulation enforcement,
|
||||
or quality verification.
|
||||
|
||||
### Quality Notes
|
||||
|
||||
- Current consistency scores (1.0 across all metrics) will be the baseline.
|
||||
As more chapters are processed, terminology conflicts and cross-reference
|
||||
issues are likely to emerge and should be actively managed.
|
||||
|
||||
- The high proportion of Strong mappings (78.6%) is appropriate for Chapter 1
|
||||
given its focus on operations, which map cleanly to S1. Later chapters
|
||||
covering more abstract economic concepts may yield more Moderate and Weak
|
||||
mappings.
|
||||
Reference in New Issue
Block a user