Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@

All notable changes to this bundle. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow [SemVer](https://semver.org/) and come from the Git tags.

## [0.2.1] - 2026-12-03

No action is needed on upgrade: the new adapter is disabled by default, and there is no migration.

### Added

- The adapter `basecamp4` (`Adapter\Basecamp4Parser`, disabled by default, enable with `dmstr_webhook.adapters.basecamp4: true`) for project webhooks of Basecamp 4, built against the Basecamp API documentation (`sections/webhooks.md` of `basecamp/bc3-api`), not against captured deliveries. Verification by the secret as path segment (`VerificationStrategy::PathSecret`, hook URL `https://<app>/webhook/<slug>/<secret>`), because Basecamp signs nothing and sends no secret header; use a token secret, and mask the segment in the access logs of every proxy in front of the application. Every verified delivery is one event of the type `basecamp4.<kind>` (`basecamp4.unknown` without a valid `kind`), including kinds outside the documented list such as `kanban_card_moved`; the payload is stored unchanged. Event context: the actor `creator.id` (never a name), the project `recording.bucket.id`, the target of the reference kind `recording` (`recording.id`); the fact edit is Yes for kinds ending in `_title_updated` or `_content_updated`, No for kinds ending in `_created` and unknown otherwise; the facts system generated, confidential and mentions the endpoint are always unknown. Filter attributes `kind` (string), `project_id` (integer) and `recording_type` (string). Event time: the top-level `created_at`. Dedupe key `basecamp4:event:<id>` from the top-level event `id`, or `basecamp4:event:sha256:<body hash>` without an `id` or a valid `kind`; it assumes that a retried delivery keeps its `id`, which the documentation does not say. In the mode `process` there is no mention gate: every event of an allowed creator that is not an edit and matches a route is routed, so routes should name an `eventType` or a `kind` filter, or the endpoint should use the mode `handler`.
- Fixtures of Basecamp 4 deliveries in the documented shape with invented values (`tests/Fixtures/basecamp4/`, origin `documented (…)` or derived from such a fixture, none captured), a fixture-driven intake matrix for both modes without and with database (`Basecamp4MatrixUnitTest`, `Basecamp4MatrixDatabaseTest`), and a test that the raw log records of a Basecamp 4 delivery, written without the redaction processor, carry neither the path secret nor payload text (`Basecamp4LogTest`).
- README section on the Basecamp 4 adapter.

### Changed

- `AbstractWebhookParser::verifyPathSecret()` is available to adapters: the check of the strategy `PathSecret` (the secret path segment must equal the endpoint secret, compared in constant time, else `RejectWebhookException` with 401). `PassthroughPathParser` uses it; its behaviour is unchanged.
- Test support: the fixture loader and the building block of a source's matrix rows are source-neutral (`tests/Support/FixtureSet.php`, `FixtureMatrix.php`), the sequence runner is shared by the sources (`FixtureSequenceTests`, `IntakeHarnessSequences`), and the fixture origin may also be `documented (…)` next to `captured` and `derived from …`. The anonymisation guard (`FixtureAnonymisationTest`) has one definition per source; the raw captures of Basecamp 4 are compared when `WEBHOOK_RAW_CAPTURES_DIR_BASECAMP4` is set, those of GitLab still with `WEBHOOK_RAW_CAPTURES_DIR`.

## [0.2.0] - 2026-12-03

Breaking for 0.1.x: endpoints have a mandatory mode, and only endpoints in the mode `handler` hand their events to delivery handlers.
Expand Down Expand Up @@ -113,3 +128,4 @@ Initial public release.
<!-- - revised 2026-12-03 (intake modes: hand-off only in mode handler, filter reasons, routing result, status transition service) -->
<!-- - revised 2026-12-03 (unreleased entry tidied into one: upgrade note, adapter contract, constructors, routes API) -->
<!-- - revised 2026-12-03 (GitLab adapter, fixtures and guard, type-info requirement, release heading 0.2.0) -->
<!-- - revised 2026-12-03 (0.2.1: Basecamp 4 adapter, verifyPathSecret(), source-neutral test support) -->
5 changes: 3 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ PHP >= 8.5 (see `composer.json`). The PHPUnit suite (configuration `phpunit.dist
- `unit` (`tests/Unit`): no kernel, no database. Run it with `vendor/bin/phpunit --testsuite unit`.
- `integration` (`tests/Integration`): boots the test kernel in `tests/Kernel` (neutral test roles, a stand-in permission voter, a frozen `clock`). Tests in the group `database` need PostgreSQL or MySQL 8 from `DATABASE_URL` (PostgreSQL by default in `phpunit.dist.xml`; the database name must end with `_test`); the schema is created by running the migrations, the bundle's own ones included. The workflow `Tests` (`.github/workflows/tests.yml`) runs both suites, group `database` included, as a matrix on PostgreSQL 16 and MySQL 8.0. Without a server, run `vendor/bin/phpunit --testsuite integration --exclude-group database`.

Test helpers live only under `tests/`. The intake is tested through a data-driven matrix: `tests/Support/IntakeCase.php` (one row: endpoint configuration, request, expected result per mode), `IntakeExpectation.php`, `IntakeHarness.php` (the real intake over an in-memory store, no kernel) and `IntakeMatrix.php` (the source-neutral rows); the same rows run against the database in `tests/Integration/Intake/IntakeMatrixDatabaseTest.php`. Test adapters live in `tests/Kernel/` (`ContextTestAdapter`, `ActorlessTestAdapter`, `FilterAttributesTestAdapter`); a source adapter with fixtures adds its rows in its own provider with the same row shape. The GitLab adapter does so: `tests/Fixtures/gitlab/` holds one anonymised GitLab 15.11 delivery per YAML file (`origin` captured or derived, `headers`, `body`), loaded by `tests/Support/GitlabFixtures.php` and turned into rows by `tests/Support/GitlabMatrix.php`.
Test helpers live only under `tests/`. The intake is tested through a data-driven matrix: `tests/Support/IntakeCase.php` (one row: endpoint configuration, request, expected result per mode), `IntakeExpectation.php`, `IntakeHarness.php` (the real intake over an in-memory store, no kernel) and `IntakeMatrix.php` (the source-neutral rows); the same rows run against the database in `tests/Integration/Intake/IntakeMatrixDatabaseTest.php`. Test adapters live in `tests/Kernel/` (`ContextTestAdapter`, `ActorlessTestAdapter`, `FilterAttributesTestAdapter`); a source adapter with fixtures adds its rows in its own provider with the same row shape. Its fixtures live in `tests/Fixtures/<source>/`, one delivery per YAML file (`origin`, `headers`, `body`), loaded through the source-neutral `tests/Support/FixtureSet.php` and turned into rows through `tests/Support/FixtureMatrix.php` (the source's default endpoint and, for a path secret source, the secret path segment of every request); the traits `tests/Support/FixtureSequenceTests.php` and `IntakeHarnessSequences.php` run a source's sequences without database, and `tests/Integration/Intake/IntakeMatrixDatabaseTestCase.php` runs rows and sequences against the database. `origin` is `captured` (a recorded delivery with neutral values), `documented (<source of the shape>)` (built from the source's documentation, every value invented) or `derived from <fixture> (<what changed>)` (`FixtureSet::ORIGIN_PATTERN`). Two sources do so: GitLab (`tests/Fixtures/gitlab/`, captured GitLab 15.11 deliveries and fixtures derived from them; `tests/Support/GitlabFixtures.php`, `GitlabMatrix.php`) and Basecamp 4 (`tests/Fixtures/basecamp4/`, built from the Basecamp API documentation, so every fixture is documented or derived and none is captured; `tests/Support/Basecamp4Fixtures.php`, `Basecamp4Matrix.php`). Mark a fixture `captured` only when it is anonymised from a real delivery. `tests/Unit/Intake/Basecamp4LogTest.php` checks the raw log records of Basecamp 4 deliveries without the redaction processor (no path secret, no request path, no payload text) and proves its detector with a leaking test adapter.

Fixtures are public: never copy a raw capture or any of its values into `tests/Fixtures/`; use neutral values (`example.com` hosts, invented ids, names, UUIDs, SHAs and texts). `tests/Unit/Fixtures/FixtureAnonymisationTest.php` enforces structural rules always and, with `WEBHOOK_RAW_CAPTURES_DIR` pointing to a local directory of raw captures (kept outside the repository), fails on any captured value found in a fixture; run it locally whenever fixtures change.
Fixtures are public: never copy a raw capture or any of its values into `tests/Fixtures/`; use neutral values (`example.com` hosts, invented ids, names, UUIDs, SHAs and texts). `tests/Unit/Fixtures/FixtureAnonymisationTest.php` has one definition per source (`sources()`: fixture set, allowed hosts, header values, captures variable, structural values; a new source adds one entry, and every fixture file must belong to a source). It enforces structural rules always and, with the source's variable pointing to a local directory of raw captures (kept outside the repository; `WEBHOOK_RAW_CAPTURES_DIR` for GitLab, `WEBHOOK_RAW_CAPTURES_DIR_BASECAMP4` for Basecamp 4), fails on any captured value found in a fixture of any source; run it locally whenever fixtures change.

Replay-window tests build their Standard Webhooks signatures with the time of a frozen clock (`MockClock`), never with `time()`; only the test of the system-time fallback uses `time()`.

Expand All @@ -40,3 +40,4 @@ Replay-window tests build their Standard Webhooks signatures with the time of a

<!-- - revised 2026-12-03 (database tests on PostgreSQL and MySQL 8 in CI, layout of src/Model and src/Routing, intake test matrix, public names of 0.2.0) -->
<!-- - revised 2026-12-03 (GitLab fixtures and the anonymisation guard) -->
<!-- - revised 2026-12-03 (Basecamp 4 fixtures, documented origin, source-neutral fixture set, matrix and sequence runner, anonymisation guard per source) -->
Loading
Loading