Fix two toolchain defects found by the M checkpoint
A. Interpreter memory grew with the number of executed steps (one arena, never reclaimed): block and call arguments, frames, frame storage, value copies, place paths, channel buffers and per-step scratch now live in a collectable execution heap. Between instructions, past a threshold, the live state is copied into a fresh heap (sharing preserved) and the old one released. Long-lived state (module, world, authority, task, channel and region tables, the result) stays in the caller's arena. The guarded value of a mutex is a separate cell (no interior pointers). Nothing observable changes: fuel, schedule, PRNG, values, traps and run records are the same. - test: five loop shapes x 100k/1M/4M iterations, measured with the interpreter's own heap counters: live state after a collection does not grow with the iteration count; the heap stays under a fixed bound - conformance --collect-every-step: the second run of every run test collects before every instruction; records must be byte-identical (passes, also with --stress 20) B. A void function whose body ends in an if/if-else/match/block/void call lowered to `ret %` (malformed AIR, reported as E0001): it now lowers to `ret`. Seven fall-through tests (six failed before). Also: files_opened counts reads by relative path and file name; P6A-11 (malformed generated AIR as an internal compiler diagnostic) and Q-023 (ref of a whole array as an argument) recorded.
This commit is contained in:
1 parent
4aa9183e78
commit
222c0c884c
15 files changed
+573
-48
No files matched your search
@@ -20,7 +20,9 @@
|
||||
read_tokens_by_group tokens of the group's lines the agent saw
|
||||
coverage_by_section per file: fraction of its distinctive lines
|
||||
(in no other file of the mount) seen
|
||||
files_opened files whose /docs path occurs in a tool input
|
||||
files_opened files named in a tool input: by /docs path, by
|
||||
path relative to /docs, or by file name as a
|
||||
whole token (`cd /docs/language; cat syntax.md`)
|
||||
unique_docs_read how many files were opened
|
||||
|
||||
The gap between them shows where context is amplified: rereading the same
|
||||
@@ -112,6 +114,15 @@ def _doc_files(docs):
|
||||
return sorted(out)
|
||||
|
||||
|
||||
def _named(rel, inputs):
|
||||
"""Whether a tool input names the file: `/docs/<rel>`, `<rel>`, or its
|
||||
file name as a whole token."""
|
||||
for name in {rel, os.path.basename(rel)}:
|
||||
if re.search(r"(?<![\w.-])" + re.escape(name) + r"(?![\w.-])", inputs):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def _group_of(rel, groups):
|
||||
for g, prefixes in groups.items():
|
||||
for pre in prefixes:
|
||||
@@ -145,7 +156,7 @@ def doc_metrics(tool_events, docs, groups, seen, count):
|
||||
for rel, _ in files:
|
||||
mine = own.get(rel, set())
|
||||
coverage[rel] = round(len(mine & seen) / len(mine), 4) if mine else 0.0
|
||||
if "/docs/" + rel in inputs:
|
||||
if _named(rel, inputs):
|
||||
opened.append(rel)
|
||||
g = _group_of(rel, groups)
|
||||
size[g] = size.get(g, 0) + count(texts[rel])
|
||||
|
||||
@@ -275,6 +275,24 @@ class CheckpointTest(unittest.TestCase):
|
||||
self.assertEqual(b["other"], 5) # effects and capabilities are not dropped
|
||||
|
||||
|
||||
class DocsReadTest(unittest.TestCase):
|
||||
def test_files_opened_by_relative_path(self):
|
||||
from ajieval import context
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
os.makedirs(os.path.join(d, "language"))
|
||||
for rel in ("QUICK.md", "language/syntax.md", "language/types.md", "language/memory.md"):
|
||||
with open(os.path.join(d, rel), "w") as f:
|
||||
f.write(f"only in {rel}\n")
|
||||
events = [('{"command": "cat /docs/QUICK.md"}', "only in QUICK.md"),
|
||||
('{"command": "cd /docs/language && cat syntax.md"}', "only in language/syntax.md"),
|
||||
('{"command": "cat language/types.md"}', "only in language/types.md"),
|
||||
('{"command": "cat mysyntax.md types.mdx"}', "")]
|
||||
seen = {o for _, o in events if o}
|
||||
m = context.doc_metrics(events, [("", d)], {}, seen, len)
|
||||
self.assertEqual(m["files_opened"], ["QUICK.md", "language/syntax.md", "language/types.md"])
|
||||
self.assertEqual(m["coverage_by_section"]["language/memory.md"], 0.0)
|
||||
|
||||
|
||||
class CyclesTest(unittest.TestCase):
|
||||
def test_repair_cycles_from_commands(self):
|
||||
from ajieval import native
|
||||
|
||||
Reference in new issue
Block a user