Skip to content

Commit cfd8e95

Browse files
Expose matching-role partition and backpressure metadata in operator metrics
Surface matching-role routing metadata in operator metrics
1 parent 5f2c22f commit cfd8e95

5 files changed

Lines changed: 44 additions & 9 deletions

File tree

docs/architecture/task-matching.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -441,14 +441,20 @@ layer healthy" without reading task rows directly:
441441
`leased_tasks`, `retrying_activities`, `unhealthy_tasks`,
442442
`claim_failed_runs`, and `compatibility_blocked_runs`; a
443443
`workers` block with the Phase 2 compatibility roll-up; and a
444-
`matching_role` block with `queue_wake_enabled`, `shape`, and
445-
`task_dispatch_mode`. `shape` is `in_worker` when this process
444+
`matching_role` block with `queue_wake_enabled`, `shape`,
445+
`task_dispatch_mode`, `partition_primitives`, and
446+
`backpressure_model`. `shape` is `in_worker` when this process
446447
still runs the in-worker broad-poll wake and `dedicated` when
447448
the process has opted out so the broad sweep runs under
448-
`php artisan workflow:v2:repair-pass`. The snapshot reports the
449-
configuration observed by the process serving the request; in
450-
mixed-shape fleets, operators read one snapshot per node to see
451-
the full deployment.
449+
`php artisan workflow:v2:repair-pass`. `partition_primitives`
450+
freezes the routing axes in order:
451+
`connection`, `queue`, `compatibility`, `namespace`.
452+
`backpressure_model` reports `lease_ownership`, meaning the durable
453+
admission boundary is lease occupancy and lease expiry rather
454+
than an engine-enforced per-worker quota. The snapshot reports
455+
the configuration observed by the process serving the request;
456+
in mixed-shape fleets, operators read one snapshot per node to
457+
see the full deployment.
452458
- `Workflow\V2\Support\OperatorQueueVisibility::forNamespace()` /
453459
`::forQueue()` returns per-partition queue depth, leased depth,
454460
poller heartbeats, and stale-worker detection.

src/V2/Support/MatchingRoleSnapshot.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,18 @@ final class MatchingRoleSnapshot
1616
* opted out and the broad sweep is expected to run as
1717
* `php artisan workflow:v2:repair-pass` instead. `task_dispatch_mode`
1818
* reports the configured dispatch mode (`queue` or `poll`).
19+
* `partition_primitives` freezes the matching-role routing axes that
20+
* operators and downstream clients can reason about, while
21+
* `backpressure_model` reports the durable admission boundary the
22+
* engine enforces today.
1923
*
20-
* @return array{queue_wake_enabled: bool, shape: string, task_dispatch_mode: string}
24+
* @return array{
25+
* queue_wake_enabled: bool,
26+
* shape: string,
27+
* task_dispatch_mode: string,
28+
* partition_primitives: list<string>,
29+
* backpressure_model: string
30+
* }
2131
*/
2232
public static function current(): array
2333
{
@@ -31,6 +41,8 @@ public static function current(): array
3141
'queue_wake_enabled' => $queueWakeEnabled,
3242
'shape' => $queueWakeEnabled ? 'in_worker' : 'dedicated',
3343
'task_dispatch_mode' => $dispatchMode,
44+
'partition_primitives' => ['connection', 'queue', 'compatibility', 'namespace'],
45+
'backpressure_model' => 'lease_ownership',
3446
];
3547
}
3648
}

tests/Feature/V2/V2OperatorMetricsTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,6 +2246,8 @@ public function testSnapshotReportsInWorkerMatchingRoleShapeByDefault(): void
22462246
'queue_wake_enabled' => true,
22472247
'shape' => 'in_worker',
22482248
'task_dispatch_mode' => 'queue',
2249+
'partition_primitives' => ['connection', 'queue', 'compatibility', 'namespace'],
2250+
'backpressure_model' => 'lease_ownership',
22492251
],
22502252
$snapshot['matching_role'],
22512253
);
@@ -2264,6 +2266,8 @@ public function testSnapshotReportsDedicatedMatchingRoleShapeWhenQueueWakeIsDisa
22642266
'queue_wake_enabled' => false,
22652267
'shape' => 'dedicated',
22662268
'task_dispatch_mode' => 'poll',
2269+
'partition_primitives' => ['connection', 'queue', 'compatibility', 'namespace'],
2270+
'backpressure_model' => 'lease_ownership',
22672271
],
22682272
$snapshot['matching_role'],
22692273
);

tests/Unit/Commands/V2DoctorCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testJsonOutputIncludesTheMatchingRoleShape(): void
4141
'--json' => true,
4242
])
4343
->expectsOutputToContain(
44-
'"matching_role":{"queue_wake_enabled":false,"shape":"dedicated","task_dispatch_mode":"poll"}'
44+
'"matching_role":{"queue_wake_enabled":false,"shape":"dedicated","task_dispatch_mode":"poll","partition_primitives":["connection","queue","compatibility","namespace"],"backpressure_model":"lease_ownership"}'
4545
)
4646
->assertSuccessful();
4747
}

tests/Unit/V2/TaskMatchingDocumentationTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,14 @@ public function testContractDocumentExposesMatchingRoleShapeOnOperatorSnapshot()
412412
{
413413
$contents = $this->documentContents();
414414

415-
foreach (['`matching_role`', '`queue_wake_enabled`', '`shape`', '`task_dispatch_mode`'] as $field) {
415+
foreach ([
416+
'`matching_role`',
417+
'`queue_wake_enabled`',
418+
'`shape`',
419+
'`task_dispatch_mode`',
420+
'`partition_primitives`',
421+
'`backpressure_model`',
422+
] as $field) {
416423
$this->assertStringContainsString(
417424
$field,
418425
$contents,
@@ -433,6 +440,12 @@ public function testContractDocumentExposesMatchingRoleShapeOnOperatorSnapshot()
433440
),
434441
);
435442
}
443+
444+
$this->assertStringContainsString(
445+
'`lease_ownership`',
446+
$contents,
447+
'Task matching contract must name the lease_ownership backpressure model so operator surfaces can expose the durable admission boundary without paraphrasing it.',
448+
);
436449
}
437450

438451
private function documentContents(): string

0 commit comments

Comments
 (0)