feat(cognition): add minimal incremental runtime#355
Conversation
|
Warning Review limit reached
Your plan includes 1 review of capacity. Refill in 52 minutes and 8 seconds. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more review capacity refills, a review can be triggered using the 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 trial, open-source, and free plans. In all cases, review capacity refills continuously over time. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR introduces the foundational cognition runtime layer for Canopy—an incremental graph system for AI coding context artifacts. It defines core type contracts, implements reactive dependency tracking via incr, provides a recomputation store with selective invalidation, and validates the system with comprehensive tests. ChangesCognition Runtime Foundation
Sequence DiagramsequenceDiagram
participant Developer as Caller
participant Store as CognitionStore
participant Reactive as CognitionReactive
Developer->>Store: set_input(FileText("a"), Text(...))
Store->>Store: store value & bump revision
Store->>Store: mark FileSummary dirty
Store->>Reactive: bump_dependency_revision()
Developer->>Store: recompute_dirty()
Note over Store: Find ready dirty keys
Store->>Store: find FileSummary (deps clean)
Store->>Store: recompute_one(FileSummary)
Store->>Store: update dependency map
Developer->>Store: get_value(FileSummary)
Store-->>Developer: computed Summary
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
lambda-editor | 2ce1773 | Commit Preview URL Branch Preview URL |
May 25 2026, 07:28 PM |
Benchmark Comparison ReportComparing PR branch against Main Module BenchmarksBase branch: PR branch: event-graph-walker BenchmarksBase branch: PR branch: Benchmarks run with |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 26f15db950
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| pub fn CognitionStore::set_input( | ||
| self : CognitionStore, | ||
| key : CognitionKey, | ||
| value : CognitionValue, | ||
| ) -> Unit { | ||
| self.values[key] = value.copy_value() |
There was a problem hiding this comment.
Restrict set_input to FileText/Text inputs
set_input accepts any CognitionKey/CognitionValue pair and writes it directly into the store, so callers can accidentally inject derived artifacts (for example RepoSummary or QueryContext) or wrong value variants as inputs. In those cases dependency edges are never established for the injected derived node, and subsequent FileText updates will not reliably invalidate it, causing stale context to be returned from get_value. Please validate set_input so only FileText(path) with Text(...) is accepted (or split the API for raw inputs vs. derived values).
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e92706ceba
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| fn CognitionStore::recompute_repo_summary(self : CognitionStore) -> Unit { | ||
| let summary_keys = self.known_file_summary_keys() | ||
| let items : Array[String] = [] |
There was a problem hiding this comment.
Seed RepoSummary from FileText inputs on first build
When RepoSummary is recomputed here, it only reads known_file_summary_keys(), which are discovered from already-materialized FileSummary values. If callers load files via set_input(FileText, Text) and then compute RepoSummary (or QueryContext) for the first time, no FileSummary entries exist yet, so the repo summary is built as empty and existing files are omitted until each file is separately computed or later edited. This breaks first-query context accuracy for a common startup flow.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/architecture/cognition-runtime.md`:
- Around line 56-59: The doc currently names concrete types (SymbolSummary,
DecisionLog, AgentMemory, BranchMemory, StaleMemory); remove those specific
identifiers and rewrite the sentence to express only the architectural principle
(e.g., "future cognition artifacts should follow the same graph discipline:
explicit inputs, explicit dependencies, revisions, and selective invalidation
before introducing expensive AI work") so the file remains principle-only;
ensure no type/field names remain (remove or generalize any of SymbolSummary,
DecisionLog, AgentMemory, BranchMemory, StaleMemory).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2590d55b-2176-4605-b1df-d64dd4bbac83
⛔ Files ignored due to path filters (1)
moon.workis excluded by!**/*.work
📒 Files selected for processing (10)
docs/architecture/README.mddocs/architecture/cognition-runtime.mdlib/cognition/cognition_test.mbtlib/cognition/demo.mbtlib/cognition/moon.modlib/cognition/moon.pkglib/cognition/pkg.generated.mbtilib/cognition/reactive.mbtlib/cognition/store.mbtlib/cognition/types.mbt
Summary
Validation
Summary by CodeRabbit
Documentation
New Features
Tests