Skip to content

[code-simplifier] refactor: small clarity tweaks in chunk cursor + device spec #27136

@github-actions

Description

@github-actions

Overview

This PR applies small readability/consistency tweaks to code that was recently modified, without changing behavior.

Files Simplified

  • packages/dds/tree/src/feature-libraries/chunked-forest/basicChunk.ts
    • Rename an internal variable to better reflect meaning (halfHeightnodeDepth).
    • Remove a non-null assertion in getStackedFieldKey() by using explicit ?? oob() checks.
  • packages/runtime/container-runtime/src/containerRuntime.ts
    • Update the (now-stale) comment above getDeviceSpec() to reflect that navigator is required (browser or Node 22+).
    • Make the deviceMemory cast more explicit via a local navigatorWithDeviceMemory variable.

Changes Based On

Testing

Validation could not be executed in this runner because the available Node version is v20.20.2, while the repo requires >=22.22.2.

Commands attempted
  • pnpm install --frozen-lockfile
  • pnpm run build:fast
  • pnpm run test
  • pnpm run lint
  • pnpm run format:repo

Review Focus

  • Confirm no behavior changes (all changes are local refactors / comment updates).
  • Confirm the stack indexing logic remains unchanged.

References: §24823297965

Generated by Code Simplifier ·

To install this agentic workflow, run

gh aw add github/gh-aw/.github/workflows/code-simplifier.md@94662b1dee8ce96c876ba9f33b3ab8be32de82a4
  • expires on Apr 24, 2026, 7:52 AM UTC

Note

This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch code-simplifier/2026-04-23-clarity-73956383e7a63872.

Click here to create the pull request

To fix the permissions issue, go to SettingsActionsGeneral and enable Allow GitHub Actions to create and approve pull requests.

Show patch preview (72 of 72 lines)
From c2598056b8c63c09d6078d725629f3de07791f07 Mon Sep 17 00:00:00 2001
From: GitHub Copilot <223556219+Copilot@users.noreply.github.com>
Date: Thu, 23 Apr 2026 07:50:01 +0000
Subject: [PATCH] refactor: small clarity tweaks

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 .../feature-libraries/chunked-forest/basicChunk.ts    | 11 ++++++-----
 .../runtime/container-runtime/src/containerRuntime.ts |  8 +++++---
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/packages/dds/tree/src/feature-libraries/chunked-forest/basicChunk.ts b/packages/dds/tree/src/feature-libraries/chunked-forest/basicChunk.ts
index 4ebaa68..08b0e63 100644
--- a/packages/dds/tree/src/feature-libraries/chunked-forest/basicChunk.ts
+++ b/packages/dds/tree/src/feature-libraries/chunked-forest/basicChunk.ts
@@ -178,13 +178,13 @@ export class BasicChunkCursor extends SynchronousCursor implements ChunkedCursor
 	 * their length should always equal the number of node levels traversed.
 	 */
 	private assertChunkStacksMatchNodeDepth(): void {
-		const halfHeight = this.getNodeOnlyHeightFromHeight();
+		const nodeDepth = this.getNodeOnlyHeightFromHeight();
 		assert(
-			this.indexOfChunkStack.length === halfHeight,
+			this.indexOfChunkStack.length === nodeDepth,
 			0x51c /* unexpected indexOfChunkStack */,
 		);
 		assert(
-			this.indexWithinChunkStack.length === halfHeight,
+			this.indexWithinChunkStack.length === nodeDepth,
 			0x51d /* unexpected indexWithinChunkStack */,
 		);
 	}
@@ -199,8 +199,9 @@ export class BasicChunkCursor extends SynchronousCursor implements ChunkedCursor
 
 	private getStackedFieldKey(height: number): FieldKey {
 		assert(height % 2 === 0, 0x51f /* must field height */);
-		// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-		return this.siblingStack[height]![this.indexStack[height]!] as FieldKey;
+		const siblingsAtHeight = this.siblingStack[height] ?? oob();
+		const indexAtHeight = this.indexStack[height] ?? oo
... (truncated)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions