From 3980cb0cd5352e4357b69a124e0a9a1e0cc75b16 Mon Sep 17 00:00:00 2001
From: Mistium <92952823+Mistium@users.noreply.github.com>
Date: Sat, 21 Nov 2026 01:18:32 +0000
Subject: [PATCH 1/5] Add batched commit summaries for commit lists
---
native/gitinspection/changes.go | 97 ++++++++++++++++++++++++++--
native/gitinspection/fractch_test.go | 18 ++++++
native/gitinspection/inspection.go | 2 +
opal.json | 2 +-
scripts/e2e_smoke.py | 3 +
src/git/git-inspection.osl | 61 +++++++++++++++++
src/git/routes.osl | 1 +
7 files changed, 177 insertions(+), 7 deletions(-)
diff --git a/native/gitinspection/changes.go b/native/gitinspection/changes.go
index 80d3d2a..ef7c4ca 100644
--- a/native/gitinspection/changes.go
+++ b/native/gitinspection/changes.go
@@ -216,14 +216,21 @@ func treeFiles(source archive, tree string) (map[string]gitFile, bool) {
return files, true
}
-func changesBetween(baseArchive archive, baseSHA string, baseCommit gitCommit, headArchive archive, headSHA string, headCommit gitCommit) string {
+type commitChanges struct {
+ legacy bool
+ targets []fractchTargetChanges
+ others []map[string]any
+ totals changeTotals
+}
+
+func computeChanges(baseArchive archive, baseCommit gitCommit, headArchive archive, headCommit gitCommit, inline bool) (commitChanges, string) {
parentFiles, ok := treeFiles(baseArchive, baseCommit.Tree)
if !ok {
- return failure("parent commit tree is invalid")
+ return commitChanges{}, "parent commit tree is invalid"
}
currentFiles, ok := treeFiles(headArchive, headCommit.Tree)
if !ok || headCommit.Tree == "" {
- return failure("commit tree is invalid")
+ return commitChanges{}, "commit tree is invalid"
}
changes := []map[string]any{}
legacy := false
@@ -247,13 +254,91 @@ func changesBetween(baseArchive archive, baseSHA string, baseCommit gitCommit, h
}
sortChanges(changes)
targets, others, totals := structuredChanges(changes, baseArchive, parentFiles, headArchive, currentFiles)
- inlineDiffContent(others, baseArchive, parentFiles, headArchive, currentFiles)
+ if inline {
+ inlineDiffContent(others, baseArchive, parentFiles, headArchive, currentFiles)
+ }
+ return commitChanges{legacy: legacy, targets: targets, others: others, totals: totals}, ""
+}
+
+func changesBetween(baseArchive archive, baseSHA string, baseCommit gitCommit, headArchive archive, headSHA string, headCommit gitCommit) string {
+ computed, problem := computeChanges(baseArchive, baseCommit, headArchive, headCommit, true)
+ if problem != "" {
+ return failure(problem)
+ }
return encode(map[string]any{
- "ok": true, "sha": headSHA, "parent": baseSHA, "commit": headCommit, "legacy": legacy,
- "targets": targets, "files": others, "totals": totals,
+ "ok": true, "sha": headSHA, "parent": baseSHA, "commit": headCommit, "legacy": computed.legacy,
+ "targets": computed.targets, "files": computed.others, "totals": computed.totals,
}, "could not encode commit changes")
}
+const maxSummarySprites = 5
+
+func summarizeComputed(computed commitChanges) map[string]any {
+ assetDirs := map[string]bool{}
+ for _, file := range computed.others {
+ path, _ := file["path"].(string)
+ if isAssetPath(path) {
+ assetDirs[spriteDir(path)] = true
+ }
+ }
+ sprites := []string{}
+ count := 0
+ for _, target := range computed.targets {
+ if len(target.Scripts) == 0 && len(target.Items) == 0 && !target.TooLarge && !assetDirs[target.Path] {
+ continue
+ }
+ delete(assetDirs, target.Path)
+ count++
+ if len(sprites) < maxSummarySprites {
+ sprites = append(sprites, summaryName(target.Path, target.Name))
+ }
+ }
+ remaining := make([]string, 0, len(assetDirs))
+ for dir := range assetDirs {
+ remaining = append(remaining, dir)
+ }
+ sort.Strings(remaining)
+ for _, dir := range remaining {
+ count++
+ if len(sprites) < maxSummarySprites {
+ sprites = append(sprites, summaryName(dir, ""))
+ }
+ }
+ return map[string]any{"legacy": computed.legacy, "totals": computed.totals, "sprites": sprites, "spriteCount": count}
+}
+
+func summaryName(dir, name string) string {
+ if dir == "Stage" {
+ return "Stage"
+ }
+ if name != "" {
+ return name
+ }
+ return dir
+}
+
+func (a archive) inspectCommitSummary(sha string, commit gitCommit) string {
+ base := archive{objects: map[string]*zip.File{}}
+ parentCommit := gitCommit{}
+ initial := len(commit.Parents) == 0
+ if !initial {
+ parsed, ok := a.parseCommit(commit.Parents[0])
+ if !ok {
+ return failure("parent commit is unavailable")
+ }
+ base, parentCommit = a, parsed
+ }
+ computed, problem := computeChanges(base, parentCommit, a, commit, false)
+ if problem != "" {
+ return failure(problem)
+ }
+ summary := summarizeComputed(computed)
+ summary["ok"] = true
+ summary["sha"] = sha
+ summary["initial"] = initial
+ return encode(summary, "could not encode commit summary")
+}
+
func (a archive) inspectCommitChanges(sha string, commit gitCommit) string {
if len(commit.Parents) == 0 {
return changesBetween(archive{objects: map[string]*zip.File{}}, "", gitCommit{}, a, sha, commit)
diff --git a/native/gitinspection/fractch_test.go b/native/gitinspection/fractch_test.go
index 33f2feb..4a50af3 100644
--- a/native/gitinspection/fractch_test.go
+++ b/native/gitinspection/fractch_test.go
@@ -298,6 +298,24 @@ func TestInspectChangesSummarisesCommit(t *testing.T) {
}
}
+ summary := decodeResult(t, Inspect(path, second, "summary", "", second))
+ if summary["ok"] != true || summary["initial"] != false || summary["spriteCount"] != float64(2) {
+ t.Fatalf("unexpected summary: %v", summary)
+ }
+ if names := summary["sprites"].([]any); len(names) != 2 || names[0] != "Cat" || names[1] != "Stage" {
+ t.Fatalf("unexpected summary sprites: %v", names)
+ }
+ if summary["totals"].(map[string]any)["scripts"].(map[string]any)["changed"] != float64(1) {
+ t.Fatalf("summary totals differ from the changes view: %v", summary["totals"])
+ }
+ if _, inlined := summary["files"]; inlined {
+ t.Fatalf("a summary should not carry file contents: %v", summary)
+ }
+ firstSummary := decodeResult(t, Inspect(path, first, "summary", "", second))
+ if firstSummary["initial"] != true {
+ t.Fatalf("the first commit should be marked initial: %v", firstSummary)
+ }
+
initial := decodeResult(t, Inspect(path, first, "changes", "", second))
initialTotals := initial["totals"].(map[string]any)
if initialTotals["scripts"].(map[string]any)["added"] != float64(3) || initialTotals["stateOnly"] != false {
diff --git a/native/gitinspection/inspection.go b/native/gitinspection/inspection.go
index e4e08d4..649765b 100644
--- a/native/gitinspection/inspection.go
+++ b/native/gitinspection/inspection.go
@@ -349,6 +349,8 @@ func Inspect(workspacePath, sha, operation, requestedPath, allowedHeads string)
return archive.inspectCommit(sha, commit, true)
case "changes":
return archive.inspectCommitChanges(sha, commit)
+ case "summary":
+ return archive.inspectCommitSummary(sha, commit)
default:
return archive.inspectCommit(sha, commit, false)
}
diff --git a/opal.json b/opal.json
index a1a0de4..7da1afe 100644
--- a/opal.json
+++ b/opal.json
@@ -1,6 +1,6 @@
{
"name": "mistwarp-api",
- "version": "1.2.0",
+ "version": "1.3.0",
"main": "main.osl",
"scripts": {
"dev": ["osl", "run", "main.osl"],
diff --git a/scripts/e2e_smoke.py b/scripts/e2e_smoke.py
index b8ddfaa..f110cfe 100644
--- a/scripts/e2e_smoke.py
+++ b/scripts/e2e_smoke.py
@@ -644,6 +644,9 @@ def head_and_edited():
step("commit changes", "GET", path + "/commits/" + head + "/changes", "sam")
step("commit changes signed out", "GET", path + "/commits/" + head + "/changes")
step("changes of unknown commit", "GET", path + "/commits/" + "1" * 40 + "/changes", "sam")
+ step("commit summaries", "GET", path + "/commit-summaries?shas=" + head + ",nothex," + "1" * 40 + "," + head, "sam")
+ step("commit summaries signed out", "GET", path + "/commit-summaries?shas=" + head)
+ step("commit summaries without shas", "GET", path + "/commit-summaries", "sam")
step("rename branch", "PATCH", path + "/branches", "sam", {"branch": "feature", "name": "feature-two"})
step("rename branch as stranger", "PATCH", path + "/branches", "bob", {"branch": "feature-two", "name": "x"})
step("delete branch", "DELETE", path + "/branches", "sam", {"branch": "feature-two"})
diff --git a/src/git/git-inspection.osl b/src/git/git-inspection.osl
index b1274a4..4667dd8 100644
--- a/src/git/git-inspection.osl
+++ b/src/git/git-inspection.osl
@@ -285,3 +285,64 @@ def handleGetCommitFile(*serve.Context c) (
)
gitInspectionResponse(c, res.project.assert(object), c.param("sha"), "file", (c.query("path") ?? ""))
)
+
+def commitSummaryLimit() number (
+ return 50
+)
+
+def requestedCommitShas(string raw) array (
+ array shas = []
+ object seen = {}
+ for entry in raw.split(",") (
+ string sha = entry.toStr().trim()
+ if validGitObjectId(sha) and !seen.contains(sha) and shas.len < commitSummaryLimit() (
+ seen[sha] = true
+ shas.append(sha)
+ )
+ )
+ return shas
+)
+
+def handleGetCommitSummaries(*serve.Context c) (
+ c.setHeader("Cache-Control", "private, no-store")
+ c.setHeader("CDN-Cache-Control", "private, no-store")
+ auto res = loadProject(c.param("id"))
+ if !res.ok (
+ c.notFound("project not found")
+ return
+ )
+ object project = res.project.assert(object)
+ if !canSeeInsideProject(project, c) (
+ c.notFound("project not found")
+ return
+ )
+ array shas = requestedCommitShas((c.query("shas") ?? ""))
+ object summaries = {}
+ if shas.len == 0 (
+ c.json(200, {ok: true, summaries: summaries})
+ return
+ )
+ string allowedHeads = projectGitAllowedHeadsString(project)
+ if allowedHeads == "" (
+ c.json(200, {ok: true, summaries: summaries})
+ return
+ )
+ string workspacePath = cachedProjectWorkspacePath(project)
+ if workspacePath == "" (
+ c.notFound("workspace not found")
+ return
+ )
+ for i shas.len (
+ string sha = shas[i].toStr()
+ if projectRecordsCommit(project, sha) (
+ auto parsed = json.parse(cachedWorkspaceGitInspectionJSON(project, workspacePath, sha, "summary", "", allowedHeads), {type: "object"})
+ if !parsed.isErr() (
+ object summary = parsed.unwrap().assert(object)
+ if summary.contains("ok") and summary.ok == true (
+ summaries[sha] = summary
+ )
+ )
+ )
+ )
+ c.json(200, {ok: true, summaries: summaries})
+)
diff --git a/src/git/routes.osl b/src/git/routes.osl
index 5f727c6..06c4d40 100644
--- a/src/git/routes.osl
+++ b/src/git/routes.osl
@@ -5,6 +5,7 @@ export {
def registerGitRoutes(*serve.Router api) (
api.GET("/projects/:id/commits", handleGetCommits)
+ api.GET("/projects/:id/commit-summaries", handleGetCommitSummaries)
api.GET("/projects/:id/branches", handleListProjectBranches)
api.POST("/projects/:id/branches", requireAuth, handleCreateProjectBranch)
api.PATCH("/projects/:id/branches", requireAuth, handleRenameProjectBranch)
From 9a6829f255bdbb3c4db17363781d824bca98816f Mon Sep 17 00:00:00 2001
From: Mistium <92952823+Mistium@users.noreply.github.com>
Date: Sat, 21 Nov 2026 01:22:08 +0000
Subject: [PATCH 2/5] Count authored files and oversized sprites in commit
summaries
---
native/gitinspection/changes.go | 10 +++++++++-
native/gitinspection/fractch_test.go | 3 +++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/native/gitinspection/changes.go b/native/gitinspection/changes.go
index ef7c4ca..0a444c9 100644
--- a/native/gitinspection/changes.go
+++ b/native/gitinspection/changes.go
@@ -275,15 +275,20 @@ const maxSummarySprites = 5
func summarizeComputed(computed commitChanges) map[string]any {
assetDirs := map[string]bool{}
+ files := 0
for _, file := range computed.others {
path, _ := file["path"].(string)
if isAssetPath(path) {
assetDirs[spriteDir(path)] = true
+ } else if path != "fractch.json" {
+ files++
}
}
sprites := []string{}
count := 0
+ tooLarge := false
for _, target := range computed.targets {
+ tooLarge = tooLarge || target.TooLarge
if len(target.Scripts) == 0 && len(target.Items) == 0 && !target.TooLarge && !assetDirs[target.Path] {
continue
}
@@ -304,7 +309,10 @@ func summarizeComputed(computed commitChanges) map[string]any {
sprites = append(sprites, summaryName(dir, ""))
}
}
- return map[string]any{"legacy": computed.legacy, "totals": computed.totals, "sprites": sprites, "spriteCount": count}
+ return map[string]any{
+ "legacy": computed.legacy, "totals": computed.totals, "sprites": sprites, "spriteCount": count,
+ "authoredFiles": files, "tooLarge": tooLarge,
+ }
}
func summaryName(dir, name string) string {
diff --git a/native/gitinspection/fractch_test.go b/native/gitinspection/fractch_test.go
index 4a50af3..15382c0 100644
--- a/native/gitinspection/fractch_test.go
+++ b/native/gitinspection/fractch_test.go
@@ -308,6 +308,9 @@ func TestInspectChangesSummarisesCommit(t *testing.T) {
if summary["totals"].(map[string]any)["scripts"].(map[string]any)["changed"] != float64(1) {
t.Fatalf("summary totals differ from the changes view: %v", summary["totals"])
}
+ if summary["authoredFiles"] != float64(1) || summary["tooLarge"] != false {
+ t.Fatalf("summary should count the readme and nothing else: %v", summary)
+ }
if _, inlined := summary["files"]; inlined {
t.Fatalf("a summary should not carry file contents: %v", summary)
}
From 65e12b2a6d989e743d8f5aff2fa659a60887021b Mon Sep 17 00:00:00 2001
From: Mistium <92952823+Mistium@users.noreply.github.com>
Date: Sat, 21 Nov 2026 01:35:16 +0000
Subject: [PATCH 3/5] Keep commit summaries in one cache file per project
---
scripts/e2e_smoke.py | 1 +
src/git/git-inspection.osl | 77 +++++++++++++++++++++++++++++++++-----
2 files changed, 69 insertions(+), 9 deletions(-)
diff --git a/scripts/e2e_smoke.py b/scripts/e2e_smoke.py
index f110cfe..2c100b9 100644
--- a/scripts/e2e_smoke.py
+++ b/scripts/e2e_smoke.py
@@ -646,6 +646,7 @@ def head_and_edited():
step("changes of unknown commit", "GET", path + "/commits/" + "1" * 40 + "/changes", "sam")
step("commit summaries", "GET", path + "/commit-summaries?shas=" + head + ",nothex," + "1" * 40 + "," + head, "sam")
step("commit summaries signed out", "GET", path + "/commit-summaries?shas=" + head)
+ step("commit summaries from cache", "GET", path + "/commit-summaries?shas=" + head, "sam")
step("commit summaries without shas", "GET", path + "/commit-summaries", "sam")
step("rename branch", "PATCH", path + "/branches", "sam", {"branch": "feature", "name": "feature-two"})
step("rename branch as stranger", "PATCH", path + "/branches", "bob", {"branch": "feature-two", "name": "x"})
diff --git a/src/git/git-inspection.osl b/src/git/git-inspection.osl
index 4667dd8..3f54185 100644
--- a/src/git/git-inspection.osl
+++ b/src/git/git-inspection.osl
@@ -303,6 +303,46 @@ def requestedCommitShas(string raw) array (
return shas
)
+def commitSummaryCacheDir() string (
+ return tmpDir ++ "git-summaries/"
+)
+
+def commitSummaryCacheName(object project) string (
+ return gitInspectionCacheVersion() ++ "." ++ project.id.toStr().hashSHA256() ++ ".json"
+)
+
+def readCommitSummaryCache(string cachePath) object (
+ if !fs.exists(cachePath) or fs.size(cachePath).unwrapOr(0) > 8388608 (
+ return {}
+ )
+ auto parsed = json.parse(fs.readFile(cachePath).unwrapOr(""), {type: "object"})
+ if parsed.isErr() (
+ return {}
+ )
+ return parsed.unwrap().assert(object)
+)
+
+def computeCommitSummary(string workspacePath, string sha, string allowedHeads) object (
+ auto parsed = json.parse(gitinspection.Inspect(workspacePath, sha, "summary", "", allowedHeads), {type: "object"})
+ if parsed.isErr() (
+ return {}
+ )
+ object summary = parsed.unwrap().assert(object)
+ if !summary.contains("ok") or summary.ok != true (
+ return {}
+ )
+ return summary
+)
+
+def writeCommitSummaryCache(string cachePath, object cached) (
+ string temporaryPath = cachePath ++ ".tmp." ++ randomString(8)
+ if fs.writeFile(temporaryPath, json.stringify(cached)) (
+ if !fs.rename(temporaryPath, cachePath) (
+ void fs.remove(temporaryPath)
+ )
+ )
+)
+
def handleGetCommitSummaries(*serve.Context c) (
c.setHeader("Cache-Control", "private, no-store")
c.setHeader("CDN-Cache-Control", "private, no-store")
@@ -327,22 +367,41 @@ def handleGetCommitSummaries(*serve.Context c) (
c.json(200, {ok: true, summaries: summaries})
return
)
- string workspacePath = cachedProjectWorkspacePath(project)
- if workspacePath == "" (
- c.notFound("workspace not found")
- return
- )
+ string cacheDir = commitSummaryCacheDir()
+ void fs.mkdir(cacheDir, {recursive: true})
+ string cacheName = commitSummaryCacheName(project)
+ string cachePath = cacheDir ++ cacheName
+ string lockName = "git-summaries-" ++ cacheName
+ sync.lock(lockName)
+ defer sync.unlock(lockName)
+ object cached = readCommitSummaryCache(cachePath)
+ boolean changed = false
+ string workspacePath = ""
for i shas.len (
string sha = shas[i].toStr()
if projectRecordsCommit(project, sha) (
- auto parsed = json.parse(cachedWorkspaceGitInspectionJSON(project, workspacePath, sha, "summary", "", allowedHeads), {type: "object"})
- if !parsed.isErr() (
- object summary = parsed.unwrap().assert(object)
- if summary.contains("ok") and summary.ok == true (
+ if cached.contains(sha) and cached[sha] != null (
+ summaries[sha] = cached[sha]
+ ) else (
+ if workspacePath == "" (
+ workspacePath = cachedProjectWorkspacePath(project)
+ if workspacePath == "" (
+ c.notFound("workspace not found")
+ return
+ )
+ )
+ object summary = computeCommitSummary(workspacePath, sha, allowedHeads)
+ if summary.contains("ok") (
summaries[sha] = summary
+ cached[sha] = summary
+ changed = true
)
)
)
)
+ if changed (
+ writeCommitSummaryCache(cachePath, cached)
+ pruneGitInspectionCache(cacheDir, cacheName)
+ )
c.json(200, {ok: true, summaries: summaries})
)
From 9757fef0bc6f9f65f11e67203f5efa1b759c6979 Mon Sep 17 00:00:00 2001
From: Mistium <92952823+Mistium@users.noreply.github.com>
Date: Sat, 21 Nov 2026 01:44:54 +0000
Subject: [PATCH 4/5] Compute summaries outside the cache lock and skip
non-sprite folders
---
native/gitinspection/changes.go | 25 +++++++--
native/gitinspection/fractch_test.go | 55 ++++++++++++++++++
scripts/e2e_smoke.py | 4 ++
src/git/commit-summary-cache.osl | 51 +++++++++++++++++
src/git/commit-summary-cache.test.osl | 34 ++++++++++++
src/git/git-inspection.osl | 80 +++++++++++----------------
6 files changed, 196 insertions(+), 53 deletions(-)
create mode 100644 src/git/commit-summary-cache.osl
create mode 100644 src/git/commit-summary-cache.test.osl
diff --git a/native/gitinspection/changes.go b/native/gitinspection/changes.go
index 0a444c9..81eeed7 100644
--- a/native/gitinspection/changes.go
+++ b/native/gitinspection/changes.go
@@ -217,10 +217,21 @@ func treeFiles(source archive, tree string) (map[string]gitFile, bool) {
}
type commitChanges struct {
- legacy bool
- targets []fractchTargetChanges
- others []map[string]any
- totals changeTotals
+ legacy bool
+ targets []fractchTargetChanges
+ others []map[string]any
+ totals changeTotals
+ spriteDirs map[string]bool
+}
+
+func spriteDirsOf(trees ...map[string]gitFile) map[string]bool {
+ dirs := map[string]bool{}
+ for _, files := range trees {
+ for dir := range fractchFilesByDir(files) {
+ dirs[dir] = true
+ }
+ }
+ return dirs
}
func computeChanges(baseArchive archive, baseCommit gitCommit, headArchive archive, headCommit gitCommit, inline bool) (commitChanges, string) {
@@ -257,7 +268,7 @@ func computeChanges(baseArchive archive, baseCommit gitCommit, headArchive archi
if inline {
inlineDiffContent(others, baseArchive, parentFiles, headArchive, currentFiles)
}
- return commitChanges{legacy: legacy, targets: targets, others: others, totals: totals}, ""
+ return commitChanges{legacy: legacy, targets: targets, others: others, totals: totals, spriteDirs: spriteDirsOf(parentFiles, currentFiles)}, ""
}
func changesBetween(baseArchive archive, baseSHA string, baseCommit gitCommit, headArchive archive, headSHA string, headCommit gitCommit) string {
@@ -279,7 +290,9 @@ func summarizeComputed(computed commitChanges) map[string]any {
for _, file := range computed.others {
path, _ := file["path"].(string)
if isAssetPath(path) {
- assetDirs[spriteDir(path)] = true
+ if dir := spriteDir(path); dir != "" && computed.spriteDirs[dir] {
+ assetDirs[dir] = true
+ }
} else if path != "fractch.json" {
files++
}
diff --git a/native/gitinspection/fractch_test.go b/native/gitinspection/fractch_test.go
index 15382c0..b268ad4 100644
--- a/native/gitinspection/fractch_test.go
+++ b/native/gitinspection/fractch_test.go
@@ -2,6 +2,7 @@ package gitinspection
import (
"encoding/hex"
+ "encoding/json"
"sort"
"strings"
"testing"
@@ -340,6 +341,60 @@ func TestInspectChangesStateOnlyCommitIsNotCode(t *testing.T) {
}
}
+func TestInspectSummaryNamesOnlySpriteFolders(t *testing.T) {
+ repo := newTestRepository()
+ code := repo.object("blob", []byte(fractchBase))
+ firstTree := repo.nestedTree(map[string]string{
+ "Cat/main.fractch": code,
+ "Cat/assets/a.svg": repo.object("blob", []byte("")),
+ "fonts/Brand.ttf": repo.object("blob", []byte("font one")),
+ "assets/loose.png": repo.object("blob", []byte("png one")),
+ "Stage/stage.fractch": repo.object("blob", []byte("stage \"Stage\";\n")),
+ })
+ first := repo.commit(firstTree, "", "Initial version")
+ secondTree := repo.nestedTree(map[string]string{
+ "Cat/main.fractch": code,
+ "Cat/assets/a.svg": repo.object("blob", []byte("