session export: write only session.html, retire the markdown export

A stage's session was exported twice, as session.md and session.html, and both
files were presented. It is now one html file; the markdown export is retired.

- internal/stage/session_export.go: ExportSession renders and writes exactly one
  file, session.html, via writeSessionFile; renderSessionMarkdown and its helpers
  are gone; SessionExportResult carries HTML/HTMLBytes only. The source read, the
  8 MiB source / 2 MiB rendered bounds, the truncation banner, the
  never-overwrite rule and the honest empty-session handling are unchanged.
- internal/protocol/runs.go: SessionExport drops markdown/markdown_bytes (a
  record written before the change still decodes; unknown fields are ignored),
  and adds LegacySessionMarkdownArtifact with RunStep.PresentedArtifacts(), the
  one Go rule that hides the retired session.md from every artifact listing.
- internal/server/runner.go: evidence.Markdown/MarkdownBytes are no longer copied.
- internal/tui: the artifacts panel, the recorded count and the per-visit summary
  derive from PresentedArtifacts(), so the terminal never lists session.md.
- web/src/app.js: the spike's renderArtifacts applies the same filter.
- android: the Session section is the html export alone in a WebView — SessionView,
  the Markdown/HTML toggle and the session markdown path are removed;
  presentedArtifacts(step) filters the retired session.md out of the per-visit
  gallery, the run gallery and its count, the verdict/selection lists and the
  timeline indicator; data/protocol SessionExport drops the markdown fields.
- Tests pin the single html file, prove no session.md is written and that a
  pre-existing one is neither overwritten nor presented, and prove a legacy
  export record still loads and its session.md is hidden.

The legacy session.md of an older run stays on disk (dated evidence); it is only
no longer produced and no longer presented.

Checks (macOS, Go 1.24, Android Gradle 8.11.1, 18 Oct 2026): gofmt -l . prints
nothing; go build ./... && go vet ./... clean; go test ./internal/... ./cmd/...
-> 19 packages ok, 0 failures; node --check web/src/app.js ok and node --test
web/test -> 20/20; gradle --offline --no-daemon :app:assembleDebug
:app:testDebugUnitTest -> BUILD SUCCESSFUL.

Packaged references checked: internal/author/skill/references/delivery.md and
operations.md both described the session.md+session.html pair, so both are
updated here to describe the single session.html export and the retired, hidden
session.md. README.md and internal/author/skill/SKILL.md carry no session.md
reference and install.go's managed inventory is unchanged (no reference added or
removed). docs/notes/session-html-only.md records the remaining stale shared
documentation (docs/stage-artifacts.md, docs/app-integration-verification.md) for
the docs-fold writer; shared docs are not edited by this item.
This commit is contained in:
2026-10-18 10:06:49 +01:00
parent 5a4cfc2e9c
commit 95362134aa
25 changed files with 666 additions and 571 deletions
+45 -13
View File
@@ -101,20 +101,20 @@ type SessionEvidence struct {
}
// SessionExport is the recorded evidence of one stage's session file export:
// the file names written under the step's artifacts directory, their byte sizes,
// the decoded message count, the source, whether the export was truncated and a
// sanitized diagnostic. It is observed server-side evidence, not a model claim.
// the html file name written under the step's artifacts directory, its byte
// size, the decoded message count, the source, whether the export was truncated
// and a sanitized diagnostic. It is observed server-side evidence, not a model
// claim. A record written before the HTML-only change also carried markdown and
// markdown_bytes; readers ignore those fields.
type SessionExport struct {
SessionID string `json:"session_id,omitempty"`
Backend string `json:"backend,omitempty"`
Source string `json:"source,omitempty"`
Markdown string `json:"markdown,omitempty"`
HTML string `json:"html,omitempty"`
MarkdownBytes int64 `json:"markdown_bytes,omitempty"`
HTMLBytes int64 `json:"html_bytes,omitempty"`
Messages int `json:"messages"`
Truncated bool `json:"truncated,omitempty"`
Diagnostic string `json:"diagnostic,omitempty"`
SessionID string `json:"session_id,omitempty"`
Backend string `json:"backend,omitempty"`
Source string `json:"source,omitempty"`
HTML string `json:"html,omitempty"`
HTMLBytes int64 `json:"html_bytes,omitempty"`
Messages int `json:"messages"`
Truncated bool `json:"truncated,omitempty"`
Diagnostic string `json:"diagnostic,omitempty"`
}
type RunSummary struct {
@@ -197,6 +197,38 @@ type StageArtifact struct {
URL string `json:"url"`
}
// LegacySessionMarkdownArtifact is the retired markdown session export file name.
// Nothing writes it any more, but a run recorded before the HTML-only change
// still lists session.md among its stored artifacts: it is dated evidence that is
// never presented, so every listing hides it rather than showing it beside the
// session html. This is the one definition of the retired name, shared by the
// stage export and the clients.
const LegacySessionMarkdownArtifact = "session.md"
// PresentedArtifacts is one step's recorded artifacts as they are presented: the
// files with the retired markdown session export filtered out. It is the single
// rule every Go artifact listing derives from, so a stage's artifacts never show
// a session markdown beside the session html and a recorded count can never
// disagree with the tiles. It never mutates the step and returns nil when nothing
// is presented; the stored record still carries the legacy file. Pure,
// O(artifacts) per step.
func (s RunStep) PresentedArtifacts() []StageArtifact {
if len(s.Artifacts) == 0 {
return nil
}
presented := make([]StageArtifact, 0, len(s.Artifacts))
for _, artifact := range s.Artifacts {
if artifact.Name == LegacySessionMarkdownArtifact {
continue
}
presented = append(presented, artifact)
}
if len(presented) == 0 {
return nil
}
return presented
}
// StageUsage is the usage one model stage actually reported, carried from the
// stage's already-measured budget accounting rather than a second measurement or
// a transcript parse. TokensTotal/TokensKnown are the reported total; TokensIn
+22
View File
@@ -51,3 +51,25 @@ func TestRunStepOmitsAbsentArtifacts(t *testing.T) {
t.Fatalf("absent field must decode empty: %+v", decoded)
}
}
func TestPresentedArtifactsHidesRetiredSessionMarkdown(t *testing.T) {
step := RunStep{Artifacts: []StageArtifact{
{Name: "session.md", URL: "/artifacts/344/1/session.md"},
{Name: "session.html", URL: "/artifacts/344/1/session.html"},
{Name: "shot.png", URL: "/artifacts/344/1/shot.png"},
}}
presented := step.PresentedArtifacts()
if len(presented) != 2 || presented[0].Name != "session.html" || presented[1].Name != "shot.png" {
t.Fatalf("presented = %+v", presented)
}
if len(step.Artifacts) != 3 {
t.Fatalf("PresentedArtifacts mutated the stored record: %+v", step.Artifacts)
}
if got := (RunStep{}).PresentedArtifacts(); got != nil {
t.Fatalf("empty step presented %+v, want nil", got)
}
onlyLegacy := RunStep{Artifacts: []StageArtifact{{Name: LegacySessionMarkdownArtifact}}}
if got := onlyLegacy.PresentedArtifacts(); got != nil {
t.Fatalf("legacy-only step presented %+v, want nil", got)
}
}