jsdoc typing round, phases 1-2: tsc as a no-emit checker over plain mjs (checkJs, strict), the shared shapes in server/shapes.mjs (log events as a tagged union, wire messages, manifests, job state, the ctx), all 12 server modules annotated; requireOwner/requireSuperuser as JSDoc assertion functions so the router guarantee narrows without callsite churn; runtime stays zero-dependency (typescript + @types/node as pinned devDeps, node_modules gitignored, QUESTIONS #4 amended: dev tooling exempt); every non-annotation delta audited onto a small intended list (clerk status ?? 1, dead 401 guards, async wraps on enqueue callsites); smoke 105/105 + restart + repo checks green; the clerk and web/ are the next phases
This commit is contained in:
+8
-1
@@ -15,9 +15,14 @@
|
||||
// pairing violations).
|
||||
import { randomInt } from 'node:crypto';
|
||||
|
||||
/** @typedef {import('./shapes.mjs').LogEvent} LogEvent */
|
||||
|
||||
const ANY_TAG = /<\/?variants?>/; // matches <variant>, <variants>, and both closers
|
||||
|
||||
// null = no variants syntax at all (a plain turn); throws on malformed
|
||||
/** The parsed candidates of one variants block.
|
||||
* @typedef {{ variants: string[] }} Variants */
|
||||
|
||||
/** @param {?string} text @returns {?Variants} null = no variants syntax at all (a plain turn); throws on malformed */
|
||||
export function parseVariants(text) {
|
||||
const t = String(text ?? '');
|
||||
if (!ANY_TAG.test(t)) return null;
|
||||
@@ -35,6 +40,7 @@ export function parseVariants(text) {
|
||||
}
|
||||
|
||||
// the dice: uniform, server-side, unwatchable by the model
|
||||
/** @param {number} count @returns {number} */
|
||||
export const pickVariant = (count) => randomInt(count);
|
||||
|
||||
// The effective-content map: what each assistant message "really
|
||||
@@ -42,6 +48,7 @@ export const pickVariant = (count) => randomInt(count);
|
||||
// note renders the chosen variant; a message still mid-turn (a tool
|
||||
// call carrying draft variants) renders the block stripped -- the
|
||||
// candidates are her live draft until a pick resolves them.
|
||||
/** @param {LogEvent[]} lines @returns {Map<number, string>} */
|
||||
export function effectiveContents(lines) {
|
||||
const eff = new Map();
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user