Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
cb50794
Keep requested numeric cache keys from taking positional defaults
binaryfire Nov 18, 2026
6bce7bb
docs: track removing native Windows runtime support
binaryfire Nov 19, 2026
63e39a1
Merge commit '78db9e187' into upstream-sync-2026-11-14-4
binaryfire Nov 19, 2026
0f21dbd
Stop a canceled coroutine's sleep at the interruption
binaryfire Nov 19, 2026
158e319
Detect streaming cancellation only at the transport's own waits
binaryfire Nov 19, 2026
c3cde00
Classify credential cancellation only from this call's waits
binaryfire Nov 19, 2026
5a9a2b2
Classify Redis cancellation at each native operation
binaryfire Nov 19, 2026
b0dbf6a
Require hypervel/guzzle 8.5.0.2 in hypervel/foundation
binaryfire Nov 19, 2026
80e5262
Add releaseUsingBackoff() to InteractsWithQueue
binaryfire Nov 19, 2026
6e9ebfb
Add the RetryFor queue attribute and refresh retry deadlines on manua…
binaryfire Nov 19, 2026
490d292
Cover cursor pagination of unions ordered by aliased expressions
binaryfire Nov 19, 2026
724c4de
Give an unaliased subquery in from() a default alias
binaryfire Nov 19, 2026
5dd3345
Add RawTemplate for inline Blade components
binaryfire Nov 19, 2026
deb4b17
Add withoutAffectingStickiness() to database connections
binaryfire Nov 19, 2026
7f49bef
Update the DB facade docblock for withoutAffectingStickiness()
binaryfire Nov 19, 2026
b46c040
Cover wildcard primary-attribute lookups during validation
binaryfire Nov 19, 2026
31a0dd6
Render bound attributes of dynamic components like the component tag
binaryfire Nov 19, 2026
3e0a50a
Cover tagged Redis cache reads in a single MGET
binaryfire Nov 19, 2026
f37e282
Finish batches that allow failures once every job has run
binaryfire Nov 19, 2026
a63807e
Find models by their keys when given models
binaryfire Nov 19, 2026
3d6726a
Add size methods to the list rule builder
binaryfire Nov 19, 2026
bd01acc
Name Laravel's renamed sticky-connection worker tests in the REMOVED …
binaryfire Nov 19, 2026
55b87dd
Remove unused protected methods
binaryfire Nov 19, 2026
89e76aa
Use Exceptions::fake() in the exception-throttling reporting tests
binaryfire Nov 19, 2026
522bdb5
Require hypervel/guzzle 8.5.0.2 in every package that uses it
binaryfire Nov 19, 2026
e167999
Stop a canceled coroutine's sleep across while() iterations
binaryfire Nov 19, 2026
cc6ae7f
Keep backoff schedules given as lists or comma-separated options
binaryfire Nov 19, 2026
d1bc11e
Count batched commands that do not use InteractsWithQueue
binaryfire Nov 19, 2026
06976f9
Correct when RetryFor windows start and when BatchFinished is dispatched
binaryfire Nov 19, 2026
5e39d34
Refuse generated classes whose names PHP rejects
binaryfire Nov 19, 2026
cc127e4
Track removal of Pest integration
binaryfire Nov 19, 2026
35f9909
Check generated PHP with php -l before writing it
binaryfire Nov 19, 2026
51a1b63
Keep a --backoff schedule when the deprecated --delay is also passed
binaryfire Nov 19, 2026
75dc0ab
Describe when a queued listener's RetryFor window starts
binaryfire Nov 19, 2026
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"google/protobuf": "^5.35",
"guzzlehttp/psr7": "^3.1",
"guzzlehttp/uri-template": "^1.0 || ^2.0",
"hypervel/guzzle": "^8.3",
"hypervel/guzzle": "^8.5.0.2",
"hypervel/guzzle-promises": "^3.1",
"laravel/agent-detector": "^2.0.5",
"laravel/serializable-closure": "^2.0.11",
Expand Down
4 changes: 4 additions & 0 deletions docs/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

## Framework-wide

- Remove native Windows runtime support across all Hypervel packages, including standalone packages that do not depend on Swoole. Remove code paths and test expectations used only when running on native Windows, and direct Windows developers to WSL 2 in the platform docs. Preserve public Laravel-compatible helpers and signatures. Keep handling Windows-originated input wherever it is valid on a supported host.

- Audit the entire codebase for behavior missing from its contracts, designing them as complete greenfield framework interfaces rather than copying Laravel's omissions. Add methods every conforming implementation must provide, based on real consumers and implementation semantics; keep internal helpers and implementation- or driver-specific capabilities off general contracts. Update implementations, tests and public-contract documentation together.

- In a separate PR, make factory-created dates immutable by contract, removing the application-wide mutable opt-out from `Date` / `DateFactory`, `now()` and `today()`. Audit custom classes, factories, callbacks and consumers; preserve useful timezone, locale and test-clock customization and immutable subclasses. Keep explicit mutable conversion at third-party boundaries. Update runtime enforcement, return types, tests and docs together, then tighten `hypervel/phpstan` typing and discarded-date diagnostics wherever immutability is guaranteed; retain accurate handling of external mutable dates. Review the Laravel API departures before implementation.
Expand Down Expand Up @@ -92,6 +94,8 @@ Remove older ways of doing things once a modern equivalent fully replaces them,

## Testing

- Remove Pest integration from Artisan’s test runners and generators, Testbench, and the user documentation. Update the affected tests to cover PHPUnit behavior.

- Finish switching the regular and nightly database jobs to Unix sockets, matching [laravel/framework#62323](https://github.com/laravel/framework/pull/62323). Swoole 6.3.0 RC2 fixes cold `caching_sha2_password` authentication over Unix sockets, and the MySQL 9.7 job and `UnixSocketAuthenticationTest` already run on a socket. Convert the remaining MySQL 8.4, MySQL Innovation and PostgreSQL 18 jobs. Keep the dedicated schema TLS check on TCP, and keep TCP coverage of MySQL Innovation's native dump path.

- Investigate a method attribute such as `#[ResetAfterTest]` to replace the manual static-reset list in `AfterEachTestSubscriber`. Discover methods once per test process and reuse the list after each test, covering classes loaded later without eagerly loading optional packages. Preserve required cleanup ordering, avoid duplicate inherited calls, and keep special lifecycle cleanup explicit. Reuse existing test-state registration where appropriate; avoid per-test scanning or a complex discovery system.
Expand Down
2 changes: 1 addition & 1 deletion src/ai/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"hypervel/events": "^0.4",
"hypervel/filesystem": "^0.4",
"hypervel/foundation": "^0.4",
"hypervel/guzzle": "^8.3",
"hypervel/guzzle": "^8.5.0.2",
"hypervel/guzzle-promises": "^3.1",
"hypervel/http": "^0.4",
"hypervel/json-schema": "^0.4",
Expand Down
2 changes: 1 addition & 1 deletion src/api-client/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"hypervel/conditionable": "^0.4",
"hypervel/container": "^0.4",
"hypervel/contracts": "^0.4",
"hypervel/guzzle": "^8.3",
"hypervel/guzzle": "^8.5.0.2",
"hypervel/guzzle-promises": "^3.1",
"hypervel/http": "^0.4",
"hypervel/pipeline": "^0.4",
Expand Down
2 changes: 1 addition & 1 deletion src/broadcasting/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"hypervel/contracts": "^0.4",
"hypervel/database": "^0.4",
"hypervel/foundation": "^0.4",
"hypervel/guzzle": "^8.3",
"hypervel/guzzle": "^8.5.0.2",
"hypervel/guzzle-promises": "^3.1",
"hypervel/http": "^0.4",
"hypervel/object-pool": "^0.4",
Expand Down
74 changes: 74 additions & 0 deletions src/bus/src/Batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,30 @@
use Hypervel\Container\Container;
use Hypervel\Contracts\Events\Dispatcher;
use Hypervel\Contracts\Queue\Factory as QueueFactory;
use Hypervel\Contracts\Queue\Job;
use Hypervel\Contracts\Support\Arrayable;
use Hypervel\Coroutine\Coroutine;
use Hypervel\Database\ConnectionResolverInterface;
use Hypervel\Queue\CallQueuedClosure;
use Hypervel\Queue\InteractsWithQueue;
use Hypervel\Support\Arr;
use Hypervel\Support\CarbonImmutable;
use Hypervel\Support\Collection;
use Hypervel\Support\Enumerable;
use JsonSerializable;
use LogicException;
use Throwable;
use WeakMap;

class Batch implements Arrayable, JsonSerializable
{
/**
* The batch job IDs of commands being processed that cannot reach their queued job.
*
* @var null|WeakMap<object, string>
*/
protected static ?WeakMap $commandJobIds = null;

/**
* Create a new batch instance.
*/
Expand Down Expand Up @@ -159,6 +169,51 @@ public function progress(): int
return $this->totalJobs > 0 ? (int) round(($this->processedJobs() / $this->totalJobs) * 100) : 0;
}

/**
* Get the ID the batch records for the given queued job.
*
* Horizon gives each retry a new UUID, so a retried batch job carries its original ID in the payload.
*
* @internal
*/
public static function jobIdFor(Job $job): ?string
{
return $job->payload()['batchJobId'] ?? $job->uuid();
}

/**
* Get the ID the batch records for the given command while it is processed.
*
* @internal
*/
public static function jobIdForCommand(object $command): ?string
{
if (isset(static::$commandJobIds[$command])) {
return static::$commandJobIds[$command];
}

// Only InteractsWithQueue makes $job the queued job; another job property belongs to the application.
return isset(class_uses_recursive($command)[InteractsWithQueue::class]) && $command->job instanceof Job
? static::jobIdFor($command->job)
: null;
}

/**
* Remember the batch job ID of a command that cannot reach its queued job.
*
* Commands without InteractsWithQueue have no queued job, and the IDs are held weakly so they never travel
* with the command or outlive it.
*
* @internal
*/
public static function rememberJobIdForCommand(object $command, Job $job): void
{
if (($jobId = static::jobIdFor($job)) !== null) {
static::$commandJobIds ??= new WeakMap;
static::$commandJobIds[$command] = $jobId;
}
}

/**
* Record that a job within the batch finished successfully, executing any callbacks if necessary.
*/
Expand Down Expand Up @@ -204,6 +259,8 @@ public function recordSuccessfulJob(string $jobId): void
$this->invokeCallbacks('then');
}

$this->markAsFinishedIfOnlyFailuresRemain($counts);

if ($counts->allJobsHaveRanExactlyOnce() && $this->hasFinallyCallbacks()) {
$this->invokeCallbacks('finally');
}
Expand Down Expand Up @@ -314,6 +371,8 @@ public function recordFailedJob(string $jobId, ?Throwable $e): void
$this->invokeCallbacks('catch', $e);
}

$this->markAsFinishedIfOnlyFailuresRemain($counts);

if ($counts->allJobsHaveRanExactlyOnce() && $this->hasFinallyCallbacks()) {
$this->invokeCallbacks('finally');
}
Expand All @@ -327,6 +386,21 @@ public function incrementFailedJobs(string $jobId): ?UpdatedBatchJobCounts
return $this->repository->incrementFailedJobs($this->id, $jobId);
}

/**
* Mark a batch that allows failures as finished once every remaining job has failed.
*/
protected function markAsFinishedIfOnlyFailuresRemain(UpdatedBatchJobCounts $counts): void
{
// Repositories that report completedFirstPass already finished the batch in their locked update.
if ($counts->completedFirstPass !== null) {
return;
}

if ($this->allowsFailures() && $counts->pendingJobs > 0 && $counts->allJobsHaveRanExactlyOnce()) {
$this->repository->markAsFinished($this->id);
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
}
}

/**
* Determine if this is the first job processed in the batch.
*/
Expand Down
8 changes: 7 additions & 1 deletion src/bus/src/Batchable.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ public function batching(): bool
{
$batch = $this->batch();

return $batch && ! $batch->finished() && ! $batch->cancelled();
if (! $batch || $batch->cancelled()) {
return false;
}

// Unlike Laravel, a failed job retried after its batch finished still belongs to the batch, so it does its work.
return ! $batch->finished()
|| in_array(Batch::jobIdForCommand($this), $batch->failedJobIds, true);
}

/**
Expand Down
72 changes: 63 additions & 9 deletions src/bus/src/DatabaseBatchRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,29 @@ public function incrementTotalJobs(string $batchId, int $amount): void
*/
public function decrementPendingJobs(string $batchId, string $jobId): ?UpdatedBatchJobCounts
{
$values = $this->updateAtomicValues($batchId, function ($batch) use ($jobId) {
$completedFirstPass = false;

$values = $this->updateAtomicValues($batchId, function ($batch) use ($jobId, &$completedFirstPass) {
$failedJobIds = (array) json_decode($batch->failed_job_ids, true);
$remainingFailedJobIds = array_values(array_diff($failedJobIds, [$jobId]));
$pendingJobs = $batch->pending_jobs - 1;

$completedFirstPass = $this->completesFirstPass(
$batch->pending_jobs - count($failedJobIds),
$pendingJobs - count($remainingFailedJobIds),
);

return [
'pending_jobs' => $batch->pending_jobs - 1,
'pending_jobs' => $pendingJobs,
'failed_jobs' => $batch->failed_jobs,
'failed_job_ids' => json_encode(array_values(array_diff((array) json_decode($batch->failed_job_ids, true), [$jobId]))),
];
'failed_job_ids' => json_encode($remainingFailedJobIds),
] + $this->finishWhenOnlyFailuresRemain($batch, $pendingJobs, $completedFirstPass);
});

return $values === null ? null : new UpdatedBatchJobCounts(
$values['pending_jobs'],
$values['failed_jobs']
$values['failed_jobs'],
$completedFirstPass,
);
}

Expand All @@ -125,20 +137,62 @@ public function decrementPendingJobs(string $batchId, string $jobId): ?UpdatedBa
*/
public function incrementFailedJobs(string $batchId, string $jobId): ?UpdatedBatchJobCounts
{
$values = $this->updateAtomicValues($batchId, function ($batch) use ($jobId) {
$completedFirstPass = false;

$values = $this->updateAtomicValues($batchId, function ($batch) use ($jobId, &$completedFirstPass) {
$failedJobIds = (array) json_decode($batch->failed_job_ids, true);
$updatedFailedJobIds = array_values(array_unique(array_merge($failedJobIds, [$jobId])));

$completedFirstPass = $this->completesFirstPass(
$batch->pending_jobs - count($failedJobIds),
$batch->pending_jobs - count($updatedFailedJobIds),
);

return [
'pending_jobs' => $batch->pending_jobs,
'failed_jobs' => $batch->failed_jobs + 1,
'failed_job_ids' => json_encode(array_values(array_unique(array_merge((array) json_decode($batch->failed_job_ids, true), [$jobId])))),
];
'failed_job_ids' => json_encode($updatedFailedJobIds),
] + $this->finishWhenOnlyFailuresRemain($batch, $batch->pending_jobs, $completedFirstPass);
});

return $values === null ? null : new UpdatedBatchJobCounts(
$values['pending_jobs'],
$values['failed_jobs']
$values['failed_jobs'],
$completedFirstPass,
);
}

/**
* Determine if an update ran the batch's last job that had not yet run.
*
* Failed jobs stay pending until they succeed, so the jobs that have not yet run are the pending
* jobs minus the distinct failed jobs. A job that fails again on retry is only counted once.
*/
protected function completesFirstPass(int $notYetRunBefore, int $notYetRunAfter): bool
{
return $notYetRunBefore > 0 && $notYetRunAfter <= 0;
}

/**
* Get the finish time to store when only failed jobs remain in a batch that allows failures.
*
* Unlike Laravel, the batch is finished in the same locked update instead of after the job's callbacks, so a job
* added to the batch at the same moment reopens it instead of being stranded in a finished batch. An existing
* finish time, such as a cancellation's, is kept.
*
* @return array{finished_at?: int}
*/
protected function finishWhenOnlyFailuresRemain(object $batch, int $pendingJobs, bool $completedFirstPass): array
{
if (! $completedFirstPass || $pendingJobs <= 0 || $batch->finished_at !== null) {
return [];
}

return ($this->unserialize($batch->options)['allowFailures'] ?? false) === true
? ['finished_at' => time()]
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
: [];
}

/**
* Update an atomic value within the batch.
*/
Expand Down
5 changes: 4 additions & 1 deletion src/bus/src/UpdatedBatchJobCounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ class UpdatedBatchJobCounts
{
/**
* Create a new batch job counts object.
*
* @param null|bool $completedFirstPass Whether the update ran the batch's last job that had not yet run, or null when the repository does not report it. A repository that reports it also marks a batch that allows failures as finished in that same update.
*/
public function __construct(
public int $pendingJobs = 0,
public int $failedJobs = 0,
public ?bool $completedFirstPass = null,
) {
}

Expand All @@ -20,6 +23,6 @@ public function __construct(
*/
public function allJobsHaveRanExactlyOnce(): bool
{
return ($this->pendingJobs - $this->failedJobs) === 0;
return $this->completedFirstPass ?? ($this->pendingJobs - $this->failedJobs) === 0;
}
}
3 changes: 2 additions & 1 deletion src/cache/src/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,8 @@ protected function handleManyResult(array $keys, string $key, mixed $value): mix
// genuine miss (null) and cached-null (sentinel) both resolve to the
// per-key default, matching get()'s convention.
if (is_null($value) || $value === NullSentinel::VALUE) {
return (isset($keys[$key]) && ! array_is_list($keys)) ? value($keys[$key]) : null;
// PHP stores canonical integer strings as integer keys, which are requested keys rather than defaults.
return isset($keys[$key]) && (string) (int) $key !== $key ? value($keys[$key]) : null;
}

return $value;
Expand Down
2 changes: 1 addition & 1 deletion src/console/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"hypervel/coroutine": "^0.4",
"hypervel/engine": "^0.4",
"hypervel/filesystem": "^0.4",
"hypervel/guzzle": "^8.3",
"hypervel/guzzle": "^8.5.0.2",
"hypervel/log": "^0.4",
"hypervel/macroable": "^0.4",
"hypervel/prompts": "^0.4",
Expand Down
34 changes: 30 additions & 4 deletions src/console/src/GeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Process\Process;

use function Hypervel\Support\php_binary;

abstract class GeneratorCommand extends Command implements PromptsForMissingInput
{
Expand Down Expand Up @@ -183,10 +186,9 @@ public function handle(): bool|int
// First we need to ensure that the given name is not a reserved word within the PHP
// language and that the class name will actually be valid. If it is not valid we
// can error now and prevent from polluting the filesystem using invalid files.
// Unlike Laravel, this fails so the command exits with an error and generates no companion files.
if ($this->isReservedName($this->getNameInput())) {
$this->components->error('The name "' . $this->getNameInput() . '" is reserved by PHP.');

return false;
$this->fail('The name "' . $this->getNameInput() . '" is reserved by PHP.');
}

$name = $this->qualifyClass($this->getNameInput());
Expand All @@ -207,9 +209,13 @@ public function handle(): bool|int
// Next, we will generate the path to the location where this class' file should get
// written. Then, we will build the class and make the proper replacements on the
// stub files so that it gets the correctly formatted namespace and class name.
$contents = $this->sortImports($this->buildClass($name));

$this->ensureGeneratedCodeCompiles($path, $contents);

$this->makeDirectory($path);

$this->replaceFile($path, $this->sortImports($this->buildClass($name)));
$this->replaceFile($path, $contents);

$info = $this->type;

Expand Down Expand Up @@ -485,6 +491,26 @@ protected function isReservedName(string $name): bool
return array_any($this->reservedNames, fn ($reservedName) => strtolower($reservedName) === $name);
}

/**
* Ensure the generated PHP compiles before it is written.
*
* Unlike Laravel, the command fails before writing the file, even with --force, instead of creating one that PHP
* refuses to load, such as a class named like a class it imports.
*/
protected function ensureGeneratedCodeCompiles(string $path, string $contents): void
{
// Blade views are compiled by Blade before PHP reads them.
if (! str_ends_with($path, '.php') || str_ends_with($path, '.blade.php')) {
return;
}

$process = new Process([php_binary(), '-d', 'display_errors=stderr', '-d', 'log_errors=0', '-l'], input: $contents);

if ($process->run() !== 0) {
$this->fail(sprintf('The generated file [%s] is not valid PHP. %s', $path, trim($process->getErrorOutput())));
}
}

/**
* Get the first view directory path from the application configuration.
*/
Expand Down
Loading