Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .agents/skills/modwerk-diagnostics/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ If the developer is not the owner, say that shared diagnostics are private to th

The records are private. Tester names and anything quoted from a record stay in chat and in `~/.cache/modwerk-local/`: never in a commit, pull request, issue, changelog or document. There, write "a tester" and only the technical fact.

1. **Pull.** `git fetch`, then `npm run diagnostics:pull` on Node 24. The summary is long, so write it to `~/.cache/modwerk-local/diagnostics/pull-<today>.txt` and read its Problems section first; every record is in `~/.cache/modwerk-local/diagnostics/latest.json` (UTC). What the summary means, its known noise and an HTTP 403 are in `docs/MAINTENANCE.md#beta-worker`; the record schema is `src/community/octatrack-diagnostics-contract.ts`. With an argument, read only that member's, module's or symptom's records.
1. **Pull.** `git fetch`, then `npm run diagnostics:pull` on Node 24. The summary is long, so write it to `~/.cache/modwerk-local/diagnostics/pull-<today>.txt` and read its Problems section first; every record is in `~/.cache/modwerk-local/diagnostics/latest.json` (UTC). What the summary means, its known noise and an HTTP 403 are in `docs/MAINTENANCE.md#beta-worker`; the record schema is `src/community/octatrack-diagnostics-contract.ts`. With an argument, read only that member's, module's or symptom's records. A member who does not share can hand over the same records themselves: Copy details or a saved `modwerk-support-*.txt` after a USB error, or the USB events block of a report they posted; read their JSON lines with `parseSupportFile` (`src/community/support-report.ts`).
2. **Sort the failures into causes**, not records: sync and link failures, build failures, browser errors, unresponsive units, stalls and crashes in device logs, restores that were not `RESTORED`, CPU or DSP near the limit. One cause is one line: what happens, on which base, set, browser and OS, how many units, first and last seen.
3. **Drop what is not open.** For each cause check, in this order: the unit's base and module versions against what is live (an old build's bug that `changelog/` or the module's changelog already fixed is done), the open issues and pull requests (`gh issue list`, `gh pr list`), the findings in `docs/OCTATRACK_BETA_TEST_PLAN.md`, and the stock OS's own behaviour. Say which it was.
4. **Prove the rest before fixing it.** Find the code the record points at and reproduce the failure in a test, over HTTP, or with the developer MCP. On the owner's computer, take a turn through the [unit queue](../../../docs/OCTATRACK_DRIVING.md#taking-turns-on-the-unit) for hardware reproduction (`/modwerk-test-on-unit`). Confirm the shared emulator is free before starting it. A cause you cannot reproduce is a hypothesis: say what would confirm it, and add the missing diagnostic field or log line as the fix if that is what stands in the way. Never ask a tester to run tests.
Expand Down
2 changes: 1 addition & 1 deletion .claude/skills/modwerk-diagnostics/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ If the developer is not the owner, say that shared diagnostics are private to th

The records are private. Tester names and anything quoted from a record stay in chat and in `~/.cache/modwerk-local/`: never in a commit, pull request, issue, changelog or document. There, write "a tester" and only the technical fact.

1. **Pull.** `git fetch`, then `npm run diagnostics:pull` on Node 24. The summary is long, so write it to `~/.cache/modwerk-local/diagnostics/pull-<today>.txt` and read its Problems section first; every record is in `~/.cache/modwerk-local/diagnostics/latest.json` (UTC). What the summary means, its known noise and an HTTP 403 are in `docs/MAINTENANCE.md#beta-worker`; the record schema is `src/community/octatrack-diagnostics-contract.ts`. With an argument, read only that member's, module's or symptom's records.
1. **Pull.** `git fetch`, then `npm run diagnostics:pull` on Node 24. The summary is long, so write it to `~/.cache/modwerk-local/diagnostics/pull-<today>.txt` and read its Problems section first; every record is in `~/.cache/modwerk-local/diagnostics/latest.json` (UTC). What the summary means, its known noise and an HTTP 403 are in `docs/MAINTENANCE.md#beta-worker`; the record schema is `src/community/octatrack-diagnostics-contract.ts`. With an argument, read only that member's, module's or symptom's records. A member who does not share can hand over the same records themselves: Copy details or a saved `modwerk-support-*.txt` after a USB error, or the USB events block of a report they posted; read their JSON lines with `parseSupportFile` (`src/community/support-report.ts`).
2. **Sort the failures into causes**, not records: sync and link failures, build failures, browser errors, unresponsive units, stalls and crashes in device logs, restores that were not `RESTORED`, CPU or DSP near the limit. One cause is one line: what happens, on which base, set, browser and OS, how many units, first and last seen.
3. **Drop what is not open.** For each cause check, in this order: the unit's base and module versions against what is live (an old build's bug that `changelog/` or the module's changelog already fixed is done), the open issues and pull requests (`gh issue list`, `gh pr list`), the findings in `docs/OCTATRACK_BETA_TEST_PLAN.md`, and the stock OS's own behaviour. Say which it was.
4. **Prove the rest before fixing it.** Find the code the record points at and reproduce the failure in a test, over HTTP, or with the developer MCP. On the owner's computer, take a turn through the [unit queue](../../../docs/OCTATRACK_DRIVING.md#taking-turns-on-the-unit) for hardware reproduction (`/modwerk-test-on-unit`). Confirm the shared emulator is free before starting it. A cause you cannot reproduce is a hypothesis: say what would confirm it, and add the missing diagnostic field or log line as the fix if that is what stands in the way. Never ask a tester to run tests.
Expand Down
1 change: 1 addition & 0 deletions LICENSES/platform.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"src/community/profile-links.ts",
"src/community/remote-session-contract.ts",
"src/community/report-closure.ts",
"src/community/support-report.ts",
"src/community/usage-contract.ts",
"src/community/usage-pages.ts",
"src/config/beta-invitation.ts",
Expand Down
1 change: 1 addition & 0 deletions changelog/2026-11-24-usb-support-details.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Your Octatrack: after a failed sync, connection, self-test or base update, **Copy details** and **Save report** next to the error give you what went wrong, the base with its USB Audio layout and the last USB events, to paste in a message or keep as a file. The page keeps its last 100 USB events in memory whether or not you share diagnostics, and sends none of them by itself. **Report a problem** now fills in what the Octatrack runs and the last error, and offers to attach those events; you see what is attached and can remove it before posting. A failed base update that changes only the USB Audio layout now names the layout ("came back on base 0.8.1 (USB Audio off)") instead of reading like the same base.
1 change: 1 addition & 0 deletions public/licenses/THIRD_PARTY_NOTICES.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
src/community/profile-links.ts
src/community/remote-session-contract.ts
src/community/report-closure.ts
src/community/support-report.ts
src/community/usage-contract.ts
src/community/usage-pages.ts
src/config/beta-invitation.ts
Expand Down
1 change: 1 addition & 0 deletions public/licenses/THIRD_PARTY_NOTICES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ src/community/ot-log.ts
src/community/profile-links.ts
src/community/remote-session-contract.ts
src/community/report-closure.ts
src/community/support-report.ts
src/community/usage-contract.ts
src/community/usage-pages.ts
src/config/beta-invitation.ts
Expand Down
15 changes: 11 additions & 4 deletions server/configuration-reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import { followReportedModules } from './module-updates'
import type { Database, Env, User } from './platform'
import { HttpError, jsonBody, optional, required, response } from './security'
import { configurationSummary, validateConfigurationReportContext } from '../src/community/configuration-report'
import { IssueInputError } from '../src/community/issue-context'
import { IssueInputError, isDigiIssue } from '../src/community/issue-context'
import { OT_LOG_MAX_BYTES, OtLogError, parseOtLog } from '../src/community/ot-log'
import { communityModule } from '../src/community/modules'
import { SUPPORT_ATTACHMENT_BYTES } from '../src/community/support-report'
import { validateSupportAttachment } from './support-attachment'

const FIELDS = ['title', 'steps', 'expected', 'actual', 'context', 'log', 'maintainerSharing', 'visibility', 'notifyUpdates']
const FIELDS = ['title', 'steps', 'expected', 'actual', 'context', 'log', 'usbEvents', 'maintainerSharing', 'visibility', 'notifyUpdates']
function input<T>(read: () => T): T { try { return read() } catch (error) { if (error instanceof IssueInputError || error instanceof OtLogError) throw new HttpError(400, error.message); throw error } }

/**
Expand All @@ -19,7 +21,7 @@ function input<T>(read: () => T): T { try { return read() } catch (error) { if (
*/
export async function createConfigurationReport(request: Request, env: Env, db: Database, user: User | null) {
const owner = needMember(user)
const body = await jsonBody(request, OT_LOG_MAX_BYTES + 32 * 1024)
const body = await jsonBody(request, OT_LOG_MAX_BYTES + SUPPORT_ATTACHMENT_BYTES + 32 * 1024)
if (Object.keys(body).some(key => !FIELDS.includes(key))) throw new HttpError(400, 'Unexpected report field. Files and firmware are not accepted.')
if (body.notifyUpdates !== undefined && typeof body.notifyUpdates !== 'boolean') throw new HttpError(400, 'Choose whether to follow module updates.')
if (body.visibility !== undefined && body.visibility !== 'forum' && body.visibility !== 'private') throw new HttpError(400, 'Choose a public forum report or a private report.')
Expand All @@ -31,6 +33,11 @@ export async function createConfigurationReport(request: Request, env: Env, db:
const log = attached ? input(() => parseOtLog(body.log as string)) : null
// An attached log records the configuration the device ran; otherwise the reporter names it.
const { context, modules } = input(() => validateConfigurationReportContext(body.context, log?.summary ?? null))
// USB events the reporter chose to attach (support-report.ts): kept with the configuration, which reaches GitHub on the
// same terms as the log.
const usb = body.usbEvents === undefined || body.usbEvents === null ? undefined : validateSupportAttachment(body.usbEvents)
if (usb && isDigiIssue(context)) throw new HttpError(400, 'USB events come from an Octatrack. Remove them and post the report again.')
if (usb && JSON.stringify(usb).length > SUPPORT_ATTACHMENT_BYTES) throw new HttpError(400, 'The attached USB events are too long. Remove them and post the report again.')
// Member first, so one member's refused reports never fill the address's or the site's counter.
await throttle(db, 'issue-member:' + owner.id, 10)
await throttle(db, 'issue-ip:' + (request.headers.get('CF-Connecting-IP') ?? 'local'), 10)
Expand All @@ -47,7 +54,7 @@ export async function createConfigurationReport(request: Request, env: Env, db:
db.prepare('INSERT INTO forum_posts(id,thread_id,user_id,body) VALUES(?,?,?,?)').bind(postId, threadId, owner.id, 'Configuration (' + configurationSummary(modules.length) + '): ' + modules.map(module => module.name + ' ' + module.version).join(', ') + '\n\n' + details),
db.prepare('INSERT INTO forum_follows(thread_id,user_id) VALUES(?,?)').bind(threadId, owner.id),
] : []
statements.push(db.prepare("INSERT INTO issues(id,module_id,author_login,reporter_id,title,body,context_json,github_state,maintainer_sharing,forum_thread_id,public_json,scope) VALUES(?,?,?,?,?,?,?,?,?,?,?,'configuration')").bind(id, anchor.id, anchor.author, owner.id, title, details, JSON.stringify(context), github ? 'pending' : 'none', Number(publicReport || body.maintainerSharing === true), threadId, publicDetails && JSON.stringify(publicDetails)))
statements.push(db.prepare("INSERT INTO issues(id,module_id,author_login,reporter_id,title,body,context_json,github_state,maintainer_sharing,forum_thread_id,public_json,scope) VALUES(?,?,?,?,?,?,?,?,?,?,?,'configuration')").bind(id, anchor.id, anchor.author, owner.id, title, details, JSON.stringify(usb ? { ...context, usb } : context), github ? 'pending' : 'none', Number(publicReport || body.maintainerSharing === true), threadId, publicDetails && JSON.stringify(publicDetails)))
for (const module of modules) statements.push(db.prepare('INSERT INTO issue_modules(issue_id,module_id,version) VALUES(?,?,?) ON CONFLICT DO NOTHING').bind(id, module.id, module.version))
if (log) statements.push(db.prepare('INSERT INTO issue_logs(issue_id,text,bytes,summary_json) VALUES(?,?,?,?)').bind(id, log.text, log.text.length, JSON.stringify(log.summary)))
if (body.notifyUpdates !== false) statements.push(...followReportedModules(db, modules.map(module => module.id), owner.id))
Expand Down
13 changes: 8 additions & 5 deletions server/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { profilePath } from '../src/community/forum-links'
import { FLASH_STATES, type IssueContext } from '../src/community/issue-context'
import { REPORT_CLOSURE_REASONS, REPORT_COMMANDS, type ReportClosureReason } from '../src/community/report-closure'
import { digest } from './security'
import { supportBlock, type SupportAttachment } from '../src/community/support-report'

const API = 'https://api.github.com'
const BODY_LIMIT = 60000
Expand Down Expand Up @@ -69,7 +70,7 @@ const quote = (text: string) => inert(text).split(/\r?\n/).map(line => '> ' + li
*/
export type PublicBugDetails = { device: string; version: string; steps: string; expected: string; actual: string; modules?: { id: string; name: string; version: string }[]; full?: boolean }
/** A whole-configuration report lists every module in `moduleIds`; `module_id` is then only the first of them. */
export type MirroredIssue = { id: string; module_id: string; scope?: 'module' | 'configuration'; moduleIds?: string[]; title: string; reporter: string | null; owners: string[]; details: PublicBugDetails; context?: IssueContext; log?: string }
export type MirroredIssue = { id: string; module_id: string; scope?: 'module' | 'configuration'; moduleIds?: string[]; title: string; reporter: string | null; owners: string[]; details: PublicBugDetails; context?: IssueContext; log?: string; usb?: SupportAttachment }

export function issueTitle(issue: Pick<MirroredIssue, 'module_id' | 'scope' | 'title'>) { return ('[' + (issue.scope === 'configuration' ? 'configuration' : issue.module_id) + '] ' + issue.title).slice(0, 256) }
const GITHUB_LOGIN = /^[A-Za-z0-9-]{1,39}$/
Expand Down Expand Up @@ -115,8 +116,10 @@ export function issueMarkdown(issue: MirroredIssue, app?: string) {
'Only the registered release author can use `resolve`, after verifying that exact published download fixes the report on their unit. Ordinary closures claim no new firmware fix.', '',
'A merged PR alone does not resolve a report. [Author release steps](https://github.com/repeat98/modwerk/blob/main/docs/MODULE_AUTHOR_UPDATES.md).',
]
const log = issue.log ? ['### Device log', '', ...logBlock(issue.log, BODY_LIMIT - [...report, ...rest].join('\n').length)] : []
return [...report, ...log, ...rest].join('\n').slice(0, BODY_LIMIT)
// The reporter attached them themselves (support-report.ts); checked to numbers, codes and hashes when they posted.
const usb = issue.usb ? ['### USB events', '', ...supportBlock(issue.usb)] : []
const log = issue.log ? ['### Device log', '', ...logBlock(issue.log, BODY_LIMIT - [...report, ...usb, ...rest].join('\n').length)] : []
return [...report, ...usb, ...log, ...rest].join('\n').slice(0, BODY_LIMIT)
}

export async function createGithubIssue(config: GithubConfig, issue: MirroredIssue, app?: string) {
Expand Down Expand Up @@ -178,8 +181,8 @@ export async function mirrorIssue(db: Database, env: Env, id: string, stale = fa
const details = JSON.parse(row.public_json) as PublicBugDetails
// Only reporters who agreed to publish them get their configuration and log on GitHub.
const log = details.full ? (await db.prepare('SELECT text FROM issue_logs WHERE issue_id=?').bind(id).first<{ text: string }>())?.text : undefined
const context = details.full && row.context_json ? JSON.parse(row.context_json) as IssueContext : undefined
const created = await createGithubIssue(config, { id: row.id, module_id: row.module_id, scope: row.scope, moduleIds, title: row.title, reporter: row.reporter, owners, details, context, log }, env.APP_URL)
const context = details.full && row.context_json ? JSON.parse(row.context_json) as IssueContext & { usb?: SupportAttachment } : undefined
const created = await createGithubIssue(config, { id: row.id, module_id: row.module_id, scope: row.scope, moduleIds, title: row.title, reporter: row.reporter, owners, details, context, log, ...(context?.usb ? { usb: context.usb } : {}) }, env.APP_URL)
await db.prepare("UPDATE issues SET github_state='synced',github_number=?,github_url=?,github_error='' WHERE id=?").bind(created.number, created.url, id).run()
return { state: 'synced' as const, url: created.url }
} catch (error) {
Expand Down
38 changes: 38 additions & 0 deletions server/support-attachment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { HttpError } from './security'
import { validateDiagnostic } from './octatrack-diagnostics'
import { DIAGNOSTIC_USB_EVENTS } from '../src/community/octatrack-diagnostics-contract'
import { SUPPORT_ATTACHED_EVENTS, SUPPORT_LAYOUTS, type SupportAttachment, type SupportEvent } from '../src/community/support-report'

const object = (v: unknown): v is Record<string, unknown> => !!v && typeof v === 'object' && !Array.isArray(v)
const hash = (v: unknown) => typeof v === 'string' && /^[a-f0-9]{64}$/.test(v)
/** validateDiagnostic wants a record id; an attached event has none of its own. */
const NO_ID = '00000000-0000-4000-8000-000000000000'
/** The link's own events: no device log (the collector reads that, not the link) and no browser or build events. */
const LINK_EVENTS: readonly string[] = [...DIAGNOSTIC_USB_EVENTS.filter(event => event !== 'device_log'), 'link_failed']
const refuse = (): never => { throw new HttpError(400, 'The attached USB events are unreadable. Remove them and post the report again.') }
const checked = (record: Record<string, unknown>) => { try { return validateDiagnostic({ id: NO_ID, ...record }) } catch { return refuse() } }

/**
* USB events a member attached to a problem report (support-report.ts): the trail's records, each held to the shared
* diagnostics' field rules (validateDiagnostic), with when the page saw it, plus the unit's base, version, layout, model
* text and running set, and the browser family. Anything else is refused, so no free text reaches the issue.
*/
export function validateSupportAttachment(value: unknown): SupportAttachment {
if (!object(value) || value.schema !== 1 || !Object.keys(value).every(key => ['schema', 'unit', 'client', 'events'].includes(key))) return refuse()
const { unit, client, events } = value
if (unit !== undefined && !(object(unit) && Object.keys(unit).every(key => ['base', 'version', 'layout', 'model', 'active'].includes(key)) && hash(unit.base)
&& (unit.version === undefined || typeof unit.version === 'string' && /^[0-9]{1,3}(?:\.[0-9]{1,3}){1,3}$/.test(unit.version))
&& (unit.layout === undefined || SUPPORT_LAYOUTS.includes(unit.layout as string))
&& (unit.model === undefined || typeof unit.model === 'string' && /^[A-Za-z0-9 ._+-]{1,16}$/.test(unit.model))
&& (unit.active === undefined || hash(unit.active)))) return refuse()
if (client !== undefined) checked({ event: 'connected', phase: 'ready', client })
if (!Array.isArray(events) || !events.length || events.length > SUPPORT_ATTACHED_EVENTS) return refuse()
const list = events.map(entry => {
if (!object(entry) || typeof entry.at !== 'string' || entry.at.length > 30 || !/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d{1,3})?Z$/.test(entry.at) || !Number.isFinite(Date.parse(entry.at))) return refuse()
const { at, ...record } = entry
if (!LINK_EVENTS.includes(record.event as string) || 'modules' in record || 'client' in record) return refuse()
checked(record)
return { at, ...record } as SupportEvent
})
return { schema: 1, ...(unit ? { unit: unit as unknown as SupportAttachment['unit'] } : {}), ...(client ? { client: client as SupportAttachment['client'] } : {}), events: list }
}
Loading
Loading