Repository navigation
[fix] preserve snapshot cycles across shared containers (LET-40) - #191
Conversation
Keep one formatting path across SharedDict, Struct and Set values so container cycles terminate without starting a fresh String traversal. Preserve external synchronization for nested values and release set iterators before host callbacks. Add bounded cycle and compatibility tests.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 128 |
| Duplication | 2 |
🟢 Coverage 100.00% diff coverage · +0.05% coverage variation
Metric Results Coverage variation ✅ +0.05% coverage variation (-1.00%) Diff coverage ✅ 100.00% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (cfeb889) 8530 8117 95.16% Head commit (430564e) 8622 (+92) 8209 (+92) 95.21% (+0.05%) 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 details
Coverable lines Covered lines Diff coverage Pull request (#191) 97 97 100.00% 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.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #191 +/- ##
==========================================
+ Coverage 94.05% 94.12% +0.06%
==========================================
Files 53 53
Lines 6834 6913 +79
==========================================
+ Hits 6428 6507 +79
Misses 258 258
Partials 148 148 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Move Set and Struct traversal outside the common formatter frame. Capture small sets and ancestor paths in bounded local buffers, and skip the formatter for empty root snapshots. Preserve cycle and callback behavior with spill and deep-ancestor tests.
SnapshotString could exhaust the stack when cycles crossed SharedDict, Struct or Set values. The fix carries one ancestor path across supported containers, uses captured root entries for back-references, and separates dictionary-key ancestry from value ancestry. Set iteration finishes before formatting callbacks.
This is the existing opt-in Go diagnostic helper. Legacy String/default printing, SharedDict layout, module registration, dependencies and Go floors remain unchanged. Snapshots are shallow; nested mutable values still require caller synchronization. Custom values, duplicate-field Go structs, tuple-only Go cycles and general depth/output limits retain the documented boundaries.
Current integration
430564e1incorporates verified mastercfeb8892(#203). The formatter production code is unchanged fromb1af6e4aapart from the ToJSON documentation. The test insertion conflict is resolved with all earlier tests and the complete #203 regression preserved. Fresh joint-current-Starlight baseline/candidate validation passes on Go 1.27.4 and 1.19.13: build, full race-count=2 coverage and vet, 118/118 revised/new statements covered per compiler, and no old covered blocks lost. The ordinary default-dependency commit hook also passes.Retained acceptance on
b1af6e4a/74c69256below keeps its original version labels. Strict production-source and module equality bridges it to this integration; the 84-leg cohort and historical benchmarks were not rerun:The historical fixed benchmarks retain their original
3cedbf3/015686d7and Go 1.27.3/1.19.13 labels; this merge keeps the formatter implementation unchanged. ExplicitSnapshot/Set32costs about +11.3%/+38.2% time and +248B per call; floor SetStruct32 costs +16.8% time. Nested/repeated SharedDict cases add +232/+368B; Struct8 adds +224/+240B on host/floor. Legacy control allocations are unchanged; the floor native-Dict control's +1.49% timing signal remains recorded without a proven cause. These are accepted proportional costs for opt-in diagnostic correctness, with no claim of performance equivalence and no extra sampling. Costs depend on data, compiler and machine; avoid diagnostic formatting in business hot loops.Tracks LET-40. #203 documents and tests caller synchronization for legacy String/print and direct-Go ToJSON; concurrent unsynchronized use of those methods remains a separate limitation.