You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[fix] make shared dictionary output fail safely - #204
SharedDict.String and direct Go ToJSON read the mapping without synchronization. JSON/Set iteration can also race between readers. This change repairs default formatting, SnapshotString, and Go/script JSON output with nonblocking output coordination.
Formatting captures each visited SharedDict before invoking formatting callbacks. JSON checks native data and uses the official encoder while holding the mapping lock. Type names use atomic storage; attribute lookup uses fixed metadata. Script methods retain the caller thread and avoid freezing the receiver through a bound to_json closure.
Behavior changes:
Held mapping/output locks produce shared_dict(<busy>) for formatting, or an empty string plus ErrSharedDictBusy for Go JSON; script JSON raises the error. Retry outside the current critical section.
SharedDict JSON accepts native scalars, containers, structs/modules, duration and the pinned interpreter’s immutable range/string/bytes views. Other Go-backed values, including GoStruct, GoMap, GoSlice and custom JSON/attribute implementations, are rejected. Convert them to independently owned plain data first. The general EncodeStarlarkJSON helper keeps its existing behavior and caller synchronization requirements.
Native aliases shared by independent owners still require common ownership or application synchronization. This does not provide an atomic snapshot of an arbitrary mutable graph. Normal output order and configured names remain.
Validation:
Go 1.27.4 and Go 1.19.13 baseline/candidate builds, full race-count=2 suites, vet and complete Go examples pass. Coverage increases with no lost coverage in unchanged functions/files; revised/new functions cover 204/207 statements, with three defensive guards classified.
The fresh ecosystem comparison passes all 84 legs, including Starbox, StarCLI, kit/examples and domain consumers. Forty consumer profile pairs retain exactly the same 16,012 coverage blocks. Eight real CLI demonstrations pass. An interrupted run retained 60 completed legs and resumed only the remaining 24; original results were not rerun. One overwritten start-metadata record is disclosed separately; command outputs and source guards remain intact.
One identical two-reader/no-writer race program reproduces the old iterator race and passes on the candidate.
Final documentation updates leave all 115 Go/test/module files byte-identical to the fully tested runtime candidate. Normal commit hooks pass. Go minimum versions, interpreter pin and dependencies are unchanged.
A fixed benchmark cohort compares the previous Starlet implementation (14b31e93) with this runtime, using identical harnesses and compiler per pair: 24 serial processes, 312 rows, no extra samples. Set formatting takes about 15% more time on the native host and 47% on the emulated Go 1.19 floor; JSON cases add about 10–20%. JSON also adds temporary allocations; nonempty name updates add 16 bytes and one allocation. Ordinary Get/SetKey add no allocations. These are descriptive, machine/data-dependent observations, not an equivalence or zero-overhead guarantee. The usage guide includes the qualitative costs and benchmark command.
The native-data JSON input contract above is intentional to prevent host callbacks under the mapping lock. The final head passes all 23 required checks, all 24 latest checks, both Codecov contexts, review/comment inspection and checks-watch.
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer TIP This summary will be updated as you push new changes.
❌ Patch coverage is 97.22222% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.20%. Comparing base (14b31e9) to head (0f9614e).
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
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.
SharedDict.Stringand direct GoToJSONread the mapping without synchronization. JSON/Set iteration can also race between readers. This change repairs default formatting,SnapshotString, and Go/script JSON output with nonblocking output coordination.Formatting captures each visited SharedDict before invoking formatting callbacks. JSON checks native data and uses the official encoder while holding the mapping lock. Type names use atomic storage; attribute lookup uses fixed metadata. Script methods retain the caller thread and avoid freezing the receiver through a bound
to_jsonclosure.Behavior changes:
shared_dict(<busy>)for formatting, or an empty string plusErrSharedDictBusyfor Go JSON; script JSON raises the error. Retry outside the current critical section.GoStruct,GoMap,GoSliceand custom JSON/attribute implementations, are rejected. Convert them to independently owned plain data first. The generalEncodeStarlarkJSONhelper keeps its existing behavior and caller synchronization requirements.Validation:
A fixed benchmark cohort compares the previous Starlet implementation (
14b31e93) with this runtime, using identical harnesses and compiler per pair: 24 serial processes, 312 rows, no extra samples. Set formatting takes about 15% more time on the native host and 47% on the emulated Go 1.19 floor; JSON cases add about 10–20%. JSON also adds temporary allocations; nonempty name updates add 16 bytes and one allocation. Ordinary Get/SetKey add no allocations. These are descriptive, machine/data-dependent observations, not an equivalence or zero-overhead guarantee. The usage guide includes the qualitative costs and benchmark command.The native-data JSON input contract above is intentional to prevent host callbacks under the mapping lock. The final head passes all 23 required checks, all 24 latest checks, both Codecov contexts, review/comment inspection and checks-watch.