docs(17-02): complete scheduler + storage plan

- Add 17-02-SUMMARY.md with execution results
- Update STATE.md position and metrics
- Mark SCHED-01 complete in REQUIREMENTS.md
This commit is contained in:
salvacybersec
2026-04-06 17:28:30 +03:00
parent c71faa97f5
commit d8a610758b
3 changed files with 115 additions and 8 deletions

View File

@@ -242,7 +242,7 @@ Requirements for initial release. Each maps to roadmap phases.
### Scheduled Scanning ### Scheduled Scanning
- [ ] **SCHED-01**: Cron-based recurring scan scheduling - [x] **SCHED-01**: Cron-based recurring scan scheduling
- [ ] **SCHED-02**: keyhunter schedule add/list/remove commands - [ ] **SCHED-02**: keyhunter schedule add/list/remove commands
- [ ] **SCHED-03**: Auto-notify on scheduled scan completion - [ ] **SCHED-03**: Auto-notify on scheduled scan completion

View File

@@ -3,14 +3,14 @@ gsd_state_version: 1.0
milestone: v1.0 milestone: v1.0
milestone_name: milestone milestone_name: milestone
status: executing status: executing
stopped_at: Completed 16-01-PLAN.md stopped_at: Completed 17-02-PLAN.md
last_updated: "2026-04-06T13:48:35.313Z" last_updated: "2026-04-06T14:28:16.926Z"
last_activity: 2026-04-06 last_activity: 2026-04-06
progress: progress:
total_phases: 18 total_phases: 18
completed_phases: 14 completed_phases: 14
total_plans: 85 total_plans: 85
completed_plans: 83 completed_plans: 84
percent: 20 percent: 20
--- ---
@@ -26,8 +26,8 @@ See: .planning/PROJECT.md (updated 2026-04-04)
## Current Position ## Current Position
Phase: 17 Phase: 17
Plan: Not started Plan: 2 of 5
Status: Ready to execute Status: executing
Last activity: 2026-04-06 Last activity: 2026-04-06
Progress: [██░░░░░░░░] 20% Progress: [██░░░░░░░░] 20%
@@ -100,6 +100,7 @@ Progress: [██░░░░░░░░] 20%
| Phase 15 P01 | 3min | 2 tasks | 13 files | | Phase 15 P01 | 3min | 2 tasks | 13 files |
| Phase 15 P03 | 4min | 2 tasks | 11 files | | Phase 15 P03 | 4min | 2 tasks | 11 files |
| Phase 16 P01 | 4min | 2 tasks | 6 files | | Phase 16 P01 | 4min | 2 tasks | 6 files |
| Phase 17 P02 | 2min | 2 tasks | 8 files |
## Accumulated Context ## Accumulated Context
@@ -152,6 +153,7 @@ Recent decisions affecting current work:
- [Phase 16]: VT uses x-apikey header per official API v3 spec - [Phase 16]: VT uses x-apikey header per official API v3 spec
- [Phase 16]: IX uses three-step flow: POST search, GET results, GET file content - [Phase 16]: IX uses three-step flow: POST search, GET results, GET file content
- [Phase 16]: URLhaus tag lookup with payload endpoint fallback - [Phase 16]: URLhaus tag lookup with payload endpoint fallback
- [Phase 17]: Scheduler.ScanFunc callback decouples from engine; OnComplete bridges to notifications; disabled jobs stay in DB
### Pending Todos ### Pending Todos
@@ -166,6 +168,6 @@ None yet.
## Session Continuity ## Session Continuity
Last session: 2026-04-06T13:46:09.383Z Last session: 2026-04-06T14:28:16.922Z
Stopped at: Completed 16-01-PLAN.md Stopped at: Completed 17-02-PLAN.md
Resume file: None Resume file: None

View File

@@ -0,0 +1,105 @@
---
phase: 17-telegram-scheduler
plan: 02
subsystem: scheduler
tags: [gocron, sqlite, cron, scheduler, telegram]
requires:
- phase: 01-foundation
provides: pkg/storage DB wrapper with schema.sql embed pattern
provides:
- pkg/scheduler/ package with gocron wrapper, start/stop lifecycle
- Storage CRUD for subscribers table (Add/Remove/List/IsSubscribed)
- Storage CRUD for scheduled_jobs table (Save/List/Get/Delete/UpdateLastRun/SetEnabled)
- subscribers and scheduled_jobs SQLite tables in schema.sql
affects: [17-telegram-scheduler, 17-03, 17-04, 17-05]
tech-stack:
added: [gocron/v2 v2.19.1]
patterns: [scheduler wraps gocron with DB persistence, ScanFunc abstraction decouples from engine]
key-files:
created:
- pkg/scheduler/scheduler.go
- pkg/scheduler/jobs.go
- pkg/scheduler/scheduler_test.go
- pkg/storage/subscribers.go
- pkg/storage/scheduled_jobs.go
modified:
- pkg/storage/schema.sql
- go.mod
- go.sum
key-decisions:
- "Scheduler.ScanFunc callback decouples from engine -- Plan 17-04 wires the real scan logic"
- "OnComplete callback bridges scheduler to notification system without direct bot dependency"
- "Disabled jobs skipped during Start() but remain in DB for re-enabling"
patterns-established:
- "Scheduler pattern: gocron wrapper with DB persistence and callback-based extensibility"
requirements-completed: [SCHED-01]
duration: 2min
completed: 2026-04-06
---
# Phase 17 Plan 02: Scheduler + Storage Summary
**gocron v2.19.1 wrapper with SQLite persistence for subscribers and scheduled scan jobs, callback-based scan/notify extensibility**
## Performance
- **Duration:** 2 min
- **Started:** 2026-04-06T14:25:04Z
- **Completed:** 2026-04-06T14:27:08Z
- **Tasks:** 2
- **Files modified:** 8
## Accomplishments
- Created pkg/scheduler/ package wrapping gocron with Start/Stop lifecycle and DB-backed job persistence
- Implemented full CRUD for subscribers (Add/Remove/List/IsSubscribed) and scheduled_jobs (Save/List/Get/Delete/UpdateLastRun/SetEnabled)
- Added subscribers and scheduled_jobs tables to schema.sql
- All 5 tests pass: storage round-trip, subscriber round-trip, scheduler start/add/remove/run
## Task Commits
Each task was committed atomically:
1. **Task 1: Add gocron dependency, create storage tables, and subscriber/job CRUD** - `c8f7592` (feat)
2. **Task 2 RED: Failing tests for scheduler package** - `89cc133` (test)
3. **Task 2 GREEN: Implement scheduler package** - `c71faa9` (feat)
## Files Created/Modified
- `pkg/scheduler/scheduler.go` - Scheduler struct wrapping gocron with Start/Stop/AddJob/RemoveJob/RunJob/ListJobs
- `pkg/scheduler/jobs.go` - Job and JobResult types
- `pkg/scheduler/scheduler_test.go` - 5 tests covering storage, subscriber, and scheduler lifecycle
- `pkg/storage/subscribers.go` - Subscriber struct and CRUD methods on DB
- `pkg/storage/scheduled_jobs.go` - ScheduledJob struct and CRUD methods on DB
- `pkg/storage/schema.sql` - subscribers and scheduled_jobs CREATE TABLE statements
- `go.mod` - gocron/v2 v2.19.1 promoted to direct dependency
- `go.sum` - Updated checksums
## Decisions Made
- ScanFunc callback decouples scheduler from engine -- Plan 17-04 wires real scan logic
- OnComplete callback bridges scheduler to notification system without direct bot dependency
- Disabled jobs skipped during Start() but remain in DB for re-enabling via SetJobEnabled
## Deviations from Plan
None - plan executed exactly as written.
## Issues Encountered
None
## User Setup Required
None - no external service configuration required.
## Next Phase Readiness
- pkg/scheduler/ ready for CLI wiring in Plan 17-03 (schedule add/list/remove commands)
- Subscriber storage ready for bot /subscribe handler in Plan 17-01
- OnComplete callback ready for notification bridge in Plan 17-04
---
*Phase: 17-telegram-scheduler*
*Completed: 2026-04-06*