Answer architecture round 4: anchor the record's headings to a UTC stamp, import the archive's names from their owner, keep docs/reading-cost.md out of the panel's reading, and order the decision's reasons
This commit is contained in:
@@ -22,6 +22,7 @@ lists the files the last 5 chunks read most. With fewer than 10 figures, it says
|
||||
Exit 1, saying why, on unknown arguments, or when git cannot start or finds no checkout, the
|
||||
archive or the record cannot be read or written, or a figure in the record cannot be read back.
|
||||
"""
|
||||
import dataclasses
|
||||
import os
|
||||
import pathlib
|
||||
import subprocess
|
||||
@@ -31,9 +32,16 @@ import time
|
||||
from reading_cost.measure import Checkout, measure, Reading
|
||||
from failure import Failure
|
||||
from reading_cost.figures import figure, merged, readings_of, RESET, trend, unheld
|
||||
from reading_cost.archive import finished_chunks, project_archive, read_threads, utc
|
||||
from loop_claude.transcript_archive import finished_chunks, utc
|
||||
from reading_cost.archive import project_archive, read_threads
|
||||
from file_writes import replace_file
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Updated:
|
||||
appended: int
|
||||
readings: list[Reading]
|
||||
|
||||
|
||||
def main(argv: list[str]) -> int:
|
||||
reset = argv[:1] == ["--reset"]
|
||||
given = argv[1:] if reset else argv
|
||||
@@ -52,14 +60,12 @@ def main(argv: list[str]) -> int:
|
||||
updated = update(record, archive, checkout, str(home), utc(time.time()) if reset else None)
|
||||
if isinstance(updated, Failure):
|
||||
return failed(updated)
|
||||
appended, readings = updated
|
||||
print(f"Appended {appended} reading-cost figure{'' if appended == 1 else 's'} from {archive}{' and a reset' if reset else ''} to {record}.")
|
||||
print(trend(readings))
|
||||
print(f"Appended {updated.appended} reading-cost figure{'' if updated.appended == 1 else 's'} from {archive}{' and a reset' if reset else ''} to {record}.")
|
||||
print(trend(updated.readings))
|
||||
return 0
|
||||
|
||||
|
||||
def update(record: pathlib.Path, archive: pathlib.Path, checkout: Checkout, home: str, reset_at: str | None) -> tuple[int, list[Reading]] | Failure:
|
||||
"""How many figures it appended, and the readings the trend counts."""
|
||||
def update(record: pathlib.Path, archive: pathlib.Path, checkout: Checkout, home: str, reset_at: str | None) -> Updated | Failure:
|
||||
text = read_record(record)
|
||||
if isinstance(text, Failure):
|
||||
return text
|
||||
@@ -73,7 +79,7 @@ def update(record: pathlib.Path, archive: pathlib.Path, checkout: Checkout, home
|
||||
return readings
|
||||
if marks and (unwritten := write_record(record, text)):
|
||||
return unwritten
|
||||
return len(figures), readings
|
||||
return Updated(len(figures), readings)
|
||||
|
||||
|
||||
def new_figures(record: str, archive: pathlib.Path, checkout: Checkout, home: str) -> list[str] | Failure:
|
||||
|
||||
Reference in New Issue
Block a user