mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-07-27 04:11:01 +00:00
d26ab58189
* feat(fleet): cross-node bulk label assign with authoritative label discovery Make Fleet Actions > Bulk label assign work across the fleet. Pick a stack label that exists anywhere in the fleet, select stacks on one or more nodes, and the control orchestrates: each target node resolves the label by name, creating it with the same name and color if missing, then adds it to the selected stacks while preserving their existing labels. The local node runs in process; each remote runs its own admin-only local-assign receiver over the node proxy. Per-node failures (unknown node, no proxy target, unreachable, mixed-version remote) degrade that node only and are reported per node in the result. Assignment writes use a transactional INSERT OR IGNORE so the add-preserve path is idempotent and race-free. Also make the shared fleet label discovery authoritative: suggestions, match-preview, and the fleet-stop remote leg now read each node's labels live over the proxy instead of the control database, which does not mirror remote labels. A propagated label therefore appears in, and is stoppable by, Stop-by-label across the fleet, and unreachable nodes are surfaced rather than silently dropped. Fleet Actions runs against the unfiltered node list, so overview filters no longer narrow its scope. The previous node-scoped, replace-by-id bulk-assign endpoint is removed. * fix(fleet): treat malformed remote label responses as per-node failures A 200 response from a remote node whose body is not the expected shape was treated as a benign empty result, so a malformed remote could read as a clean zero-stack assign or a "matched, nothing to stop" no-op and even surface a success toast. Validate the wire shape in the bulk-assign and fleet-stop remote legs and in the authoritative label discovery fan-out; on a malformed body, report the node as a per-node failure with the error attributed to its stacks instead of silently dropping it. * chore: drop accidentally committed temp file
43 lines
2.0 KiB
TypeScript
43 lines
2.0 KiB
TypeScript
// Shared constants used across the backend. Extracted from index.ts to keep
|
|
// the entry point lean and to make values discoverable without scanning the
|
|
// monolith.
|
|
|
|
// Server
|
|
export const PORT = 1852;
|
|
|
|
// Password policy
|
|
export const MIN_PASSWORD_LENGTH = 8;
|
|
/** bcrypt cost factor. 10 is current Sencho default; roughly ~75ms/hash on modern hardware. */
|
|
export const BCRYPT_SALT_ROUNDS = 10;
|
|
|
|
// Labels
|
|
export const VALID_LABEL_COLORS = ['teal', 'blue', 'purple', 'rose', 'amber', 'green', 'orange', 'pink', 'cyan', 'slate'] as const;
|
|
export type LabelColor = typeof VALID_LABEL_COLORS[number];
|
|
export const MAX_LABELS_PER_NODE = 50;
|
|
// Hard cap on stack assignments a single bulk-assign request may carry, summed
|
|
// across all target nodes. A node typically has tens of stacks, not thousands;
|
|
// the cap bounds the DB writes one request can force. Shared by the per-node
|
|
// receiver and the fleet orchestrator so they cannot drift.
|
|
export const MAX_ASSIGNMENTS = 1000;
|
|
|
|
// Session cookies
|
|
export const COOKIE_NAME = 'sencho_token';
|
|
export const SESSION_COOKIE_MAX_AGE_MS = 24 * 60 * 60 * 1000; // 24 hours
|
|
export const MFA_PENDING_COOKIE_NAME = 'sencho_mfa_pending';
|
|
export const MFA_PENDING_SCOPE = 'mfa_pending';
|
|
export const MFA_PENDING_TTL_MS = 5 * 60 * 1000; // 5 minutes to complete the challenge
|
|
|
|
// MFA replay-prevention: recently-used codes are blacklisted for
|
|
// MFA_REPLAY_TTL_MS to block replay within a single 30-second TOTP window
|
|
// (plus drift tolerance). A periodic purge keeps the table bounded.
|
|
export const MFA_REPLAY_TTL_MS = 120 * 1000;
|
|
export const MFA_REPLAY_PURGE_INTERVAL_MS = 60 * 1000;
|
|
|
|
// Hot-path cache TTLs.
|
|
// Short TTLs collapse concurrent polling pressure across browser tabs and
|
|
// overlapping service samplers without introducing noticeable UI staleness.
|
|
// Keys are per-node: "stats:<nodeId>", "system-stats:<nodeId>", "stack-statuses:<nodeId>".
|
|
export const STATS_CACHE_TTL_MS = 2_000;
|
|
export const SYSTEM_STATS_CACHE_TTL_MS = 3_000;
|
|
export const STACK_STATUSES_CACHE_TTL_MS = 3_000;
|