Specify scope arenas, dynamic reuse, and global anchors - #147
Specify scope arenas, dynamic reuse, and global anchors#147TheLazyCat00 wants to merge 16 commits into
Conversation
📝 WalkthroughWalkthroughThe memory model now defines separate fixed-size and dynamic regions per scope, a runtime-global anchor pool, unified segmented offsets, scoped allocation reuse, and stable anchor identity across moves and rehosting. ChangesMemory model
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
spec/memory.md (1)
413-418: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy liftDo not lose source-scope anchor paths during promotion.
Promotion can leave source tethers using the old cell while destination tethers use a newly minted cell. With only one backpointer, later moves update one cell and stale the other. Define forwarding/multi-anchor semantics or prohibit re-anchoring/movement while the old cell remains live.
spec/memory.md#L413-L418: correct the normative promotion algorithm.stories/memory.md#L106-L110: align the explanation with that algorithm.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@spec/memory.md` around lines 413 - 418, The promotion semantics in spec/memory.md lines 413-418 and stories/memory.md lines 106-110 must preserve all live source-scope anchor paths. Define forwarding or multi-anchor behavior so subsequent moves update both the old source cell and any newly minted destination cell, or explicitly prohibit re-anchoring and movement while the old cell remains live; make both sections describe the same normative algorithm.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@spec/memory.md`:
- Around line 304-316: Define the representation and allocation rules for
dynamic blocks exceeding one chunk in the normative allocator section around the
dynamic block growth rules in spec/memory.md:304-316, including contiguous
multi-chunk spans and how their handles address them, or explicitly cap blocks
at one chunk. Apply the same oversized-block behavior in the corresponding
narrative at stories/memory.md:80-82 so both documents remain consistent.
---
Outside diff comments:
In `@spec/memory.md`:
- Around line 413-418: The promotion semantics in spec/memory.md lines 413-418
and stories/memory.md lines 106-110 must preserve all live source-scope anchor
paths. Define forwarding or multi-anchor behavior so subsequent moves update
both the old source cell and any newly minted destination cell, or explicitly
prohibit re-anchoring and movement while the old cell remains live; make both
sections describe the same normative algorithm.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: zane-lang/coderabbit/.coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 38120942-bcee-4ab5-9075-0622b78dc8c5
📒 Files selected for processing (2)
spec/memory.mdstories/memory.md
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@spec/memory.md`:
- Line 230: Update the headings in spec/memory.md, including “3.1 Scope arenas,
the global anchor pool, and segmented offsets” and the additionally identified
headings, by inserting one blank line between each heading and its following
content to satisfy markdownlint MD022.
- Around line 403-407: Clarify the move/rehosting rules in section 4.5 for
destinations with existing anchored guests. Define how the source and
destination anchor identities and both guest sets are preserved, or explicitly
forbid this move; align the result with section 2.2 and ensure no anchor
identity can be recycled while referenced.
- Around line 274-276: Clarify the anchor-page reclamation contract in the
free-address stack description: either require wholly free anchor pages to
remain mapped while their offsets are retained, or specify that unmapping
removes all offsets for the page and updates the chunk directory and any reused
chunk IDs before reclamation. Ensure later allocations cannot pop an offset
referring to an unmapped or repurposed page.
- Around line 261-263: Align anchor-cell representation with segmented-offset
encoding by choosing and documenting either 8-byte physical cell stride/padding
or a 4-byte offset unit. Update spec/memory.md lines 261-263 to define
anchor-page addressability and alignment, reconcile the anchor-cell width and
12-byte logical cost in spec/memory.md lines 338-351, and mirror the normative
representation in stories/memory.md lines 63-69; revise all affected memory-cost
and capacity claims consistently.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: zane-lang/coderabbit/.coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: ff6870d4-96b8-4599-87ee-389081f9015e
📒 Files selected for processing (2)
spec/memory.mdstories/memory.md
TheLazyCat00
left a comment
There was a problem hiding this comment.
dont rewrite the entire story
* docs: fix review defects in the arena and global-anchor change Repair the integration half of the memory-model revision and the cross-references it left stale. - Restore the story pointer at memory.md §3.6; it named a chapter heading that no longer exists, so the link resolved to nothing. - Point the sections whose rules the revision changed (§3.1, §3.2, §3.6, §4.1, §4.5, §4.6) at the new story chapter; §4.6 had no pointer at all. - Restore the story's placement chapter to its previous wording: the chapter predates this change, and its in-prose spec reference is a commit-pinned permalink rather than a living relative link. - Update the glossary entries for anchor cell and arena placement, which still described a scope-local anchor region. - Record the both-sides-guests move restriction in lifetimes.md, the home of move legality, as §1.10 with a summary row. - Restore the arena-granularity latitude and the destruction-timing distinction dropped from §3.1 and §3.2, and note that the fixed-size region reclaims nothing individually. - State how the anchor pool avoids issuing identity 0, restore the address formula, drop a contrast with storage the language has no form for, and square the segmented-offset diagram. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YnNCXtguHg4tSbLCtTT2c * docs: sharpen the scope-drain guarantee and the move-liveness summary Address review on the promotion and move-liveness wording. - State the drain guarantee as reachability: a scope's memory is released at drain and no guest resolves into released memory, with an escaping value promoted out first and its guests following the canonical anchor. The previous phrasing claimed source-arena memory outlives every guest that can reach it, which promotion breaks. - Say in the glossary that promotion copies the fixed-size bytes — the inline payload or the handle — while a dynamic backing store transfers without being copied. - Complete the move-liveness summary row with the case where neither side has live guests: a moved-from slot that stays readable anchors lazily. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YnNCXtguHg4tSbLCtTT2c --------- Co-authored-by: Claude <noreply@anthropic.com>
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@spec/memory.md`:
- Line 314: Define a consistent lifetime mechanism for dynamic backing stores:
update spec/memory.md lines 314-314 and 357-357 so promotion and move/rehosting
allocate or retain storage in an arena covering every possible destination, or
relocate/copy it before source teardown; qualify spec/glossary.md lines 188-189
so ownership is not always attributed to the creating scope’s dynamic region;
and update stories/memory.md lines 122-124 to describe the same backing-store
lifetime and promotion behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: zane-lang/coderabbit/.coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 34f998ec-ff77-455e-8f20-55fc7f346a89
📒 Files selected for processing (5)
README.mdspec/glossary.mdspec/lifetimes.mdspec/memory.mdstories/memory.md
Define rehosting as copying the complete hosted representation into destination-owned storage. Inline bytes move into the destination slot, dynamic backing stores relocate into equal-size destination-region allocations, old source storage ceases to be live, and the source host-capable slot becomes a guest through the canonical tether. Keep anchor bookkeeping O(1) in the number of guests while stating the physical relocation cost explicitly. Align the normative memory model, glossary, and design story, and complete the glossary's verb list with operators and lambdas.
0bcc770 to
6140d1a
Compare
|
Addressed the remaining review on dynamic backing-store lifetime. Rehosting now relocates the complete hosted representation into destination-owned storage before the source can drain: inline bytes are copied into the destination slot, each dynamic backing store moves into an equal-size destination-region block or oversized span, and the old source allocation is returned to its exact-size stack. The old source payload then ceases to be live, while its host-capable slot becomes a guest through the canonical tether. The normative memory model, glossary, and story now use the same rule. They also distinguish O(1) anchor bookkeeping in the number of guests from physical relocation, whose cost is proportional to the bytes or elements moved. |
|
@coderabbitai Please implement the following design change and commit it directly to the current PR branch ( Replace the user-visible “two-live-guest” move rejection with a purely runtime forwarding-anchor mechanism. This is not a source-language concept and must not add a language restriction. Required semantics:
Preserve the existing decisions about global anchor pages, 8-byte slots, destination-owned backing-store relocation, exact-size dynamic reuse, and immediate free-stack reuse once the relevant anchor retirement event is reached. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '== Branch and working tree =='
git branch --show-current
git status --short
printf '%s\n' '== Candidate files =='
fd -t f -a '^(memory|lifetimes|glossary)\.md$' spec stories || true
fd -t f -a '^tmp-forwarding-anchor-update\.yml$' .github || true
printf '%s\n' '== Markdown outlines =='
ast-grep outline spec/memory.md --items all 2>/dev/null || true
ast-grep outline spec/lifetimes.md --items all 2>/dev/null || true
ast-grep outline spec/glossary.md --items all 2>/dev/null || true
ast-grep outline stories/memory.md --items all 2>/dev/null || true
printf '%s\n' '== Semantics and obsolete-claim references =='
rg -n -i -C 4 \
'forward|anchor|tether|canonical identity|one canonical|rehosting.*hop|two.live.guest|Move guest liveness|guest liveness|path.compress|terminal|overwrite|relocat|retir|drain|free.stack' \
spec/memory.md spec/lifetimes.md spec/glossary.md stories/memory.md README.md 2>/dev/null || true
printf '%s\n' '== Temporary workflow content, if present =='
workflow=$(fd -t f -a '^tmp-forwarding-anchor-update\.yml$' .github | head -n 1 || true)
if [ -n "$workflow" ]; then
cat -n "$workflow"
fi
printf '%s\n' '== Current PR body =='
gh pr view 147 --repo zane-lang/spec --json title,body,url --jq '"URL: \(.url)\nTitle: \(.title)\n\n\(.body)"'Length of output: 164785 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '== Validate stale claims after edits =='
rg -n -i \
'no forwarding cells|forwarding is unnecessary|two.live.guest|Move guest liveness|rehosting adds no forwarding hop|moves with guests on both sides.*rejected' \
spec/memory.md spec/lifetimes.md spec/glossary.md stories/memory.md README.md .github 2>/dev/null || true
printf '%s\n' '== Confirm temporary workflow removal =='
if fd -t f -a '^tmp-forwarding-anchor-update\.yml$' .github | grep -q .; then
echo 'Temporary workflow is still present.'
exit 1
fi
echo 'Temporary workflow is absent.'
printf '%s\n' '== Changed-file review =='
git diff --check
git diff -- spec/memory.md spec/lifetimes.md spec/glossary.md stories/memory.md README.md .github/workflows/tmp-forwarding-anchor-update.ymlLength of output: 4426 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '== Obsolete semantics must be absent =='
if rg -n -i \
'no forwarding cells|forwarding is unnecessary|two.live.guest|Move guest liveness|rehosting adds no forwarding hop|moves with guests on both sides.*rejected' \
spec/memory.md spec/lifetimes.md spec/glossary.md stories/memory.md README.md .github; then
echo 'Obsolete forwarding or move-restriction wording remains.' >&2
exit 1
fi
printf '%s\n' '== Required forwarding semantics must be present =='
rg -n -i -C 2 \
'terminal.*anchor|forwarding.*anchor|path.compress|rebind|copying.*guest|scope drains|recursive|contained reference' \
spec/memory.md spec/glossary.md stories/memory.md
printf '%s\n' '== Temporary workflow must be absent =='
if fd -t f -a '^tmp-forwarding-anchor-update\.yml$' .github | grep -q .; then
echo 'Temporary workflow is still present.' >&2
exit 1
fi
git diff --check
git diff -- spec/memory.md spec/lifetimes.md spec/glossary.md stories/memory.md .github/workflows/tmp-forwarding-anchor-update.ymlLength of output: 4648
The obsolete behavior remains in:
The command stopped before it could validate required forwarding semantics or the final diff. After the planned edits and PR-description update are applied, rerun the validation script to confirm the old restriction and temporary workflow are gone. |
|
@coderabbitai autofix |
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. The agent ran but didn't make any changes. The issues may already be fixed or require manual intervention. |
|
Closing without merging — continued in #151. Nothing here is dropped. #151 is branched from this PR's head ( What #151 adds on top is the guest-source restriction — a bare symbol is no longer a legal source for a new The consolidation is deliberate: reviewing the source restriction against a base that already carries the anchor design is more useful than reviewing the two separately, and it leaves one PR to merge instead of a chain. Generated by Claude Code |
What changed
Why
Fixed-size values and hosts should remain densely inline, while variable-sized backing stores need relocation and intra-scope reuse. Rehosting must not leave a destination handle pointing into a source scope that may drain. Copying every owned byte into destination-owned regions gives the destination an independent lifetime.
When both source and destination already have guests, destroying the destination occupant still leaves two existing anchor identities that must reach the replacement. Runtime forwarding preserves both promises without introducing a source-language move restriction: the destination anchor remains terminal and the source anchor forwards to it. New guest copies use the terminal identity, while older guests may follow the forwarding chain until their original scope drains.
Validation