Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (claude): tz-align mastery-window cutoffs with local-dated sessions

[._.]/ Adam Eivy299a4c2a9d29
diff --git a/server/services/meatspacePost.js b/server/services/meatspacePost.js
index 2f1120ac71..46b08c3330 100644
--- a/server/services/meatspacePost.js
+++ b/server/services/meatspacePost.js
@@ -1296,12 +1296,10 @@ async function getAdaptiveSignal(type) {
*/
async function getMultiplicationLevelStats(windowDays = MASTERY_DEFAULTS.windowDays) {
const sessions = await getPostSessions();
- let cutoffStr = null;
- if (windowDays > 0) {
- const cutoff = new Date();
- cutoff.setDate(cutoff.getDate() - windowDays);
- cutoffStr = cutoff.toISOString().split('T')[0];
- }
+ // Window off the user's local today (DST-safe day math) so the cutoff stays
+ // consistent with the tz-correct session dates submitPostSession now stamps
+ // (issue #2681) — a UTC-day cutoff would skew the window edge by the tz offset.
+ const cutoffStr = windowDays > 0 ? ymdShift(await localToday(), -windowDays) : null;
const byLevel = {};
let floorLevel = 0;
@@ -1365,12 +1363,9 @@ export async function getMultiplicationProgress() {
*/
async function getCognitiveLevelStats(type, windowDays = COGNITIVE_MASTERY_DEFAULTS.windowDays) {
const sessions = await getPostSessions();
- let cutoffStr = null;
- if (windowDays > 0) {
- const cutoff = new Date();
- cutoff.setDate(cutoff.getDate() - windowDays);
- cutoffStr = cutoff.toISOString().split('T')[0];
- }
+ // Window off the user's local today (DST-safe) so the cutoff stays consistent
+ // with the tz-correct session dates submitPostSession now stamps (issue #2681).
+ const cutoffStr = windowDays > 0 ? ymdShift(await localToday(), -windowDays) : null;
const byLevel = {};
let floorLevel = 0;