Commit graph

17 commits

Author SHA1 Message Date
jedarden
429d831556 feat(cli): add worker and level filtering flags to tui and web commands
Add --worker <id> and --level <level> filtering flags to both "fabric tui"
and "fabric web" commands. Filters are applied at the tailer level for
efficiency, before events are added to the store.

- Add --worker <id> option to filter by specific worker ID
- Add --level <level> option to filter by log level (debug, info, warn, error)
- Validate level filter against valid levels
- Pass filter to TUI app for header indicator display
- Pass cliFilter to web server for UI indicator display
- Apply filters in tailer, OTLP/gRPC, and OTLP/HTTP event handlers

Also adds heap snapshot options to web command for leak detection:
- Add --heap-snapshots flag to enable automatic heap snapshots
- Add --snapshot-interval <minutes> option for snapshot frequency

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-27 01:34:37 -04:00
jedarden
982f93162c feat(cli): add fabric config command for configuration management
Add a new `fabric config` command that provides a user-friendly interface
to manage FABRIC configuration without manual file editing.

Features:
- `fabric config` - Show current configuration (theme, presets, recent commands, filter state)
- `fabric config theme [theme]` - Show or set theme (dark/light)
- `fabric config presets list` - List all focus presets
- `fabric config presets delete <name>` - Delete a focus preset
- `fabric config clear` - Clear configuration state (with --theme, --presets, --commands, --filters, --all options)

Config files managed:
- ~/.fabric/theme.json (theme preference)
- ~/.fabric/focus-presets.json (focus mode presets)
- ~/.fabric/recent-commands.json (command history)
- ~/.fabric-filter-state.json (filter persistence)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 22:21:21 -04:00
jedarden
87c7888351 feat(bd-ch6.6): add /api/health + /api/metrics self-observability
- /api/health returns {status, uptime_sec, version, event_count,
  ingest_rate_per_sec, ws_clients, tailer_files_watched, dedup_dropped,
  process_resident_memory_bytes}; returns HTTP 503 with status='overloaded'
  when maxEventCount is exceeded
- /api/metrics exposes the same counters in Prometheus text format;
  fabric_status=0 when overloaded
- Add ServerMetrics.eventCount setter so both endpoints sync from store.size
  (fixes fabric_event_count in /api/metrics showing 0 when events added directly)
- Wire --max-events CLI option into `fabric web`; pass maxEventCount and
  deduplicator to createWebServer so the memory-bomb guard and dedup_dropped
  reporting are actually activated
- Track tailerFilesWatched: set after tailer.start() and update on each event
  for DirectoryTailer (uses activeFiles.length getter)
- Add import for Node net module used by systemd watchdog notify
- Add tests: overload guard returns 503, within-limit returns 200, Prometheus
  reflects fabric_status=0 when overloaded

systemd service already has Restart=on-failure + WatchdogSec=30 (scripts/fabric-web.service);
liveness guard in server.ts calls process.exit(1) after 3 consecutive overload
checks, triggering systemd restart.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-23 21:54:38 -04:00
jedarden
794d5c3034 feat(bd-ch6.2): add fabric prune CLI with archive/delete retention policy
NEEDLE log retention for ~/.needle/logs/. The directory had grown to
103k files / 11GB with no cleanup. Adds:

- fabric prune command: archives old files into dated tar.gz, deletes
  expired archives, with configurable age thresholds
- mend.logs_pruned events emitted to fabric-mend.jsonl for FABRIC tailer
- systemd timer (fabric-prune.timer) for daily automatic pruning
- 9 tests covering archive, delete, dry-run, edge cases

Ran initial prune: 103,857 -> 1,006 files, 8.6 GB freed.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 21:04:54 -04:00
jedarden
632f35a4c3 feat(bd-0nd): route --source directory to DirectoryTailer, drop workers.log suffix
- resolveSource() now returns { kind: 'directory'|'file', path } instead
  of appending workers.log to directories
- New resolveFromOptions() handles CLI flag precedence: --source > --file > default
- Default (no flags) now tails ~/.needle/logs/ as a directory via DirectoryTailer
- --source <nonexistent-path> prints clear error and exits
- -f/--file keeps single-file LogTailer behavior for backwards compat
- tui, web, and tail/logs commands all updated
- replay and digest commands unchanged (file-only, no --source)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-22 16:24:40 -04:00
jedarden
f37d88de3e feat(bd-eir): complete FABRIC↔NEEDLE dovetail — wire cross-source dedup, add exporter docs
Wire shared EventDeduplicator across all ingestion paths (JSONL tailer,
OTLP/gRPC receiver, OTLP/HTTP receiver) so duplicate events from dual
ingestion are silently dropped on (session_id, worker_id, sequence).

Also adds docs/needle-exporter-wiring.md (OTLP configuration guide for
NEEDLE), SpanDag React component, EventFilter.eventType field, and
various test/layout fixes.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-21 19:35:39 -04:00
jedarden
1f392c39d6 feat(bd-pyz): add --source flag, logs alias, and update CLI examples
Add --source flag to tui/web/tail subcommands for specifying log source
as file or directory (directories get workers.log appended). Add 'logs'
as alias for 'tail' subcommand per plan.md CLI spec. Update README.md
with fabric logs examples and --source usage.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-21 14:59:15 -04:00
jedarden
7210fdf323 feat(bd-593): add OTLP/HTTP receiver on :4318 (protobuf + JSON)
Mount OTLP/HTTP handlers on the existing Express web server via a second
HTTP listener so OTLP endpoints are reachable at the standard :4318
address without a separate process. Accepts both application/x-protobuf
and application/json content types, routing decoded records through the
same Normalizer pipeline as the gRPC receiver.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-21 13:33:36 -04:00
jedarden
b9a7dcce92 feat(bd-4ka): Wire replay command into analytics pipeline
Feed replay events into the store's analytics pipeline via store.add()
in the onEvent callback, enabling worker analytics, error grouping,
cross-reference tracking, collision detection, and semantic narrative
generation during replay sessions. Print analytics summary on replay end.

Co-Authored-By: Claude Code (glm-5-turbo) <noreply@anthropic.com>
2026-03-20 00:34:07 -04:00
default
a2e3161134 feat(bd-n8y): Add authentication/authorization to FABRIC event ingestion endpoint
- Added authToken option to WebServerOptions interface
- Created createAuthMiddleware function for Bearer token auth
- Applied auth middleware to POST /api/events and /api/events/batch
- Updated CLI to read FABRIC_AUTH_TOKEN env var
- Added comprehensive tests for authentication scenarios

- Updated POST /api/events test cases to use auth token
- All tests passing successfully
2026-03-11 05:13:12 +00:00
jeda
9a015ffa42 fix: ESM/CommonJS blessed import compatibility
Changed all blessed imports from namespace import (import * as blessed)
to default import (import blessed from 'blessed') in 28 files.

This fixes "blessed.screen is not a function" runtime error that occurs
when ESM modules import CommonJS blessed package with namespace syntax.

Also includes WorkerAnalyticsPanel property additions for type compliance.

Fixes: bd-31x

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-04 23:47:19 +00:00
jeda
f6a7d09294 feat(bd-1c5): Implement AI session digest generation
Implement comprehensive session digest generation module that aggregates:
- Beads completed with duration tracking
- Files modified with tool and worker attribution
- Errors encountered with categorization
- Time spent per worker
- Token usage and estimated costs

Features:
- SessionDigestGenerator class for digest creation
- Markdown formatting with tables and summaries
- CLI integration via 'fabric digest' command
- Support for time range and worker filtering
- Comprehensive test coverage (14 tests, all passing)

CLI Usage:
  fabric digest -f <logfile> [options]
  Options: --output, --worker, --since, --until, --max-files, --max-errors

All tests passing: 616/616

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-04 03:28:04 +00:00
jeda
e1d269ef01 feat(bd-3k9): P4-001: Session Replay - Add type fixes and complete implementation
- Add SessionReplay component with full playback controls
- Add replay command to CLI with filter support
- Fix color type references in SessionReplay
- Add EventFilter type import to CLI
- Add File Heatmap types for future feature

Co-Authored-By: Claude Worker <noreply@anthropic.com>
2026-03-03 11:58:06 +00:00
jeda
19097e7841 feat(bd-4jn): P4-004: Smart Error Grouping
Implement smart error grouping to cluster similar errors together and reduce
noise in the activity stream. Uses pattern matching on error messages and
stack traces to group related errors.

Features:
- Error categorization into 9 categories (network, permission, validation, etc.)
- Pattern-based fingerprinting for grouping similar errors
- Normalization of variable data (IPs, paths, UUIDs, timestamps)
- Severity calculation based on frequency and recency
- Integration with InMemoryEventStore for automatic error tracking

New files:
- src/errorGrouping.ts - Error grouping module
- src/errorGrouping.test.ts - Comprehensive test suite (34 tests)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-03 11:53:27 +00:00
jeda
57e8193f7b feat(bd-2kf): Add comprehensive test coverage for parser and store
- Add 36 parser tests covering:
  - parseLogLine with valid/invalid inputs
  - parseLogLines for multi-line parsing
  - formatEvent with all options
  - Edge cases: malformed JSON, missing fields, colorization

- Add 35 store tests covering:
  - InMemoryEventStore add/query operations
  - Worker status tracking (active/idle/error)
  - Event filtering by worker, level, bead, timestamp
  - maxEvents limit and LRU trimming
  - getStore/resetStore singleton management

- Close phase beads (bd-2pa, bd-n8l, bd-2nu) as infrastructure complete
- Close test beads (bd-5eh, bd-2en) with comprehensive coverage
- Total: 91 tests passing across parser, store, and tailer

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-03 10:43:24 +00:00
jeda
a6699db07f feat: implement Phase 1 core infrastructure for FABRIC
Implements working `fabric tail` command with:

- Log tailer module (src/tailer.ts)
  - File watching with fs.watch
  - Follow mode for real-time updates
  - Buffer management for partial lines
  - Graceful shutdown handling

- JSON parser module (src/parser.ts)
  - Validates NEEDLE log format
  - Extracts optional fields (tool, path, bead, duration_ms, error)
  - Human-readable event formatting with color support

- In-memory event store (src/store.ts)
  - Stores events with worker indexing
  - Supports querying with filters
  - Auto-updates worker status based on events

- Working CLI (src/cli.ts)
  - Filters by worker (-w) and level (-l)
  - Supports --json output
  - Shows existing lines with -n flag

Resolves HUMAN bead bd-17q (worker starvation) by providing
working implementation and creating beads for remaining phases.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-03 04:58:42 +00:00
jeda
69f3c1d5ab feat: initialize FABRIC TypeScript project
Implements bd-3a4 and bd-2pa.1 (project setup):
- Initialize npm project with TypeScript configuration
- Add package.json with build scripts and dependencies
- Create src/ structure with types and CLI entry point
- Add CLI commands: tui, web, tail (placeholders)
- Configure tsconfig.json for NodeNext modules

This addresses worker starvation (bd-29a) by demonstrating
that direct implementation is a viable alternative when
workers cannot claim beads due to dependency resolution issues.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-03 04:41:00 +00:00