Fix SDK contract maintainability findings
Merged
UN
4mo ago+88+88+01234567890123456789-6-6-0123456789
Summary
- Clears the targeted CodeFactor/Unicorn maintainability lane tracked by
pm-q0ye. - Preserves emitted SDK/CLI JSON Schema contract output while avoiding source-level
thenobject members that Unicorn treats as thenable-like. - Removes the redundant metadata field spread and activation command length guard flagged by Unicorn.
- Stabilizes strict 100% release coverage for the Linux
/procbackground-run race fallback.
PM tracking
- Active item:
pm-q0ye - Parent:
pm-92if - Linked files/tests/evidence are recorded on the pm item.
- Related GitHub state checked: no open PRs before this branch; no Dependabot or code-scanning alerts returned by GitHub; issue #374 remains blocked on missing
RELEASE_PAT;pm-2kklremains open until the next scheduled Windows Nightly validates PR #377.
Verification
- Targeted ESLint reproduction for
unicorn/no-thenable,unicorn/no-useless-spread, andunicorn/no-useless-length-check: 0 findings. node scripts/run-tests.mjs test -- tests/unit/commands/contracts-command.spec.ts tests/unit/commands/validate-command.spec.ts tests/unit/cli/cli-main-errors.spec.tsnode scripts/run-tests.mjs test -- tests/unit/commands/test-runs-command.spec.ts tests/unit/core/search/background-refresh.spec.tsnode scripts/run-tests.mjs coverage: literal 100/100/100/100 coverage, 256 files / 5132 tests.pnpm buildpnpm typecheckpnpm contracts:checkpnpm quality:staticpnpm changelog:pm:check: latest availablepm-changelog2026.6.20,CHANGELOG.mdunchanged.pnpm security:scan: no credential-like secrets in tracked files.pnpm audit --audit-level low: no known vulnerabilities.pm health --check-only --summary --jsonpm validate --check-resolution --check-history-drift --json: clean history drift; pre-existing resolution metadata warnings remain on old closed items.node scripts/release/sentry-telemetry-gate.mjs --json --telemetry-mode best-effort: Sentry ok, telemetry finish error rate 0.67%.pnpm release:gates: passed build, typecheck, docs/skills, static quality, 100/100/100/100 coverage, version, security, packed npx smoke, package-first dogfood, and remaining release checks.
Manual temp-directory SDK smoke
Used isolated PM_PATH and PM_GLOBAL_PATH in a temp workspace and verified:
pm init temp-project --force --defaults- create/files/docs/test item flow with
pm test --run --progress pm package init --declarative --capability commands- scaffold dependency install,
npm run typecheck, andnpm test - project package uninstall/install
- command contract discovery for
smoke package ping - command dispatch and health check
The first package install attempt, before scaffold dependencies were installed, correctly diagnosed the missing SDK dependency and gave actionable remediation. Following the generated package next steps produced runtime_activation_status=ok and health_ok=true.
Summary by Sourcery
Resolve static analysis maintainability findings while preserving the SDK/CLI JSON Schema contract behavior and test coverage guarantees.
Bug Fixes:
- Prevent false-positive thenable detection in JSON Schema generation by avoiding direct use of a literal
thenproperty. - Remove redundant extension activation command length guard that no longer affects behavior while simplifying activation checks.
Enhancements:
- Introduce a helper for constructing JSON Schema object members keyed by
thento keep schema output stable while satisfying lint rules. - Tighten the supported metadata required fields definition for validate commands by removing an unnecessary spread over the same set.
- Improve Linux background-run CPU stats fallback handling to ensure stable behavior and coverage when
/procentries disappear.
Tests:
- Update contract-related unit tests to match the new
thenmember construction helper and maintain schema contract expectations.
Chores:
- Update internal PM tracking artifacts for the
pm-q0yemaintainability task.
Summary by cubic
Clears remaining eslint-plugin-unicorn maintainability findings in the SDK/CLI while keeping emitted JSON Schema contracts unchanged. Stabilizes the release coverage gate by handling a Linux /proc race.
- Refactors
- Use explicit JSON Schema
thenproperties with narrowly scopedunicorn/no-thenabledisables; schema output stays identical, tests updated. - Keep
SUPPORTED_METADATA_REQUIRED_FIELDSdefensively deduplicated viaSetand typed asreadonlyto prevent double-counted diagnostics. - Remove the redundant
commands.lengthcheck before.some(...)insrc/cli/main.ts. - Add a scoped
/* c8 ignore next */for the/proc/<pid>/statfallback insrc/core/test/background-runs.tsto keep 100% coverage deterministic.
- Use explicit JSON Schema