Skip to content

Add PSR-15 correlation ID middleware.#1

Merged
gustavofreze merged 2 commits into
mainfrom
feature/develop
Jun 26, 2026
Merged

Add PSR-15 correlation ID middleware.#1
gustavofreze merged 2 commits into
mainfrom
feature/develop

Conversation

@gustavofreze

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings June 26, 2026 20:51
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

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 a small, framework-agnostic correlation ID building block for the tiny-blocks PHP ecosystem: a PSR-15 middleware that propagates a correlation identifier through request attributes and response headers, plus a PSR-3 logger wrapper that injects the correlation ID into log context. The PR also introduces the repo’s canonical tooling, CI, and documentation scaffolding.

Changes:

  • Introduce CorrelationIdMiddleware (PSR-15) with a configurable CorrelationIdProvider and a default UUID v4 provider.
  • Add CorrelatedLogger (PSR-3) to attach correlation_id into log context using the request attribute.
  • Add unit tests, README/SECURITY docs, and canonical tiny-blocks tooling + GitHub workflows/templates.

Reviewed changes

Copilot reviewed 60 out of 61 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/Unit/CorrelationIdMiddlewareTest.php Unit coverage for correlation ID middleware behavior (header reuse, generation, propagation).
tests/Unit/CorrelatedLoggerTest.php Unit coverage for correlated logger resolution and context attachment.
tests/Unit/CapturingLogger.php Test logger double to capture PSR-3 log entries for assertions.
tests/Unit/CapturingHandler.php PSR-15 handler double that captures the processed request for assertions.
src/Internal/UuidCorrelationIdProvider.php Default correlation ID provider implementation using UUID v4.
src/Internal/UuidCorrelationId.php Internal CorrelationId implementation used by provider and header-wrapping logic.
src/Internal/CorrelationIdMiddlewareBuilder.php Fluent builder for configuring the middleware provider.
src/Internal/CorrelationAttachingLogger.php Internal logger decorator that merges correlation_id into context.
src/CorrelationIdProvider.php Public extension point for correlation ID generation strategy.
src/CorrelationIdMiddleware.php Public PSR-15 middleware that sets request attribute and response header.
src/CorrelationId.php Public interface for correlation identifier values.
src/CorrelatedLogger.php Public wrapper that resolves a logger decorated with correlation context.
SECURITY.md Repository security policy (supported versions and reporting process).
README.md Public documentation (overview, installation, usage examples).
phpunit.xml PHPUnit configuration including coverage and logging outputs.
phpstan.neon.dist PHPStan baseline config with scoped ignores for test fixtures.
phpcs.xml PHPCS ruleset (PSR-12) for src/ and tests/.
Makefile Docker-wrapped dev workflow targets (configure, review, tests, etc.).
infection.json.dist Infection mutation-testing configuration enforcing MSI thresholds.
composer.json Package metadata, dependencies, autoloading, and standard scripts.
CLAUDE.md Tiny-blocks contributor conventions index and “definition of done” commands.
.gitignore Ignores vendor, local overrides, caches, and report artifacts.
.github/workflows/codeql.yml Adds scheduled and PR/push CodeQL security workflow.
.github/workflows/ci.yml Adds canonical CI pipeline (build, review, tests) driven by composer scripts.
.github/workflows/auto-assign.yml Auto-assign workflow for issues and pull requests.
.github/PULL_REQUEST_TEMPLATE.md Standard PR template with checklist for review/tests.
.github/ISSUE_TEMPLATE/feature_request.md Feature request issue template.
.github/ISSUE_TEMPLATE/bug_report.md Bug report issue template.
.github/dependabot.yml Dependabot config for Composer and GitHub Actions updates.
.github/copilot-instructions.md Repository Copilot instructions pointing to CLAUDE rules.
.gitattributes Export-ignore rules for Packagist tarball contents.
.editorconfig Editor formatting baseline (120 cols, LF, etc.).
.claude/skills/tiny-blocks-create/SKILL.md Skill documentation for scaffolding/restoring canonical tiny-blocks repo files.
.claude/skills/tiny-blocks-create/assets/github/workflows/ci.yml Canonical CI workflow asset used by the create skill.
.claude/skills/tiny-blocks-create/assets/github/PULL_REQUEST_TEMPLATE.md Canonical PR template asset used by the create skill.
.claude/skills/tiny-blocks-create/assets/github/ISSUE_TEMPLATE/feature_request.md Canonical feature request template asset used by the create skill.
.claude/skills/tiny-blocks-create/assets/github/ISSUE_TEMPLATE/bug_report.md Canonical bug report template asset used by the create skill.
.claude/skills/tiny-blocks-create/assets/docs/SECURITY.md Canonical SECURITY.md asset used by the create skill.
.claude/skills/tiny-blocks-create/assets/config/phpunit.xml Canonical phpunit.xml asset used by the create skill.
.claude/skills/tiny-blocks-create/assets/config/phpstan.neon.dist Canonical phpstan.neon.dist asset used by the create skill.
.claude/skills/tiny-blocks-create/assets/config/phpcs.xml Canonical phpcs.xml asset used by the create skill.
.claude/skills/tiny-blocks-create/assets/config/Makefile Canonical Makefile asset used by the create skill.
.claude/skills/tiny-blocks-create/assets/config/infection.json.dist Canonical infection.json.dist asset used by the create skill.
.claude/skills/tiny-blocks-create/assets/config/composer.json Canonical composer.json asset template used by the create skill.
.claude/skills/tiny-blocks-create/assets/config/.gitignore Canonical .gitignore asset used by the create skill.
.claude/skills/tiny-blocks-create/assets/config/.gitattributes Canonical .gitattributes asset used by the create skill.
.claude/skills/tiny-blocks-create/assets/config/.editorconfig Canonical .editorconfig asset used by the create skill.
.claude/skills/tiny-blocks-consume/SKILL.md Skill documentation for discovering/reusing tiny-blocks packages.
.claude/skills/tiny-blocks-consume/scripts/refresh-catalog.py Script to refresh the tiny-blocks catalog from Packagist.
.claude/skills/tiny-blocks-consume/references/catalog.md Generated tiny-blocks package catalog snapshot.
.claude/skills/commit-message/SKILL.md Skill documentation for tiny-blocks Conventional Commit messages.
.claude/settings.json Claude tool permissions and post-edit conformance hooks configuration.
.claude/rules/php-library-tooling.md Rule file defining tooling invariants for tiny-blocks PHP libs.
.claude/rules/php-library-testing.md Rule file defining PHPUnit/Given-When-Then conventions.
.claude/rules/php-library-modeling.md Rule file defining modeling/value-object/exception conventions.
.claude/rules/php-library-github-workflows.md Rule file defining GitHub Actions workflow conventions.
.claude/rules/php-library-documentation.md Rule file defining README/docs conventions.
.claude/rules/php-library-code-style.md Rule file defining semantic PHP style rules used by the ecosystem.
.claude/rules/php-library-architecture.md Rule file defining folder layout and public API boundary rules.
.claude/hooks/php-prose-punctuation-conformance.py Hook enforcing punctuation rules in Markdown and PHP comments.
.claude/hooks/php-ordering-conformance.py Hook enforcing deterministic ordering rules for PHP members/params.

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

Comment thread src/CorrelationIdMiddleware.php
Comment thread tests/Unit/CorrelationIdMiddlewareTest.php
Comment thread tests/Unit/CorrelationIdMiddlewareTest.php
Comment thread tests/Unit/CorrelatedLoggerTest.php
Comment thread .github/workflows/codeql.yml
Comment thread src/Internal/UuidCorrelationId.php
@gustavofreze gustavofreze merged commit 3ec9549 into main Jun 26, 2026
8 checks passed
@gustavofreze gustavofreze deleted the feature/develop branch June 26, 2026 20:56
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.

3 participants