diff --git a/dashboard/src/shale.rs b/dashboard/src/shale.rs index 9235fc27380c23a4ea4f9b240083dd3f3ff99bfa..d227dc7cafad2e1d8ca8d76c425ff36243f63153 100644 --- a/dashboard/src/shale.rs +++ b/dashboard/src/shale.rs @@ -12,19 +12,6 @@ use scraper::{Html, Selector}; const MODEL_PATTERN: &str = r"^[a-z0-9][a-z0-9._-]{0,127}$"; -fn tokenless_r1616(document: &Html) -> bool { - if document - .select(&Selector::parse("input[name=csrf_token]").unwrap()) - .next() - .is_some() - { - return false; - } - let links: Vec<_> = document.select(&Selector::parse("body#page-issue > footer.usa-footer .usa-footer__secondary-section a[href='https://astheno.software/shale/']").unwrap()).collect(); - matches!(links.as_slice(), [link] if text(*link) == "shale r1616-ga87d2f5.zig.0.16.0") -} - - pub struct Backend { pub(crate) origin: url::Url, http: reqwest::Client, @@ -57,15 +44,14 @@ impl Backend { path: &str, session: Option<&str>, ) -> Result<(StatusCode, HeaderMap, String)> { - self.request(Method::GET, self.origin.join(path)?, session, None) + self.request(self.origin.join(path)?, session, "text/html") .await } async fn request( &self, - method: Method, target: url::Url, session: Option<&str>, - form: Option<&HashMap>, + accept: &str, ) -> Result<(StatusCode, HeaderMap, String)> { if target.origin() != self.origin.origin() || !target.username().is_empty() @@ -77,18 +63,12 @@ impl Backend { let _slot = tokio::time::timeout(Duration::from_secs(5), self.slots.acquire()) .await .map_err(|_| Error::new(429, "Shale is busy. Try again in a moment."))??; - let mut request = self.http.request(method, target.clone()); + let mut request = self.http.get(target.clone()).header("accept", accept); if let Some(session) = session { let mut cookie = axum::http::HeaderValue::from_str(&format!("SessionID={session}"))?; cookie.set_sensitive(true); request = request.header("cookie", cookie); } - if let Some(form) = form { - request = request - .header("origin", self.origin.origin().ascii_serialization()) - .header("referer", target.as_str()) - .form(form); - } let mut response = request .send() .await @@ -112,9 +92,9 @@ impl Backend { } Ok((status, headers, String::from_utf8(body)?)) } - async fn page(&self, target: &url::Url, session: &str) -> Result { + async fn page(&self, target: &url::Url, session: &str, accept: &str) -> Result { let (status, _, body) = self - .request(Method::GET, target.clone(), Some(session), None) + .request(target.clone(), Some(session), accept) .await?; match status { StatusCode::OK => Ok(body), @@ -135,30 +115,13 @@ impl Backend { )), } } -} - -fn document(html: &str, page: &str, repository: Option<&str>) -> Result { - let document = Html::parse_document(html); - if document - .select(&Selector::parse("body").unwrap()) - .next() - .and_then(|body| body.attr("id")) - != Some(page) - || repository.is_some_and(|name| { - document - .select(&Selector::parse("meta[name='astheno.shale.repo.name']").unwrap()) - .next() - .and_then(|meta| meta.attr("content")) - != Some(name) - }) - { - return Err(Error::new( - 502, - "Shale's page changed. Open it to check the result.", - )); + async fn json(&self, target: &url::Url, session: &str) -> Result { + let body = self.page(target, session, "application/json").await?; + serde_json::from_str(&body) + .map_err(|_| Error::new(502, "Shale didn't return JSON. Open it to check the result.")) } - Ok(document) } + fn text(element: scraper::ElementRef<'_>) -> String { element.text().collect::().trim().to_owned() } @@ -206,137 +169,52 @@ pub(crate) async fn verified_session(app: &App, owner: &str) -> Result { let session = session(app, owner)?; username( &app.shale - .page(&app.shale.origin.join("/-/settings")?, &session) + .page(&app.shale.origin.join("/-/settings")?, &session, "text/html") .await?, )?; Ok(session) } pub async fn repositories(app: &App, owner: &str) -> Result> { let session = verified_session(app, owner).await?; - let body = app.shale.page(&app.shale.origin, &session).await?; - let document = document(&body, "page-index", None)?; + let value = app.shale.json(&app.shale.origin, &session).await?; + let entries = value.as_array().filter(|v| v.len() <= 1024) + .ok_or_else(|| Error::new(502, "Shale's repository list changed. Open Shale to browse it."))?; let mut repositories = Vec::new(); - for row in document.select(&Selector::parse(".grid-container table tbody tr").unwrap()) { - let cells: Vec<_> = row.select(&Selector::parse("td").unwrap()).collect(); - if cells.len() != 3 { - return Err(Error::new( - 502, - "Shale's repository list changed. Open Shale to browse it.", - )); + for entry in entries { + let name = entry["name"].as_str() + .ok_or_else(|| Error::new(502, "Shale's repository list changed. Open Shale to browse it."))?; + repository_path(&app.shale.origin, name, &[""])?; + if repositories.iter().any(|r: &Value| r["id"] == name) { + return Err(Error::new(502, "Shale's repository list changed. Open Shale to browse it.")); } - let link = cells[0] - .select(&Selector::parse("a").unwrap()) - .next() - .ok_or_else(|| { - Error::new( - 502, - "Shale's repository list changed. Open Shale to browse it.", - ) - })?; - let name = text(link); - let target = app - .shale - .origin - .join(link.attr("href").unwrap_or_default())?; - if target != repository_path(&app.shale.origin, &name, &[""])? - || repositories.iter().any(|r: &Value| r["id"] == name) - { - return Err(Error::new( - 502, - "Shale's repository list changed. Open Shale to browse it.", - )); - } - repositories.push(json!({"id":name,"name":name,"description":text(cells[1])})); - } - if repositories.len() > 1024 { - return Err(Error::new( - 502, - "The repository list is too large. Open Shale to narrow it.", - )); + repositories.push(json!({"id":name,"name":name,"description":entry["description"]})); } Ok(repositories) } -fn issue(html: &str, repository: &str, id: Option) -> Result { - let document = document(html, "page-issue", Some(repository))?; - let spans: Vec<_> = document - .select(&Selector::parse("h1 > span").unwrap()) - .collect(); - let (issue_id, title) = if spans.len() == 2 { - ( - text(spans[0]) - .strip_prefix('#') - .and_then(|id| id.parse::().ok()), - Some(text(spans[1])), - ) - } else if spans.is_empty() && tokenless_r1616(&document) { - let headings: Vec<_> = document.select(&Selector::parse("h1").unwrap()).collect(); - if let [heading] = headings.as_slice() { - text(*heading) - .strip_prefix("Issue #") - .and_then(|text| text.split_once(": ")) - .map(|(id, title)| (id.parse::().ok(), Some(title.to_owned()))) - .unwrap_or((None, None)) - } else { - (None, None) - } - } else { - (None, None) - }; - let statuses: Vec<_> = document - .select(&Selector::parse("dl.sidebar dd span[class*='issuestatus-']").unwrap()) - .filter_map(|status| { - status - .value() - .classes() - .find_map(|class| class.strip_prefix("issuestatus-")) - }) - .collect(); - let status = match statuses.as_slice() { - [status] => Some(*status), - _ => None, - }; - if title.as_ref().is_none_or(|title| title.is_empty()) - || issue_id.is_none_or(|n| n == 0 || id.is_some_and(|id| n != id)) - || status.is_none() +fn issue(value: Value, repository: &str, id: u64) -> Result { + let issue = &value["issue"]; + if id == 0 || issue["number"].as_u64() != Some(id) + || !issue["title"].as_str().is_some_and(|s| !s.is_empty()) + || !issue["status"].as_str().is_some_and(|s| !s.is_empty()) + || !value["actions"].is_array() || !value["labels"].is_array() { - return Err(Error::new( - 502, - "Shale's issue page changed. Open the issue to check it.", - )); + return Err(Error::new(502, "Shale's issue response changed. Open the issue to check it.")); } - let mut comments = Vec::new(); - for comment in document.select(&Selector::parse("li.comment").unwrap()) { - let content = comment - .select(&Selector::parse(".markdown").unwrap()) - .next() - .ok_or_else(|| { - Error::new( - 502, - "Shale's comments changed. Open the issue to read them.", - ) - })?; - let author = comment - .select(&Selector::parse(".n-card__header span.usa-link.va-middle-childs, .n-card__header a[href^='/~'], .n-card__header a[href^='https://github.com/'], .n-card__header a:not([href]).va-middle-childs").unwrap()) - .next() - .map(text); - let time = comment - .select(&Selector::parse(".n-card__header span[title]").unwrap()) - .next() - .and_then(|e| e.attr("title")); - comments.push( - json!({"id":comment.attr("id"),"author":author,"createdAt":time,"text":text(content)}), - ); - } - let labels: Vec<_> = document - .select(&Selector::parse("dd.sidebar-labels a").unwrap()) - .map(text) + let comments: Vec<_> = array(&value["actions"]).iter() + .filter(|action| action["kind"] == "comment" && action["deleted_on"].is_null()) + .map(|action| json!({"author":action["actor"],"createdAt":action["added_on"],"text":action["payload"]})) .collect(); - Ok( - json!({"repository":repository,"id":issue_id,"title":title.unwrap(),"status":status,"labels":labels,"comments":comments}), - ) + Ok(json!({"repository":repository,"id":id,"title":issue["title"],"status":issue["status"],"labels":value["labels"],"comments":comments})) } + fn labels(html: &str, repository: &str) -> Result { - let document = document(html, "page-labels", Some(repository))?; + let document = Html::parse_document(html); + if document.select(&Selector::parse("body#page-labels").unwrap()).next().is_none() + || document.select(&Selector::parse("meta[name='astheno.shale.repo.name']").unwrap()).next() + .and_then(|meta| meta.attr("content")) != Some(repository) + { + return Err(Error::new(502, "Shale's label page changed. Open its labels page.")); + } let mut labels = Vec::new(); for row in document.select(&Selector::parse(".grid-container table tbody tr").unwrap()) { let cells: Vec<_> = row.select(&Selector::parse("td").unwrap()).collect(); @@ -477,7 +355,7 @@ impl ServerHandler for Shale { } if name == "list_labels" { let target = repository_path(&app.shale.origin, repository, &["issues", "labels"])?; - let result = labels(&app.shale.page(&target, &credential).await?, repository)?; + let result = labels(&app.shale.page(&target, &credential, "text/html").await?, repository)?; current(app, grant, &credential)?; return Ok(result); } @@ -487,7 +365,6 @@ impl ServerHandler for Shale { .ok_or_else(|| Error::new(400, "Choose a positive issue ID."))?) }; if let Some(id) = issue_id { target = repository_path(&app.shale.origin, repository, &["issues", &id.to_string()])?; } - if name == "create_issue" { target = repository_path(&app.shale.origin, repository, &["issues", "new"])?; } if let Some(q) = arguments.get("q") { let q = q.as_str().filter(|q| q.len() <= 4096).ok_or_else(|| Error::new(400, "Narrow the issue search."))?; target.query_pairs_mut().append_pair("q", q); @@ -514,34 +391,26 @@ impl ServerHandler for Shale { if body.len() > 262144 { return Err(Error::new(400, "Shorten the comment to leave room for its Assisted-by trailer.")); } } } - username(&app.shale.page(&app.shale.origin.join("/-/settings")?, &credential).await?)?; - let body = app.shale.page(&target, &credential).await?; + username(&app.shale.page(&app.shale.origin.join("/-/settings")?, &credential, "text/html").await?)?; if name == "list_issues" { - let document = document(&body, "page-issues", Some(repository))?; + let value = app.shale.json(&target, &credential).await?; + let rows = value.as_array() + .ok_or_else(|| Error::new(502, "Shale's issue list changed. Open it in Shale."))?; let mut issues = Vec::new(); - for row in document.select(&Selector::parse(".grid-container table tbody tr").unwrap()) { - let cells: Vec<_> = row.select(&Selector::parse("td").unwrap()).collect(); - if cells.len() != 6 { return Err(Error::new(502, "Shale's issue list changed. Open it in Shale.")); } - let id = text(cells[0]).strip_prefix('#').and_then(|s| s.parse::().ok()).filter(|n| *n > 0) + for row in rows { + let id = row["number"].as_u64().filter(|id| *id > 0) .ok_or_else(|| Error::new(502, "Shale's issue list changed. Open it in Shale."))?; - let status = cells[1].select(&Selector::parse("span[class]").unwrap()) - .flat_map(|span| span.value().classes()).find_map(|class| class.strip_prefix("issuestatus-")) - .filter(|status| !status.is_empty()) - .ok_or_else(|| Error::new(502, "Shale's issue list changed. Open it in Shale."))?; - issues.push(json!({"id":id,"title":text(cells[2]),"status":status,"author":text(cells[3]), - "modifiedAt":cells[4].select(&Selector::parse("span[title]").unwrap()).next().and_then(|e| e.attr("title")), - "createdAt":cells[5].select(&Selector::parse("span[title]").unwrap()).next().and_then(|e| e.attr("title"))})); + issues.push(json!({"id":id,"title":row["title"],"status":row["status"],"author":row["author"],"modifiedAt":row["last_updated"]})); } current(app, grant, &credential)?; return Ok(json!({"repository":repository,"issues":issues})); } if !write { - let issue = issue(&body, repository, issue_id)?; + let issue = issue(app.shale.json(&target, &credential).await?, repository, issue_id.unwrap())?; current(app, grant, &credential)?; return Ok(json!({"issue":issue})); } if name == "create_issue" { - document(&body, "page-new-issue", Some(repository))?; let status = match arguments.get("status").and_then(Value::as_str) { None if !arguments.contains_key("status") => "needs_triage", Some("triage") => "needs_triage", @@ -549,7 +418,9 @@ impl ServerHandler for Shale { _ => return Err(Error::new(400, "Choose todo or triage for a new issue.")), }; fields.insert("status".into(), status.into()); - } else { issue(&body, repository, issue_id)?; } + } else { + issue(app.shale.json(&target, &credential).await?, repository, issue_id.unwrap())?; + } let mut fields = serde_json::to_value(fields)?; if let Some(id) = issue_id { fields["id"] = json!(id); } fields["model"] = json!(model.unwrap()); @@ -558,7 +429,7 @@ impl ServerHandler for Shale { .map_err(|error| if error.status >= 500 { Error::new(502, "The write outcome is unknown. Check Shale before retrying.") } else { error })?; let id = result["id"].as_u64().ok_or_else(|| Error::new(502, "The write outcome is unknown. Check Shale before retrying."))?; let target = repository_path(&app.shale.origin, repository, &["issues", &id.to_string()])?; - let result = issue(&app.shale.page(&target, &credential).await?, repository, Some(id))?; + let result = issue(app.shale.json(&target, &credential).await?, repository, id)?; current(app, grant, &credential).map_err(|_| Error::new(502, "The write outcome is unknown. Check Shale before retrying."))?; Ok(json!({"issue":result})) }.await; @@ -923,62 +794,23 @@ mod tests { ); } #[test] - fn issue_pages_must_match_repository_identity_and_issue_number() { - let page = "

#3Snow & ☃

"; - assert_eq!(issue(page, "owned", Some(3)).unwrap()["title"], "Snow & ☃"); - assert_eq!(issue(page, "owned", Some(3)).unwrap()["status"], "done"); - let owner = format!( - "{page}
" - ); - assert_eq!(issue(&owner, "owned", Some(3)).unwrap()["status"], "done"); - assert!(issue(page, "other", Some(3)).is_err()); - assert!(issue(page, "owned", Some(4)).is_err()); - assert!(issue(&page.replace("page-issue", "page-login"), "owned", Some(3)).is_err()); - assert!( - issue( - &page.replace("issuestatus-done", "unknown"), - "owned", - Some(3) - ) - .is_err() - ); - assert!( - issue( - &format!( - "{page}" - ), - "owned", - Some(3) - ) - .is_err() - ); + fn issue_json_keeps_markdown_and_excludes_deleted_actions() { + let value = json!({"issue":{"number":3,"title":"Snow & ☃","status":"done"},"labels":["bug"],"actions":[ + {"actor":"owner","kind":"comment","payload":"**Markdown** ☃","added_on":"2026-10-13T00:00:00Z","deleted_on":null}, + {"actor":"owner","kind":"update_status","payload":"done","deleted_on":null}, + {"actor":"owner","kind":"comment","payload":"deleted","deleted_on":"2026-10-13T01:00:00Z"} + ]}); + let parsed = issue(value.clone(), "owned", 3).unwrap(); + assert_eq!(parsed["comments"], json!([{"author":"owner","createdAt":"2026-10-13T00:00:00Z","text":"**Markdown** ☃"}])); + assert_eq!(parsed["labels"], json!(["bug"])); + assert!(issue(value.clone(), "owned", 4).is_err()); + assert!(issue(value.clone(), "owned", 0).is_err()); + for field in ["issue", "actions", "labels"] { + let mut incomplete = value.clone(); + incomplete.as_object_mut().unwrap().remove(field); + assert!(issue(incomplete, "owned", 3).is_err()); + } } - #[test] - fn verified_r1616_issue_heading_keeps_identity_checks() { - let page = "

Issue #3: Snow & ☃

"; - assert_eq!(issue(page, "owned", Some(3)).unwrap()["title"], "Snow & ☃"); - assert!(issue(page, "other", Some(3)).is_err()); - assert!(issue(page, "owned", Some(4)).is_err()); - assert!( - issue( - &page.replace("r1616-ga87d2f5.zig.0.16.0", "r1758-new"), - "owned", - Some(3) - ) - .is_err() - ); - assert!(issue(&page.replace("Issue #3", "Issue #0"), "owned", None).is_err()); - } - #[test] - fn issue_comment_authors_include_external_guest_profiles() { - let page = "

#3Title

"; - let page = page.replace("", "
  • GPT-6.1 Sol (on behalf of ~clover)
    Comment
  • "); - let parsed = issue(&page, "owned", Some(3)).unwrap(); - assert_eq!(parsed["comments"][2]["author"], "GPT-6.1 Sol (on behalf of ~clover)"); - assert_eq!(parsed["comments"][0]["author"], "paperclover"); - assert_eq!(parsed["comments"][1]["author"], "Astheno user"); - } - #[test] fn account_identity_uses_html_text_and_rejects_login_or_changed_markup() { assert_eq!( diff --git a/service/shale/service.pkl b/service/shale/service.pkl index e49902f6fa87f741166c8e9c9f51f4374d2dcc25..2e7b6d85b94d2c71518b99f00538ae51c8f075ca 100644 --- a/service/shale/service.pkl +++ b/service/shale/service.pkl @@ -1,6 +1,7 @@ amends "../../config/Service.pkl" import "../../config/OpenID.pkl" as sso +import "../../config/site.pkl" as site meta { name = "Shale" @@ -18,7 +19,7 @@ requirements { prepare = "prepare.py" container { - image = "docker.io/astheno/shale@sha256:547a126d829c81be5d2435223a093337951e2c6ae71a114adf69938485fb3fa8" + image = "docker.io/astheno/shale@sha256:b55cc42c4eb2c1e21733405bec795e49ddd7c71fb1755d2aa2ee4361f750cebd" extraHosts { "\(sso.hostname):host-gateway" } http { @@ -54,6 +55,10 @@ container { ["SERVER_TITLE"] = "clover's git" // Concurrent Markdown rendering shares capture state between request workers. ["NPROC"] = "1" + when (site.preview) { + ["MIRRORS_DISABLE_CLONE"] = "true" + ["MIRRORS_DISABLE_PULL_POLL"] = "true" + } ["SESSION_SECRET"] = "${secret.own.session_secret}" ["OAUTH2_CLIENT"] = "oidc,\(sso.hostname)|${secret.oidc.clientId}|${secret.oidc.clientSecret}" } diff --git a/tools/dashboard-shale-link-test.py b/tools/dashboard-shale-link-test.py index 4afbb0ce4be5387aa7888b71da67a1e93761b4c9..719ccac8afc8ab6b466acb9768542af3d06343cb 100644 --- a/tools/dashboard-shale-link-test.py +++ b/tools/dashboard-shale-link-test.py @@ -354,7 +354,7 @@ def main(): created = call(read, 'get_issue', {'repository': 'alpha', 'id': 1})['issue'] assert created['title'] == title and created['id'] == 1 assert len(created['comments']) == 1 and 'Unicode ☃' in created['comments'][0]['text'] - assert '' in created['comments'][0]['text'] listed = call(read, 'list_issues', {'repository': 'alpha', 'q': 'is:open'})['issues'][0] assert listed['title'] == title and listed['status'] == created['status'] rejected = call(read, 'list_issues', {'repository': 'alpha', 'q': 'Unicode'}, error=True) diff --git a/tools/dashboard-shale-page-test.py b/tools/dashboard-shale-page-test.py index f90aa9f36ec611df61f86b0825da925bbea2496a..2fa1bd85acf48806b50b0194aabbefe364df49a1 100644 --- a/tools/dashboard-shale-page-test.py +++ b/tools/dashboard-shale-page-test.py @@ -55,6 +55,8 @@ def main(): observations.append((self.command, self.path, {key.lower(): value for key, value in self.headers.items()})) if self.path == '/binary': return self.respond(blob, 'application/octet-stream') + if self.path == '/json': + return self.respond(b'{"issue":{"title":" & Unicode"}}', 'application/json; charset=utf-8') if self.path == '/large': return self.respond(b' ' * (9 * 1024 * 1024), 'text/html') if self.path == '/-/login': @@ -199,6 +201,10 @@ def main(): assert observations[-1][1] == '/snowbound/issues/26?query=kept', observations[-1] assert observations[-1][2]['host'] == 'shale.studio.test', observations[-1] assert observations[-1][2]['cookie'] == 'SessionID=preserved', observations[-1] + status, headers, body = request('/json', headers={'Accept': 'application/json'}) + assert status == 200 and headers['Content-Type'].startswith('application/json') + assert body == b'{"issue":{"title":" & Unicode"}}' + assert observations[-1][2]['accept'] == 'application/json' assert not any(key.lower().startswith('studio-') for key in observations[-1][2]), observations[-1] status, headers, body = request('/~guest-github-24465214') assert status == 302 and headers['Location'] == 'https://github.com/paperclover' and headers['Referrer-Policy'] == 'no-referrer' diff --git a/tools/shale-migration.md b/tools/shale-migration.md index 0def154de3ccdb15fa7fb97f45628a75196aff50..830ef0744201613d7f423dbc87bb40b9de065fc7 100644 --- a/tools/shale-migration.md +++ b/tools/shale-migration.md @@ -52,7 +52,7 @@ The writable ZFS rehearsal `shale-preview-0242cee6` starts from all 104 existing Production issue import completed on October 5 under release `dda941e618934ad9`, from committed main `51be72a9`. Recovery snapshot: `globe/prod/shale@before-forgejo-issues-20261005T080143Z-14c71a`. The private import report and SQLite backup live at `/var/lib/studio/forgejo-issue-migration/issue-import-c726euv2`. All 104 native issues survived alongside the 452 imported issues. After the route reload settled, 904 concurrent HTTPS issue reads passed (644 successful reads, 260 expected private-page denials), all 24 attachment hashes and access checks passed, SQLite integrity passed, and a forged-Origin request returned 403. Browser navigation confirmed historical timestamps, comments, labels, and status on a live imported issue. Native `chat` #1 remains Todo. The disposable Keycloak rehearsal was destroyed after verification; the production recovery snapshot and private evidence remain. -This older build predates hidden form CSRF tokens. The router requires the exact HTTPS Origin for every Shale request using the `SessionID` cookie and a mutating method. The guard precedes all Shale handlers inside an explicit Caddy `route`; otherwise default directive ordering can bypass it. Missing, wrong, and suffix-forged origins returned 403 without a database change on the clone. The valid site origin allowed a status change, while Basic-auth Git requests still reached Shale. The MCP adapter permits tokenless issue forms only with the exact verified `r1616` structural footer and no CSRF-token input anywhere on the page. Newer or mixed-token markup remains strict. +The r1616 build predated hidden form CSRF tokens. The router's exact HTTPS Origin guard preceded all Shale handlers inside an explicit Caddy `route`; default directive ordering could otherwise bypass it. Missing, wrong, and suffix-forged origins returned 403 without a database change on the clone. The valid site origin allowed a status change, while Basic-auth Git requests still reached Shale. At that time, the MCP adapter accepted tokenless issue forms only with the verified `r1616` structural footer and no CSRF-token input anywhere on the page. The October 5 `r1763-g9f5b1c7.zig.0.16.0` upgrade rehearsal passed anonymous reads of the formerly crashing issues, Unicode issue creation and comments, issue closing with a comment Delete form present, access denial, restart persistence, token revocation, and logout. The Rust adapter parsed its actual owner issue markup and accepted its status/comment CSRF fields. All migrated SQLite rows remained identical. Eight-worker concurrent Markdown rendering still crashed; keep `NPROC=1`, which passed 280 concurrent fenced-code requests. The injected issue-form script is no longer needed. Private evidence lives at `/var/lib/studio/shale-upgrade-0680d28c`; its disposable containers were removed after testing. @@ -73,3 +73,11 @@ After a same-machine OS replacement, set `STUDIO_LEGACY_HANDOFF` to the [offline The Forgejo importer originally omitted `http.receivepack=true`, which Shale sets when it creates an owned repository. Shale checks its push ACL before invoking `git-http-backend`, but does not set `REMOTE_USER`; Git's default therefore rejected authorized pushes to imported repositories. The importer now writes the setting, and Shale's prepare step repairs missing settings without replacing an explicit disable. Production `config` remains owner-only for pushes. Shale also forwards CGI `Status` as an ordinary header on HTTP 200. The Git-specific Caddy handler translates Git's error statuses into HTTP statuses and removes the CGI header. A disposable production database/repository copy verified anonymous and invalid credentials return 401, authenticated non-owners return 403, owner discovery advertises `main=37665e69e1aa954f0dec06b1cafa1612f44dc907`, and an actual `jj git push --bookmark main` advances the clone to `b8e734ce6aabd94a7e1aacfc989467662ca27dbe`. Disabled receive-pack returns actual HTTP 403; invalid method/content type return 400/415 without a `Status` header. No production token was added. + +## r1807 JSON upgrade, 2026-10-13 UTC + +The pinned image in [service.pkl](../service/shale/service.pkl) serves repository lists, issue lists, and issue details as JSON with `Accept: application/json` on their existing URLs. The MCP reads those responses, retaining issue numbers as `id` and raw Markdown in comment text. Native JSON omits comment IDs and issue-list creation times, so the MCP omits those fields. Account settings return 406 for JSON, and label JSON omits numeric IDs; those two reads retain their HTML checks. Writes still use the host broker for durable model authorship, repository permissions, delegated statuses, and grant revocation. + +The inherited `shale-preview-8ff39b2c` contained earlier disposable test writes. Rehearsing its previous pinned image followed by r1807 preserved every row of all 10 existing tables, including 559 issues; SQLite integrity passed and its allocation had zero restarts. Preview mirror cloning and polling are disabled. Public browsing, README/file navigation, open/closed issue filters, issue detail, labels, keyboard navigation, and 390-pixel layouts passed browser checks. + +An independent instance used only synthetic databases, credentials, certificates, and native Snowglobe OIDC. The candidate Nix dashboard passed linking, every issue/label operation, raw Markdown and durable model attribution, anonymous/other-user/selected-repository denials, exact-Origin enforcement, uncertain-write handling without replay, 80 concurrent JSON reads, 280 concurrent fenced-Markdown reads, backend/dashboard restart persistence, revocation, unlinking, and SQLite integrity. `NPROC=1` remains in place. The router test also verifies JSON headers and bytes pass through unchanged. Restricted verification evidence is `/var/lib/studio/shale-json-upgrade-20261013`.