Skip to content

Conversation

@galligan
Copy link
Contributor

  • Add child(context) method to Logger interface for context inheritance
  • Update noopLogger to include child() method
  • Change AssertionError category from 'validation' to 'internal'
  • Add TSDoc explaining category rationale (invariant violations, not user input)
  • Add 8 new tests for Logger.child and AssertionError behavior

Closes #53, #54

Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com

Copy link
Contributor Author

galligan commented Jan 23, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@galligan galligan force-pushed the p3-7/contracts/logger-child branch from 8d043eb to 62826b8 Compare January 23, 2026 11:58
@galligan galligan force-pushed the p3-6/config/env-validation branch from a8afb46 to 0f0a5d8 Compare January 23, 2026 11:58
@galligan galligan added the enhancement New feature or request label Jan 23, 2026
@galligan galligan marked this pull request as ready for review January 23, 2026 12:00
Copy link

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

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: 62826b82f0

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

@greptile-apps
Copy link

greptile-apps bot commented Jan 23, 2026

Greptile Summary

  • Adds Logger.child(context) method to the Logger interface in packages/contracts/src/handler.ts for creating child loggers with inherited context, enabling hierarchical logging patterns required by the project specification
  • Updates AssertionError category from 'validation' to 'internal' in packages/contracts/src/errors.ts to correctly reflect that assertion failures are programming bugs rather than user input validation issues
  • Adds comprehensive test coverage with 8 new tests across multiple test files to verify both the Logger.child functionality and corrected AssertionError behavior

Important Files Changed

Filename Overview
packages/contracts/src/handler.ts Adds child(context) method to Logger interface with comprehensive TSDoc explaining context merging and composability
packages/contracts/src/errors.ts Changes AssertionError category from 'validation' to 'internal' with detailed rationale for invariant violation handling

Confidence score: 5/5

  • This PR is safe to merge with minimal risk as it primarily adds new functionality and corrects error categorization
  • Score reflects well-documented changes with comprehensive test coverage and clear adherence to project architecture patterns
  • No files require special attention as the changes are straightforward interface additions and error category corrections

Sequence Diagram

sequenceDiagram
    participant User
    participant Logger
    participant ChildLogger
    participant AssertionHandler
    participant ErrorSystem

    User->>Logger: "child({ requestId: 'abc123' })"
    Logger->>ChildLogger: "create with inherited context"
    Logger-->>User: "return ChildLogger"
    
    User->>ChildLogger: "info('Processing request')"
    ChildLogger->>ChildLogger: "merge parent + child context"
    ChildLogger->>ChildLogger: "log with full context"

    User->>ChildLogger: "child({ operation: 'create' })"
    ChildLogger->>ChildLogger: "create nested child"
    ChildLogger-->>User: "return nested ChildLogger"

    User->>AssertionHandler: "invariant violation detected"
    AssertionHandler->>ErrorSystem: "new AssertionError({ message: 'Invariant violated' })"
    ErrorSystem->>ErrorSystem: "set category = 'internal'"
    ErrorSystem->>ErrorSystem: "map to HTTP 500/exit code 8"
    ErrorSystem-->>User: "return AssertionError"
Loading

@galligan galligan changed the base branch from p3-6/config/env-validation to graphite-base/69 January 23, 2026 21:20
@galligan galligan force-pushed the p3-7/contracts/logger-child branch from 71b347d to 3820a22 Compare January 23, 2026 21:22
@galligan galligan changed the base branch from graphite-base/69 to p3-6/config/env-validation January 23, 2026 21:22
@galligan
Copy link
Contributor Author

Aligned contracts Logger interface with logging by adding trace/fatal and updating no-op/test loggers to match.

@galligan galligan changed the base branch from p3-6/config/env-validation to graphite-base/69 January 24, 2026 02:29
@galligan galligan force-pushed the p3-7/contracts/logger-child branch from 3820a22 to 255548c Compare January 24, 2026 02:38
@galligan
Copy link
Contributor Author

Resubmitted after restack. Logger.child compatibility is handled upstack in PR #73 (logging adds child to LoggerInstance), so no additional changes were needed in this contracts PR.

galligan added a commit that referenced this pull request Jan 24, 2026
Adds child() method to LoggerInstance that:
- Merges parent context with child bindings (child takes precedence)
- Returns new logger instance with combined context
- Preserves level, redaction, sinks from parent
- Supports nested children (composable)

Fixes P1 review feedback from PR #69

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
galligan and others added 2 commits January 23, 2026 22:44
- Add child(context) method to Logger interface for context inheritance
- Update noopLogger to include child() method
- Change AssertionError category from 'validation' to 'internal'
- Add TSDoc explaining category rationale (invariant violations, not user input)
- Add 8 new tests for Logger.child and AssertionError behavior

Closes #53, #54

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@galligan galligan force-pushed the p3-7/contracts/logger-child branch from 255548c to 85956cf Compare January 24, 2026 03:46
@galligan galligan changed the base branch from graphite-base/69 to p3-6/config/env-validation January 24, 2026 03:46
@galligan
Copy link
Contributor Author

Resubmitted after downstack updates; no new feedback found on this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants