{"record":{"id":"0b5bc386184ac6da","repo":"Hmbown/CodeWhale","slug":"archive-the-legacy-recording-before-accepting-more-telemetry-0b5bc3","errorCode":null,"errorMessage":"Archive the legacy recording before accepting more telemetry.","messagePattern":"Archive the legacy recording before accepting more telemetry\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"pet/src/core/pet-world.ts","lineNumber":302,"sourceCode":"    this.branchTick = this.tick;\n    this.interactionLog.push({ timeMs: (this.tick + 1) * 1000 / HZ, kind, x, y });\n  }\n\n  /** Accept a live source packet at the next 400ms boundary. The accepted tape,\n   * including any missing intervals, is the exact replay authority for this host. */\n  acceptTelemetry(input: PetBucket): void {\n    validatePetBucket(input);\n    const sequence = Math.floor(this.tick / 12) + 1;\n    if (this.tapeLog.length >= 216_000) throw new Error('Archive this pet recording before accepting more telemetry.');\n    this.hasTelemetry = true;\n    if (this.segmented) {\n      const at = this.tapeLog.findIndex(b => b.sequence >= sequence);\n      const index = at < 0 ? this.tapeLog.length : at;\n      this.tapeLog.splice(index, at >= 0 && this.tapeLog[at].sequence === sequence ? 1 : 0,\n        { ...structuredClone(input), sequence, simTimeMs: sequence * 400 });\n      this.hashTape(index); return;\n    }\n    if (sequence >= 216_000) throw new Error('Archive the legacy recording before accepting more telemetry.');\n    const changedFrom = Math.min(sequence, this.tapeLog.length);\n    while (this.tapeLog.length <= sequence) {\n      const at = this.tapeLog.length;\n      this.tapeLog.push({ version: 1, sequence: at, simTimeMs: at * 400, durationMs: 400,\n        activity: .12, coherence: .25, attention: 0, channel: 'other', observed: 0, roamX: 0, roamY: 0, flip: 1, lit: 1,\n        onsets: Array(13).fill(0), activeMs: Array(13).fill(0), errors: 0, agentIds: [], waiting: false });\n    }\n    this.tapeLog[sequence] = { ...structuredClone(input), sequence, simTimeMs: sequence * 400 };\n    this.hashTape(changedFrom);\n  }\n\n  /** dt is bounded so suspending a surface cannot cause an unbounded catch-up. */\n  step(dt: number, opts: PetOpts = { motion: true, sensitivity: 1 }): WorldFrame {\n    if (!Number.isFinite(dt) || dt < 0 || dt > 10) throw new Error('World dt must be in [0, 10] seconds.');\n    this.accumulator += dt;\n    this.voices = [];\n    while (this.accumulator + 1e-10 >= 1 / HZ) {\n      this.accumulator -= 1 / HZ;","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/pet/src/core/pet-world.ts#L284-L320","documentation":"In the non-segmented (legacy) tape mode, acceptTelemetry() pads the tapeLog up to the incoming sequence number and throws if the sequence reaches 216,000 — the legacy recording has hit its maximum length. The recording must be archived and a new world started; no further legacy buckets are accepted.","triggerScenarios":"Calling acceptTelemetry() in legacy (non-segmented) mode once Math.floor(tick / 12) + 1 >= 216,000 — i.e. after ~24 simulated hours of ticks in legacy tape mode.","commonSituations":"A session that has run the simulation past the legacy tape's capacity; importing a legacy recording that is already near its maximum sequence and appending to it; running a long replay where the tape format predates segmented storage.","solutions":["Archive the legacy recording and start a fresh PetWorld for continued telemetry.","Migrate to segmented tape mode (the 'segmented' path in acceptTelemetry), which handles long recordings without the legacy sequence cap.","Pause simulation before the tick count reaches ~2,592,000 (216,000 × 12) if the legacy format must be kept.","Check the current sequence before accepting to stop cleanly at the boundary."],"exampleFix":"// before\nworld.acceptTelemetry(bucket); // legacy tape, sequence >= 216000\n// after\nif (world.tick / 12 >= 216_000) { archive(world); world = new PetWorld(...); }\nworld.acceptTelemetry(bucket);","handlingStrategy":"try-catch","validationCode":"const sequence = Math.floor(world.tick / 12) + 1;\nif (!world.segmented && sequence >= 216_000) archiveAndRotate(world);","typeGuard":"null","tryCatchPattern":"try { world.acceptTelemetry(bucket); } catch (e) { if (/Archive the legacy recording/.test(e.message)) { await archive(world); migrateToSegmentedOrRestart(); } else throw e; }","preventionTips":["Prefer segmented tape mode for anything expected to run long.","Stop accepting telemetry before tick/12 reaches 216,000 in legacy mode.","Archive on a wall-clock schedule (e.g. every 6h) instead of relying on the cap."],"tags":["telemetry","capacity-limit","legacy-format"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-22T16:17:23.217Z"}