build: --explain-copies hint line for nested writes (take out, put back) #302

Closed
opened 2026-10-10 02:07:23 +00:00 by orion · 3 comments
Collaborator

Context

torb build --explain-copies (#61) reports each copy the compiler can prove, with its source span and the reason. PERFORMANCE.md section 6 also shows a second = line that says how to avoid the copy (take the row out and put it back, removeAt ... insert). #61 deliberately ships without it.

Acceptance criteria

  • For a copy of a nested write (a[i][j] = ... where a[i] is shared), the --explain-copies note gains the second = line from PERFORMANCE.md section 6 naming the take-out / put-back rewrite with the user's own variable names.
  • The hint appears only when the rewrite is valid for the written container type (a list or map owner); other reasons keep the single reason line.
  • A test in compiler/tests/ pins the full text of one note with the hint and one without.
  • docs/tooling/torb-build.md shows the extended note.

Dependencies

  • Blocked by #61 (the flag, the report and the note format).

Seed impact

None: the flag is not used by the compiler's own build (tools/bootstrap.sh passes only build ./compiler --output), so one commit.

## Context `torb build --explain-copies` (#61) reports each copy the compiler can prove, with its source span and the reason. [PERFORMANCE.md section 6](https://git.torb.dev/torbscript/language/src/branch/main/docs/PERFORMANCE.md) also shows a second `= ` line that says how to avoid the copy (take the row out and put it back, `removeAt` ... `insert`). #61 deliberately ships without it. ## Acceptance criteria - [ ] For a copy of a nested write (`a[i][j] = ...` where `a[i]` is shared), the `--explain-copies` note gains the second `= ` line from PERFORMANCE.md section 6 naming the take-out / put-back rewrite with the user's own variable names. - [ ] The hint appears only when the rewrite is valid for the written container type (a list or map owner); other reasons keep the single reason line. - [ ] A test in `compiler/tests/` pins the full text of one note with the hint and one without. - [ ] `docs/tooling/torb-build.md` shows the extended note. ## Dependencies - Blocked by #61 (the flag, the report and the note format). ## Seed impact None: the flag is not used by the compiler's own build (`tools/bootstrap.sh` passes only `build ./compiler --output`), so one commit.
Author
Collaborator

[loop:torbscript] intake: in scope, no duplicate, dependencies closed (#61 / #111), definition of ready met (goal, acceptance criteria, design, no seed impact). Set ready. next: implement

[loop:torbscript] intake: in scope, no duplicate, dependencies closed (#61 / #111), definition of ready met (goal, acceptance criteria, design, no seed impact). Set `ready`. next: implement
Author
Collaborator

[loop:torbscript] claim implement by session:loop-torbscript-20261021 until 2026-10-21T04:00:43Z

[loop:torbscript] claim implement by session:loop-torbscript-20261021 until 2026-10-21T04:00:43Z
Author
Collaborator

[loop:torbscript] implement: PR #394 opened from loop/302-explain-copies-hint (one Conventional Commit, Closes #302). A note for a write into an element of a list a variable holds now gets the second = line with the take-out / put-back rewrite in the program's own names; fields, deeper paths and arrays keep the single reason line. Tests pin one note with and one without the hint; torb-build.md, PERFORMANCE.md section 6 and the generated skills copy show it. Forge CI green on 917f6bd0 (tier A and B, gates, commit messages; the first push failed only format --check, fixed by writing one call as a command). Map owners: the analysis reports no nested map writes today, so there is nothing to hint at. Worker usage: about 0.1M tokens (Sonnet), next: review

[loop:torbscript] implement: PR https://git.torb.dev/torbscript/language/pulls/394 opened from `loop/302-explain-copies-hint` (one Conventional Commit, `Closes #302`). A note for a write into an element of a list a variable holds now gets the second `=` line with the take-out / put-back rewrite in the program's own names; fields, deeper paths and arrays keep the single reason line. Tests pin one note with and one without the hint; torb-build.md, PERFORMANCE.md section 6 and the generated skills copy show it. Forge CI green on 917f6bd0 (tier A and B, gates, commit messages; the first push failed only `format --check`, fixed by writing one call as a command). Map owners: the analysis reports no nested map writes today, so there is nothing to hint at. Worker usage: about 0.1M tokens (Sonnet), next: review
argus closed this issue 2026-10-20 22:32:28 +00:00
Sign in to join this conversation.
No labels
loop
ready
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language#302
No description provided.