Created: January 14, 2026 Project: @stratiqx/cal-runtime Phase: 1 - Validation & Stabilization
This project validates and productizes the Cormorant Agentic Language (CAL) runtime engine. The language and core implementation were built during a Claude Web session on January 9, 2026. This phase focuses on local validation, testing, and preparation for browser deployment.
- Project structure created (
c:/workplace/cal-runtime) - Package.json configured with TypeScript + Vitest
- Directory structure established
- Grammar file copied (
src/parser/grammar.pegjs) - Test fixtures copied (tailwind-cascade.cal, sample-data.json)
- Analysis document created in cal/docs
- Install dependencies
- Compile PEG grammar
- Create TypeScript parser wrapper
- Port executor to TypeScript
- Write initial tests
- Financial calculator implementation
- Browser build configuration
- Documentation generation
- Publishing setup
| File | Purpose | Status |
|---|---|---|
cormorant.pegjs |
PEG grammar (~390 lines) | ✅ Copied |
cal.js |
Parser wrapper (~280 lines) | Need to port to TS |
executor.js |
Execution engine (~14KB) | Need to port to TS |
analysis-engine.js |
6D scoring (~11KB) | Need to port to TS |
data-adapters.js |
Data sources (~8KB) | Need to port to TS |
alert-adapters.js |
Notifications (~6KB) | Need to port to TS |
agent.js |
AI integration (~18KB) | Defer to Phase 4 |
run.js |
CLI runner (~10KB) | Will rewrite |
repl.js |
Interactive mode (~5KB) | Will rewrite |
| File | Purpose |
|---|---|
sample-data.json |
4 test entities (Tailwind, StackOverflow, Copilot, Stable) |
tailwind-cascade.cal |
Example CAL script (UC-002 case study) |
closed-loop-pipeline.cal |
Full DRIFT + FETCH example |
FORAGE- Query/search with WHERE, ACROSS, DEPTH, SURFACEDIVE- Deep analysis with INTO, WHEN, TRACE, EMITPERCH- Observe position with ONLISTEN- Monitor signals with FORWAKE- Time triggers with AFTERCHIRP- AlertsTRACE- Cascade pathways with FROMSURFACE- Output with AS
DRIFT- Gap measurement (METHODOLOGY, PERFORMANCE, GAP)FETCH- Action decisions (THRESHOLD, ON EXECUTE/CONFIRM/QUEUE/WAIT)
Note: DRIFT and FETCH are mentioned in all specs but not in current grammar. Need to add these before testing.
- Basic FORAGE parsing
- FORAGE with WHERE conditions
- FORAGE with dimensions (ACROSS)
- FORAGE with depth
- Complete FORAGE statement
- DIVE parsing
- PERCH/LISTEN/WAKE combinations
- CHIRP alerts
- Comment handling
- Case insensitivity
- Error cases (invalid syntax)
- FORAGE execution with WHERE filtering
- 6D dimension scoring (Sound × Space × Time)
- Cascade depth traversal
- DRIFT calculation
- FETCH decision thresholds
- Financial impact calculation
- Empty result handling
- Invalid dimension handling
- Tailwind cascade example (UC-002)
- Full pipeline (SENSE → ANALYZE → MEASURE → DECIDE → ACT)
- End-to-end with sample-data.json
Question: How is cascade multiplier calculated?
Current Understanding:
Multiplier based on (dimensions × depth):
- 15+: 10-15×
- 10-14: 6-10×
- 6-9: 4-6×
- 3-5: 2-4×
- <3: 1.5-2×
Action: Document exact formula from analysis-engine.js
Question: Are DRIFT and FETCH implemented in grammar?
Current Status: NOT in grammar.pegjs Action: Add to grammar before testing
Question: How are multiple dimension scores combined?
Options:
- Average all dimension scores?
- Max score?
- Weighted by dimension type?
Action: Check analysis-engine.js implementation
cd c:/workplace/cal-runtime
npm installUpdate src/parser/grammar.pegjs:
DriftStatement
= DRIFT _ target:Identifier _ METHODOLOGY _ m:Integer _ PERFORMANCE _ p:Integer _ gap:GapClause? _ {
return { type: "Drift", target, methodology: m, performance: p, gap };
}
FetchStatement
= FETCH _ target:Identifier _ THRESHOLD _ t:Integer _ actions:FetchActions* _ {
return { type: "Fetch", target, threshold: t, actions };
}
// ... add supporting rulesnpm run build:grammarCreate src/parser/index.ts with TypeScript types and error handling.
// tests/parser/basic.test.ts
import { parse } from '../src/parser';
test('parse basic FORAGE', () => {
const result = parse('FORAGE entities');
expect(result.success).toBe(true);
});npm test- All dependencies installed
- Grammar compiles without errors
- Parser test suite passes (20+ tests)
- Executor test suite passes (15+ tests)
- Tailwind example runs locally
- Output matches expected UC-002 results
- Documentation updated with findings
-
src/parser/index.ts- Parser wrapper -
src/parser/ast.ts- AST type definitions -
src/executor/index.ts- Main executor -
src/executor/handlers/forage.ts- FORAGE handler -
src/executor/handlers/drift.ts- DRIFT handler -
src/executor/handlers/fetch.ts- FETCH handler -
src/analyzer/dimension-scorer.ts- 6D scoring -
src/analyzer/cascade-mapper.ts- Cascade pathways -
src/analyzer/financial-calculator.ts- Impact calculation -
src/types/index.ts- Shared types
-
tests/parser/forage.test.ts -
tests/parser/drift.test.ts -
tests/parser/fetch.test.ts -
tests/executor/forage-execution.test.ts -
tests/executor/drift-execution.test.ts -
tests/analyzer/scoring.test.ts -
tests/integration/tailwind-case.test.ts
-
docs/API.md -
docs/TESTING.md -
docs/ARCHITECTURE.md
- TypeScript over JavaScript - Type safety is critical for execution engine
- Vitest over Jest - Faster, modern, better ESM support
- Monorepo structure - Keep browser/node builds in same package
- Defer AI integration - Focus on core runtime first (Phase 4)
{
"dependencies": {
"peggy": "^4.0.2" // PEG parser generator
},
"devDependencies": {
"typescript": "^5.3.3",
"vitest": "^1.2.0",
"@vitest/coverage-v8": "^1.2.0",
"@types/node": "^20.11.0"
}
}- Original implementation:
c:/workplace/cal/docs/ - Analysis document:
c:/workplace/cal/docs/CAL-IMPLEMENTATION-ANALYSIS.md - Complete reference:
c:/workplace/cal/docs/CAL-COMPLETE-REFERENCE.md - Specs folder:
c:/workplace/cal/docs/
Last Updated: January 14, 2026 Next Update: After dependencies installed and grammar updated