Context
While resolving PR #4471, we found a trivial local variable that could be inlined safely:
await onboardRuntimeBoundary.recordStateResultsWithStepCompatibility(providerInferenceResult.stateResults);
session = providerInferenceResult.session;
const sandboxStateResult = await handleSandboxState({
session,
// ...
});
The reassignment only fed the next call and was clearer as:
await onboardRuntimeBoundary.recordStateResultsWithStepCompatibility(providerInferenceResult.stateResults);
const sandboxStateResult = await handleSandboxState({
session: providerInferenceResult.session,
// ...
});
This suggests there may be other low-risk single-use local aliases in the TypeScript/JavaScript codebase that can be simplified.
Initial exploration
A raw ast-grep scan for property-alias-shaped locals found many possible matches:
npx --package @ast-grep/cli ast-grep run \
--lang ts \
-p 'const $V = $OBJ.$PROP' \
--json=stream src test scripts nemoclaw/src
At the time of exploration, this returned about 679 syntactic matches in the main code/test areas. A follow-up TypeScript-symbol filter narrowed that to about 378 conservative single-use const aliases across code and tests:
src: about 171
test: about 189
scripts: about 10
nemoclaw/src: about 7
nemoclaw-blueprint: about 1
Example candidates from the exploratory pass:
src/lib/domain/sandbox/logs.ts:157
text = lines[lineIndex]
use: parseLineTimestamp(text)
src/lib/inference/onboard-probes.ts:100
fn = value.function
use: hasValidFunctionCallPayload(fn)
src/lib/messaging/compiler/manifest-compiler.ts:302
value = process.env[input.envKey]
use: value?.replace(...)
src/lib/state/sandbox-session.ts:202
sessionCount = matchingSessions.length
use: sessionCount > 0
nemoclaw/src/blueprint/runner.ts:183
version = value.version
use: isOptionalString(version)
Not every match should be changed. Some single-use locals are useful documentation, avoid repeated complex expressions, improve test readability, or are required patterns such as exhaustiveness guards:
const _exhaustive: never = runtime;
return _exhaustive;
Proposed work
Create a focused cleanup PR, or a small series of cleanup PRs, that uses ast-grep plus symbol-aware filtering to find and manually review obvious single-use local aliases.
The goal is not to add a broad lint rule immediately. The first pass should establish which patterns are actually helpful to inline in this codebase.
Suggested approach
- Use ast-grep to find syntactic shapes such as:
const $V = $OBJ.$PROP
const $V = $OBJ[$KEY]
const $V = $EXPR as $TYPE
- simple literal or identifier aliases used exactly once
- Add a TypeScript-aware filter, or equivalent review script, that only reports variables with exactly one local reference.
- Sort candidates by lowest risk:
- declaration and use in adjacent statements
- initializer is side-effect-free
- use is a simple argument, condition, object property, or return expression
- Manually review candidates before editing.
- Avoid changes where the local name documents intent, improves tests, prevents long-line churn, or makes a complex expression easier to read.
- Prefer small reviewable patches over a large mechanical rewrite.
Acceptance criteria
- A PR removes a set of clearly redundant single-use locals without changing behavior.
- The PR does not mix this cleanup with unrelated feature or conflict-resolution work.
- Tests and type-checks relevant to touched files pass.
- Any helper script used for the scan is either:
- kept outside the repo and documented in the PR, or
- committed only if maintainers want a reusable cleanup/audit tool.
- The PR explains the selection criteria and lists notable classes intentionally skipped.
Suggested labels / type
- Native Issue Type: Task
- Labels:
area: architecture, help wanted
Context
While resolving PR #4471, we found a trivial local variable that could be inlined safely:
The reassignment only fed the next call and was clearer as:
This suggests there may be other low-risk single-use local aliases in the TypeScript/JavaScript codebase that can be simplified.
Initial exploration
A raw ast-grep scan for property-alias-shaped locals found many possible matches:
At the time of exploration, this returned about 679 syntactic matches in the main code/test areas. A follow-up TypeScript-symbol filter narrowed that to about 378 conservative single-use
constaliases across code and tests:src: about 171test: about 189scripts: about 10nemoclaw/src: about 7nemoclaw-blueprint: about 1Example candidates from the exploratory pass:
Not every match should be changed. Some single-use locals are useful documentation, avoid repeated complex expressions, improve test readability, or are required patterns such as exhaustiveness guards:
Proposed work
Create a focused cleanup PR, or a small series of cleanup PRs, that uses ast-grep plus symbol-aware filtering to find and manually review obvious single-use local aliases.
The goal is not to add a broad lint rule immediately. The first pass should establish which patterns are actually helpful to inline in this codebase.
Suggested approach
const $V = $OBJ.$PROPconst $V = $OBJ[$KEY]const $V = $EXPR as $TYPEAcceptance criteria
Suggested labels / type
area: architecture,help wanted