`lsc gen` and a failing `lsc check` overwrite the `.dfy.gen` that `lsc regen` merges against
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 58/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
Research direction
Start in tools/src/dafny-commands.ts at dafnyRegen and the code paths for gen, gen-check, and check that write .dfy.gen; trace where .dfy.base is read and deleted. Reproduce with the t.ts example to see regen skip the merge after check. Add a regression test that runs gen or check between the edit and regen, and verify repeated check on unchanged input creates no .dfy.base and a passing check removes it. Done means the reproduction merges and verifies and the acceptance criteria hold.
Written by the indexing model from the issue text.
Description
Problem
lsc regen --backend=dafny three-way merges the new generation into the proof file. Its merge base is .dfy.base if that file exists, and otherwise the previous .dfy.gen (dafnyRegen in tools/src/dafny-commands.ts). lsc gen, lsc gen-check and lsc check also write the new generation to .dfy.gen, but they do not save the previous generation as .dfy.base.
So after editing the .ts, running lsc check (which fails, because the .dfy no longer matches) or lsc gen before lsc regen replaces the merge base with the new generation. regen then finds no change between the base and the new generation, skips the merge, and fails the additions-only check: FAILED: t.dfy has modifications to generated lines. The message blames the proof file, although nobody edited it.
Recovery means restoring the previous .dfy.gen from version control before rerunning regen. Without a committed .dfy.gen, the proof file has to be updated by hand.
Reproduced on upstream main at add6ccd (0.6.10).
Reproduction
// t.ts
export function inc(n: number): number {
//@ requires n >= 0
//@ ensures \result > n
return n + 1;
}
lsc regen --backend=dafny t.ts # Created: t.dfy … 2 verified, 0 errors
perl -pi -e 's/return n \+ 1;/return n + 2;/' t.ts
lsc check --backend=dafny t.ts # exit 1, expected: t.dfy is stale
lsc regen --backend=dafny t.ts
Output of the second regen (excerpt):
WARNING: t.dfy has modifications to generated lines (not additions-only):
- (n + 2)
FAILED: t.dfy has modifications to generated lines.
Replacing the check line with lsc gen --backend=dafny t.ts gives the same failure. Without the intermediate command, the same edit merges and verifies:
Gen changed. Three-way merging...
Merged: t.dfy
Running dafny verify...
Dafny program verifier finished with 2 verified, 0 errors
Expected
Running gen, gen-check or check between a .ts edit and regen does not change what regen merges. One way: when one of those commands writes a .dfy.gen that differs from the previous one, the .dfy already exists, and no .dfy.base exists, it first saves the previous generation as .dfy.base. regen already treats .dfy.base as the merge base for this dirty state, and deletes it after a successful run. check and gen-check would also delete .dfy.base when the .dfy passes the additions-only check against the new generation, so that a base left over from an edit that was later reverted, or from a .dfy updated by hand, does not become the merge base for a later edit.
Acceptance criteria
- The reproduction merges and verifies with
checkin place, and withgenin place. - A regression test runs
genorcheckbetween an edit andregen. - Running
checkrepeatedly on an unchanged.tsdoes not create a.dfy.base. - A
.dfy.basedoes not survive acheckthat passes.
- Dominant language
- TypeScript
- Stars
- 113
- Forks
- 13
- Avg merge
- 15h 35m
- Merged PRs (30d)
- 56
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from midspiral/LemmaScript
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
midspiral/LemmaScript#355 · 1 comment ·
Maintainers usually reply within 1 day
-
In a pure function body, a `const` declared inside an `if` branch stays in scope after the `if`, so a false `ensures` can verifyPossibly taken @namin claimed this today. Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
midspiral/LemmaScript#362 ·
Maintainers usually reply within 1 day
-
A `const` or `let` inside a bare `{ }` block stays in scope after the block, so a false `ensures` can verifyPossibly taken @namin claimed this today. Open
Difficulty 4/5 3-5 days Newbie friendliness 15/100
midspiral/LemmaScript#361 ·
Maintainers usually reply within 1 day
-
A closure declared before a same-name `const` or `let` in its block reads the outer variable, so a false `ensures` can verifyPossibly taken @namin claimed this today. Open
Difficulty 4/5 3-5 days Newbie friendliness 18/100
midspiral/LemmaScript#360 ·
Maintainers usually reply within 1 day
-
An assignment used as an expression, such as `(x = 7);` or `const y = (x = 7)`, is extracted as an equality test, so a false `ensures` can verifyPossibly taken @namin claimed this today. Open
Difficulty 3/5 Half a day Newbie friendliness 30/100
midspiral/LemmaScript#356 · 1 reaction ·
Maintainers usually reply within 1 day
All issues in midspiral/LemmaScript
Similar issues
-
bug done
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
neavo/LinguaGacha#1124 ·
Maintainers usually reply within 1 day
-
[fullsend] E2E: backstage-microsoft-auth — catalogQuery missing error handler for network errorsPossibly taken @fullsend-ai-coder claimed this today. Opene2e-failure ready-to-code
Difficulty 2/5 Under an hour Newbie friendliness 78/100
redhat-developer/rhdh-plugin-export-overlays#4821 · 1 comment ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
brylie/mission-island#225 ·
Maintainers usually reply within 1 day
-
status/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
google-gemini/gemini-cli#30412 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day