Skip to content

[fix] preserve snapshot cycles across shared containers (LET-40) - #191

Merged
vt128 merged 5 commits into
masterfrom
codex/fix-shared-dict-formatting-let40
Nov 14, 2026
Merged

vt128 merged 5 commits into
masterfrom
codex/fix-shared-dict-formatting-let40

Conversation

@vt128

@vt128 vt128 commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

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 430564e1 incorporates verified master cfeb8892 (#203). The formatter production code is unchanged from b1af6e4a apart 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 / 74c69256 below 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:

  • Normal commit checks pass. Current Starlight is tested through an equal-tree archive of its merged safety fixes; the interpreter remains pinned.
  • 84-leg baseline/candidate comparison (80 active + four archived MQ diagnostic legs), including complete build, race-count=2 atomic coverage and vet on Go 1.27.4 and each consumer's existing floor. Two passing current-version host legs retain their original evidence; the remaining 82 are newly executed after correcting the validation environment. CLI main/examples use the approved Go 1.26.0 floor.
  • no previously covered blocks lost, all revised/new formatter statements covered, and eight actual CLI hello/qrcard executions pass. No unit tests, opt-in services and other SKIPs are separately classified.
  • CLI main-entry validation covers 28 exact application/configuration/eval/error/budget/capability scenarios. Four additional help runs preserve the selected pflag v1.0.5 exit-2 behavior. All four binaries have verified compiler and dependency metadata.
  • Two current-upstream Go-host/Machine race programs pass on Go 1.27.4 and 1.19.13. Each checks 128 snapshots/writes, three repaired cycles, exact output and Go-only API availability.
  • The original head's Project evaluation remained pending. Current-master integration is an ordinary merge resolving a real test conflict; it does not change CI or provider configuration. The new exact head must pass all required checks, both Codecov contexts and checks-watch before merge.

The historical fixed benchmarks retain their original 3cedbf3/015686d7 and Go 1.27.3/1.19.13 labels; this merge keeps the formatter implementation unchanged. Explicit Snapshot/Set32 costs 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.

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.
@codacy-production

codacy-production Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 128 complexity · 2 duplication

Metric Results
Complexity 128
Duplication 2

View in Codacy

🟢 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

View coverage diff in Codacy

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

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.12%. Comparing base (cfeb889) to head (430564e).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

vt128 added 3 commits November 9, 2026 15:45
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.
@vt128
vt128 marked this pull request as ready for review November 12, 2026 18:52
@vt128
vt128 merged commit 14b31e9 into master Nov 14, 2026
24 checks passed
@vt128
vt128 deleted the codex/fix-shared-dict-formatting-let40 branch November 14, 2026 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant