Skip to content

feat(cli): minimal bounded runtime for real codebases - #89

Merged
aryaniyaps merged 1 commit into
mainfrom
release/minimal-bounded-runtime
Aug 4, 2026
Merged

feat(cli): minimal bounded runtime for real codebases#89
aryaniyaps merged 1 commit into
mainfrom
release/minimal-bounded-runtime

Conversation

@aryaniyaps

Copy link
Copy Markdown
Owner

Summary

Minimal cherry-pick of bounded topology (#69) and lifecycle (#70) for production CLI use—without oracle, qualification harness, or epic #49 closure work.

  • runtime-budget.mjs: default-on thread/worker caps (disable with LAMINA_RUNTIME_BOUNDED_TOPOLOGY=0)
  • runtime-lifecycle.mjs: graphd release before observation, finalizeRuntimeCommand on CLI exit
  • CocoIndex: live= flag fix, COCOINDEX_MAX_INFLIGHT_COMPONENTS=1, observation worker thread env
  • graphd / retrieval: Ladybug and ONNX thread caps on spawn

Scope

15 files, ~1k lines. Source commits: 6f523fca (#70), 657df86b (CLI finalize).

Not included: inventory/generation (#71#72), retrieval sync overhaul (#73#76), packaging (#77), qualification (#58).

Test plan

  • node tests/runtime_budget_test.mjs
  • node tests/runtime_lifecycle_test.mjs
  • node tests/observation_cli_test.mjs
  • node tests/retrieval_runtime_test.mjs
  • node tests/graphd_protocol_test.mjs
  • Manual smoke on your repo: doctorgraph observecontext rebuildwork prepare

Made with Cursor

Add runtime-budget and runtime-lifecycle modules with default-on thread
and observation worker caps, CocoIndex live-flag fix, and graphd release
on CLI exit. Cherry-picked from topology/lifecycle work without oracle or
qualification harness changes.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cursor

cursor Bot commented Aug 4, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lamina-docs Ready Ready Preview Aug 4, 2026 9:18am

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e4e0c95796

ℹ️ 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".

const environment = Object.fromEntries(entries
.filter(([name]) => !isGraphdExecutionHook(name, platform)
&& (platform !== 'win32' || name.toLowerCase() !== 'path')));
Object.assign(environment, graphdThreadEnvironment(inheritedEnvironment));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Derive the graphd budget before applying thread limits

graphdThreadEnvironment expects a parsed budget, but this passes the raw environment object, where graphd_threads is normally undefined. Consequently every default graphd spawn receives values such as OMP_NUM_THREADS=NaN, UV_THREADPOOL_SIZE=NaN, and LAMINA_RUNTIME_WORKER_THREADS=NaN; native runtimes may reject or ignore these values, defeating the bounded-topology guarantee and potentially exceeding the cgroup task limit. Parse inheritedEnvironment with runtimeBudgetFromEnvironment before constructing the thread environment.

Useful? React with 👍 / 👎.

Comment on lines +337 to +339
const inRepo = cwdLink && (cwdLink === root || cwdLink.startsWith(`${root}${path.sep}`));
const childOfGraphd = graphdPid && readProcessPpid(pid) === graphdPid;
if (markerHit && (inRepo || childOfGraphd)) matches.push(pid);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Restrict orphan cleanup to processes owned by this command

On Linux this treats every marker-matching process whose cwd is anywhere in the repository as an orphan, without establishing ancestry or command ownership. If two Lamina commands run concurrently in one checkout, finalizing either command can therefore SIGTERM/SIGKILL the other command's cocoindex-worker or retrieval_worker.py process—for example, running a quick help/status command while a context rebuild is indexing. Track launched PIDs or require a verified descendant/lease relationship instead of using repository cwd alone.

Useful? React with 👍 / 👎.

Comment on lines +332 to +335
} finally {
if (process.env.LAMINA_CLI_SKIP_RUNTIME_FINALIZE !== '1') {
try {
await finalizeRuntimeCommand(process.cwd());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve graphd for read-only CLI commands

The unconditional finalizer now stops graphd after successful read-only commands such as lamina graph status, even though the lifecycle contract says reads may keep the daemon resident. This also breaks the existing required tests/greenfield_cli_test.mjs, which immediately captures graphd.lock after graph status; running that test against this commit fails with ENOENT because the finalizer has already removed the lock. Pass the command classification into finalization and retain graphd for reads, or otherwise update the contract and dependent lifecycle tests together.

Useful? React with 👍 / 👎.

@aryaniyaps
aryaniyaps merged commit 6a1bb59 into main Aug 4, 2026
4 of 15 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.

1 participant