release(v4.0.0): Shade GA — V3.x consolidation + audit prep
Some checks failed
Test / test (push) Has been cancelled
Cross-platform vectors / TypeScript vectors (bun) (push) Has been cancelled
Cross-platform vectors / Kotlin vectors (gradle) (push) Has been cancelled
Docker build and publish / docker (push) Has been cancelled
Publish / publish (push) Has been cancelled
Some checks failed
Test / test (push) Has been cancelled
Cross-platform vectors / TypeScript vectors (bun) (push) Has been cancelled
Cross-platform vectors / Kotlin vectors (gradle) (push) Has been cancelled
Docker build and publish / docker (push) Has been cancelled
Publish / publish (push) Has been cancelled
V3.1 → V3.12 consolidated and tagged for the first GA release. Wire format unchanged from 0.4.x — 4.0 peers interoperate with 0.4.x peers byte-for-byte. The version bump is semantic: audit-cycle complete, opt-in surface fully exposed, threat model refreshed for every new surface. Highlights: - All 24 @shade/* packages bumped to 4.0.0 in lockstep. - CHANGELOG 4.0.0 section is the canonical manifest of what landed. - THREAT-MODEL extended (§10 fingerprint gates, §11 WebRTC P2P, §12 Web-Worker boundary) + residual-risks table refreshed. - OpenAPI now covers all 27 routes: prekey, transfer, KT, inbox, bridge, observer, /metrics, /healthz, /ready. - MIGRATION 0.3.x → 4.0 documented + smoke-tested against shade migrate-storage on a real SQLite DB. - docs/audit/REVIEW-BUNDLE.md + SCOPE.md ready for external reviewer. - scripts/soak.ts harness for the GA-stable 2-week soak window. - All V*.md plans archived under docs/archive/ with Status: Done. - Voice/Video carved out into V5.0; 4.0 audit focuses on the frozen non-realtime stack. Tests: TS 1000/1000 + Kotlin 11/11 cross-platform vectors green. Docker: gt.zyon.no/stian/shade-prekey:4.0.0 builds and reports version 4.0.0 on /health. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
96
packages/shade-observability/tests/attributes.test.ts
Normal file
96
packages/shade-observability/tests/attributes.test.ts
Normal file
@@ -0,0 +1,96 @@
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import {
|
||||
bytesBin,
|
||||
laneCountBin,
|
||||
peerHash,
|
||||
safeAttribute,
|
||||
UnsafeAttributeError,
|
||||
} from '../src/index.ts';
|
||||
|
||||
describe('peerHash', () => {
|
||||
test('produces stable 8-char hex', () => {
|
||||
const a = peerHash('alice@example.com');
|
||||
const b = peerHash('alice@example.com');
|
||||
expect(a).toBe(b);
|
||||
expect(a).toMatch(/^[0-9a-f]{8}$/);
|
||||
});
|
||||
|
||||
test('different addresses produce different hashes', () => {
|
||||
expect(peerHash('alice@example.com')).not.toBe(peerHash('bob@example.com'));
|
||||
});
|
||||
|
||||
test('never echoes the address', () => {
|
||||
const addr = 'alice@example.com';
|
||||
expect(peerHash(addr).includes('alice')).toBe(false);
|
||||
expect(peerHash(addr).includes('@')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('bytesBin', () => {
|
||||
test('bins by order of magnitude', () => {
|
||||
expect(bytesBin(0)).toBe('≤4KB');
|
||||
expect(bytesBin(4096)).toBe('≤4KB');
|
||||
expect(bytesBin(4097)).toBe('4–64KB');
|
||||
expect(bytesBin(64 * 1024)).toBe('4–64KB');
|
||||
expect(bytesBin(64 * 1024 + 1)).toBe('64KB–1MB');
|
||||
expect(bytesBin(1024 * 1024)).toBe('64KB–1MB');
|
||||
expect(bytesBin(10 * 1024 * 1024)).toBe('1–10MB');
|
||||
expect(bytesBin(100 * 1024 * 1024)).toBe('10–100MB');
|
||||
expect(bytesBin(1024 * 1024 * 1024)).toBe('100MB–1GB');
|
||||
expect(bytesBin(2 * 1024 * 1024 * 1024)).toBe('≥1GB');
|
||||
});
|
||||
|
||||
test('handles invalid input', () => {
|
||||
expect(bytesBin(-1)).toBe('unknown');
|
||||
expect(bytesBin(NaN)).toBe('unknown');
|
||||
expect(bytesBin(Infinity)).toBe('unknown');
|
||||
});
|
||||
});
|
||||
|
||||
describe('laneCountBin', () => {
|
||||
test('snaps to {1, 4, 16, 64}', () => {
|
||||
expect(laneCountBin(1)).toBe(1);
|
||||
expect(laneCountBin(2)).toBe(4);
|
||||
expect(laneCountBin(4)).toBe(4);
|
||||
expect(laneCountBin(5)).toBe(16);
|
||||
expect(laneCountBin(16)).toBe(16);
|
||||
expect(laneCountBin(32)).toBe(64);
|
||||
expect(laneCountBin(128)).toBe(64);
|
||||
});
|
||||
});
|
||||
|
||||
describe('safeAttribute', () => {
|
||||
test('rejects PII-flavoured keys', () => {
|
||||
expect(() => safeAttribute('shade.peer.address', 'x')).toThrow(UnsafeAttributeError);
|
||||
expect(() => safeAttribute('shade.bytes.exact', 1)).toThrow(UnsafeAttributeError);
|
||||
expect(() => safeAttribute('shade.plaintext', 'x')).toThrow(UnsafeAttributeError);
|
||||
});
|
||||
|
||||
test('rejects address-like values', () => {
|
||||
expect(() => safeAttribute('custom.tag', 'alice@example.com')).toThrow(UnsafeAttributeError);
|
||||
expect(() => safeAttribute('custom.tag', 'device:abc-123')).toThrow(UnsafeAttributeError);
|
||||
expect(() => safeAttribute('custom.tag', 'did:web:example.com')).toThrow(UnsafeAttributeError);
|
||||
});
|
||||
|
||||
test('rejects oversized strings', () => {
|
||||
expect(() => safeAttribute('ok', 'x'.repeat(257))).toThrow(UnsafeAttributeError);
|
||||
});
|
||||
|
||||
test('accepts safe values', () => {
|
||||
expect(safeAttribute('shade.bytes.bin', '4–64KB')).toEqual({
|
||||
key: 'shade.bytes.bin',
|
||||
value: '4–64KB',
|
||||
});
|
||||
expect(safeAttribute('shade.lane.count', 4)).toEqual({ key: 'shade.lane.count', value: 4 });
|
||||
expect(safeAttribute('shade.retry.count', 0)).toEqual({ key: 'shade.retry.count', value: 0 });
|
||||
expect(safeAttribute('shade.error.code', 'SHADE_TIMEOUT')).toEqual({
|
||||
key: 'shade.error.code',
|
||||
value: 'SHADE_TIMEOUT',
|
||||
});
|
||||
// hashes pass through
|
||||
expect(safeAttribute('shade.peer.hash', 'abcdef01')).toEqual({
|
||||
key: 'shade.peer.hash',
|
||||
value: 'abcdef01',
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user