-
Notifications
You must be signed in to change notification settings - Fork 0
Fix JSON correctness and package metadata discovery #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b01e5a6
fix(support): define consistent JSON nesting semantics
binaryfire 071fd79
fix(collections): preserve maximum-depth JSON round trips
binaryfire 7799f7c
fix(filesystem): read JSON at the supported nesting limit
binaryfire f84ef12
fix(support): preserve Composer JSON file round trips
binaryfire 95fbcb6
fix: preserve framework-owned JSON round trips
binaryfire 7982f86
refactor(concurrency): own serialized closure responses
binaryfire cae3ec6
fix(validation): validate JSON casts consistently
binaryfire 80375af
fix(database): make Eloquent JSON corruption explicit
binaryfire 2f155e9
fix(database): reject invalid JSON query bindings
binaryfire c835b9d
fix(database): fail loudly on invalid console JSON
binaryfire 9b68b70
fix(telescope): harden JSON storage and redaction
binaryfire ae12786
fix(foundation): reject corrupt package manifests
binaryfire f8fb1d7
docs: add JSON correctness implementation plan
binaryfire e4e5e61
test(testbench): accept native errors from either stream
binaryfire e33ba4d
fix(concurrency): validate transported exception classes
binaryfire File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
501 changes: 501 additions & 0 deletions
501
docs/plans/2026-08-11-0932-json-correctness-and-package-metadata.md
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Hypervel\Concurrency; | ||
|
|
||
| use Hypervel\Support\Json; | ||
| use RuntimeException; | ||
| use Throwable; | ||
|
|
||
| /** | ||
| * Decode serialized-closure responses produced by the framework subprocess command. | ||
| * | ||
| * The subprocess stream may also contain output from the application task, so the | ||
| * response envelope is validated before use. Task results may contain objects, so | ||
| * successful responses require unrestricted unserialization. Callers must never | ||
| * pass external input to this decoder. | ||
| * | ||
| * @internal | ||
| */ | ||
| class SerializedClosureResult | ||
| { | ||
| /** | ||
| * Return the unserialized result or throw the reconstructed remote exception. | ||
| * | ||
| * @throws Throwable | ||
| */ | ||
| public static function decode(string $output): mixed | ||
| { | ||
| if (($position = strpos($output, "\x1f\x8b")) !== false) { | ||
| $output = substr($output, 0, $position); | ||
| } | ||
|
|
||
| $payload = Json::decode($output); | ||
|
|
||
| if (! is_array($payload) | ||
| || ! array_key_exists('successful', $payload) | ||
| || ! is_bool($payload['successful'])) { | ||
| throw new RuntimeException('Invalid serialized closure response envelope.'); | ||
| } | ||
|
|
||
| /** @var array{ | ||
| * successful: bool, | ||
| * result?: string, | ||
| * exception?: class-string<Throwable>, | ||
| * message?: string, | ||
| * parameters?: array<string, mixed> | ||
| * } $payload | ||
| */ | ||
| if ($payload['successful'] === false) { | ||
| if ((array_key_exists('exception', $payload) && ! is_string($payload['exception'])) | ||
| || (array_key_exists('message', $payload) && ! is_string($payload['message'])) | ||
| || (array_key_exists('parameters', $payload) && ! is_array($payload['parameters']))) { | ||
| throw new RuntimeException('Invalid serialized closure response envelope.'); | ||
| } | ||
|
|
||
| $exceptionClass = $payload['exception'] ?? RuntimeException::class; | ||
| $message = $payload['message'] ?? 'Serialized closure execution failed.'; | ||
| $parameters = $payload['parameters'] ?? ['message' => $message]; | ||
|
|
||
| try { | ||
| if (! is_a($exceptionClass, Throwable::class, true)) { | ||
| throw new RuntimeException("The transported exception class [{$exceptionClass}] is not an available Throwable."); | ||
| } | ||
|
|
||
| $exception = new $exceptionClass(...$parameters); | ||
| } catch (Throwable $constructionException) { | ||
| throw new RuntimeException($message, previous: $constructionException); | ||
| } | ||
|
|
||
| throw $exception; | ||
| } | ||
|
|
||
| $encodedResult = $payload['result'] ?? null; | ||
| $serializedResult = is_string($encodedResult) | ||
| ? base64_decode($encodedResult, true) | ||
| : false; | ||
|
|
||
| if ($serializedResult === false) { | ||
| throw new RuntimeException('Unable to decode the serialized closure result.'); | ||
| } | ||
|
|
||
| // Malformed payloads warn and return false, which is also a valid serialized result. | ||
| $unserializedResult = @unserialize($serializedResult); | ||
|
|
||
| if ($unserializedResult === false && $serializedResult !== serialize(false)) { | ||
| throw new RuntimeException('Unable to decode the serialized closure result.'); | ||
| } | ||
|
|
||
| return $unserializedResult; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.