Skip to content

test(config,core): cover env loading, validation, and core helpers#88

Merged
jayzalowitz merged 1 commit into
mainfrom
jayzalowitz/config-core-tests
Apr 27, 2026
Merged

test(config,core): cover env loading, validation, and core helpers#88
jayzalowitz merged 1 commit into
mainfrom
jayzalowitz/config-core-tests

Conversation

@jayzalowitz

Copy link
Copy Markdown
Owner

Summary

The session-start audit flagged `@skytwin/config` and the top-level helpers in `@skytwin/core` as having zero test coverage. Both are dependency roots — config gates bootstrap, core hosts comparison helpers used across decision/policy/risk paths. Silent regressions here cascade everywhere.

`@skytwin/config` — 0 → 18 tests

  • `loadConfig` defaults, env reads, fallback parsing
  • Legacy aliases: `GATEWAY_AUTH_TOKEN` → `IRONCLAW_GATEWAY_TOKEN`, `IRONCLAW_CHANNEL` → `IRONCLAW_DEFAULT_CHANNEL`
  • `validate()` field-by-field rejection: empty/invalid databaseUrl, malformed URL, missing webhook secret (unless mock enabled), port range, NaN
  • `loadValidatedConfig` success + aggregated error message lists every failing field

`@skytwin/core` — 30 → 50 tests (+20)

  • `generateId` UUID shape + uniqueness
  • `compareRiskTiers` eq/gt/lt/unknown
  • `riskExceeds` strict-greater behavior
  • `trustMeetsOrExceeds` gte semantics + unknown handling
  • Tier ordering tables (RISK_TIER_ORDER, TRUST_TIER_ORDER, CONFIDENCE_LEVEL_ORDER)
  • `createLogger` level routing, format (level + namespace + message + ISO timestamp), meta JSON serialization, omit-meta-when-absent

Test plan

  • `pnpm --filter @skytwin/config test` — 18/18
  • `pnpm --filter @skytwin/core test` — 50/50 (was 30)
  • `pnpm --filter @skytwin/config lint` and `@skytwin/core lint` — clean
  • `pnpm test` — 38/38 turbo tasks
  • `pnpm lint` — 30/30 turbo tasks

🤖 Generated with Claude Code

… helpers

The original session-start audit flagged @skytwin/config and the
top-level helpers in @skytwin/core as having zero test coverage. Both
are dependency roots — config gates bootstrap, core hosts comparison
helpers used across decision/policy/risk paths. Silent regressions
here cascade everywhere.

Adds:
- packages/config/src/__tests__/config.test.ts (18 tests)
  loadConfig defaults, env reads, fallback parsing, GATEWAY_AUTH_TOKEN
  legacy alias, IRONCLAW_CHANNEL legacy alias. validate() field-by-field
  rejection (empty/invalid databaseUrl, malformed URL, missing webhook
  secret, port range, NaN). loadValidatedConfig success + aggregated
  error message.
- packages/core/src/__tests__/index.test.ts (20 tests)
  generateId UUID shape + uniqueness. compareRiskTiers eq/gt/lt/unknown.
  riskExceeds strict-greater behavior. trustMeetsOrExceeds gte semantics
  + unknown handling. Tier ordering tables. createLogger level routing,
  format (level + namespace + message + ISO timestamp), meta JSON
  serialization.

Net new tests: 38. core: 30 → 50 (+20). config: 0 → 18.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 27, 2026 02:04

Copilot AI 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.

Pull request overview

Adds unit test coverage for two dependency-root packages (@skytwin/config and @skytwin/core) to prevent silent regressions in environment-driven bootstrapping and shared core helpers used broadly across the system.

Changes:

  • Adds @skytwin/core tests covering ID generation, tier comparison helpers/order tables, and console logger formatting/routing.
  • Adds @skytwin/config tests covering env loading defaults/overrides, legacy env aliases, validation errors, and aggregated validation failures.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/core/src/tests/index.test.ts New tests for generateId, tier helpers/order maps, and createLogger output/level routing.
packages/config/src/tests/config.test.ts New tests for loadConfig, validate, and loadValidatedConfig including alias handling and aggregated error messaging.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jayzalowitz jayzalowitz merged commit 12f461d into main Apr 27, 2026
12 checks passed
@jayzalowitz jayzalowitz deleted the jayzalowitz/config-core-tests branch April 27, 2026 02:17
jayzalowitz added a commit that referenced this pull request Apr 27, 2026
Captures the second half of the audit cleanup work that landed after
#87:

- #88 config/core test coverage (was 0/missing helpers)
- #89 connectors gmail + calendar pure-logic tests (8 → 43)
- #90 llm-client URL validation hardening (zone IDs, trailing dots, CGNAT)
- #91 adapter-discovery factory shape check + manifest defaultConfig
- #92 preference-archaeologist coverage (action keys, multi-group, expiry)
- #93 worker SignalDeduper extraction + 11 tests

Pure docs.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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.

2 participants