Dosu LogoDosu Logo
Ask
Join our Discord
Organization avatar
HashHivePublic
EvilBit Labs LLC
DocumentsHashHive
phase-1-core-infrastructure
phase-1-core-infrastructure
Type
External
Status
Published
Created
Jul 18, 2026
Updated
Jul 18, 2026
Source
docs/v2_rewrite_implementation_plan/phase-1-core-infrastructure.md

Phase 1: Core Infrastructure Setup#

โœ… Base SQLAlchemy Configuration#

  • Async SQLAlchemy engine with pooling
  • Base model with id, created_at, updated_at fields
  • Session management using dependency injection
  • Health check system via FastAPI route

๐Ÿงฉ Core Models Implementation#

๐Ÿ‘ค User Model#

  • Integrate fastapi-users for authentication and session handling
  • Extend base user model to include:
    • name, role (enum: admin, analyst, operator)
    • Login metadata: sign_in_count, current_sign_in_at, last_sign_in_at, current_sign_in_ip, last_sign_in_ip
    • Security: reset_password_token, unlock_token, failed_attempts
    • Indexes: email (unique), name (unique), reset_password_token (unique)
    • Optional: TOTP 2FA field

๐Ÿ“ Project Model#

  • Fields: name, description, private, archived_at (optional), notes (optional)
  • M2M Relationship with Users via association table
  • Index: name (unique)

๐Ÿง  OperatingSystem Model#

  • Fields: name (enum: windows, linux, darwin), cracker_command
  • Index: name (unique)
  • Validation: Enum enforcement via Pydantic and DB constraint

๐Ÿค– Agent Model#

  • Fields:
    • Identity: client_signature, host_name, custom_label
    • Auth: token, last_seen_at, last_ipaddress
    • State: state (enum: pending, active, error, offline, disabled), enabled (bool)
    • Config: advanced_configuration (JSON)
    • Devices: devices (array of dicts with type, model, hash rate, etc.)
    • Metadata: agent_type (optional: physical, virtual, container)
  • M2M with Projects
  • Indexes: token (unique), state, custom_label (unique)
  • Relationships: operating_system_id, user_id

โš ๏ธ AgentError Model#

  • Fields: message, severity, error_code, metadata (JSON)
  • Timestamps: created_at, updated_at
  • Indexes: agent_id, task_id
  • Relationships: agent_id, task_id

๐Ÿ’ฅ Attack Model#

  • Fields: name, description, state, hash_type (enum - Note: DB implementation uses column name type, should be renamed to hash_type for consistency)
  • Configuration block:
    • Mode: attack_mode (enum)
    • Masks: mask, increment_mode, increment_minimum, increment_maximum
    • Performance: optimized, workload_profile, slow_candidate_generators
    • Markov: disable_markov, classic_markov, markov_threshold
    • Rules: left_rule, right_rule
    • Charsets: custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4
  • Scheduling: priority, start_time, end_time
  • Relationships: campaign_id, rule_list_id, word_list_id, mask_list_id
  • Indexes: campaign_id, state, hash_type
  • Optional: Template linkage for cloning

๐Ÿงพ Task Model#

  • Fields:
    • state, stale
    • start_date, end_date, completed_at
    • progress_percent, progress_keyspace
    • result_json (structured output)
    • agent_id, attack_id
  • Indexes: agent_id, state, completed_at

โœ… Notes for Cursor#

  • Always use Pydantic v2 for schema validation and enforce field enums explicitly.
  • Use SQLAlchemy async ORM with Alembic for all model migrations.
  • All models must have matching CRUD FastAPI routers defined by end of Phase 2.
  • Enums must be validated both in schema and in SQL constraints.
  • Use helper services for non-trivial logic such as token validation or benchmark processing.

๐Ÿ”ง Implementation Discrepancies#

Attack Model: type vs hash_type#

Issue: The spec requires the Attack model to have a hash_type enum field, but the current Rails implementation uses a column named type.

Resolution Required:

  • Rename the attacks.type column to attacks.hash_type in the database schema
  • Update all queries, indexes, and model references from type to hash_type
  • Update API request/response DTOs to use hash_type
  • Update all tests to use hash_type
  • Run comprehensive grep to ensure no lingering references to the old type column name

Migration Task: Add to Milestone 1 tasks list (T048-T052) to create a Rails migration renaming this column.

Documents
.impeccable
0001-agent-enrollment-two-token-exchange
0002-docker-supervision-over-pm2
0003-bind-agent-to-enrollment-token
0004-agent-api-revisable-until-1.0
0005-version-public-api-after-1.0
0006-seaweedfs-over-minio
0007-three-api-surfaces
0008-betterauth-over-handrolled-jwt
0009-postgres-task-store-bullmq-orchestration
0010-schema-first-drizzle-zod
0011-pull-advisory-notify-task-distribution
0012-in-memory-websocket-v1-redis-deferred
0013-route-as-spec-hono-zod-openapi
0014-turborepo-bun-over-nx
0015-append-only-telemetry-timescaledb-rrd
0016-server-fanout-bus
0017-adaptive-task-sizing-lease
0018-real-db-integration-test-lane
0019-campaign-archiving-immutable-lifecycle
155-ac-traceability-matrix
155-task-distribution-assignment-spec
156-ac-traceability-matrix
156-object-storage-file-management-spec
160-login-project-selection-ui
2026-05-25-websocket-realtime-infrastructure-requirements
2026-05-29-dashboard-stats-and-read-endpoint-contract-requirements
2026-05-31-openapi-auto-generation-migration-requirements
2026-06-08-results-analysis-export-ui-requirements
2026-06-19-task-distribution-architecture
2026-06-20-campaign-archiving-requirements
2026-06-30-hash-export-import-search-requirements
227-spa-deep-link-refresh-redirect-spec
94-p0-cracker-binary-management-agent-auto-update
96-keyspace-task-distribution-spec
97-task-preemption-spec
99-attack-complexity-state-machine-spec
AGENTS
AGENTS
AI_POLICY
AI_POLICY
ARCHITECTURE
ARCHITECTURE
Agent_Authentication_&_Authorization
Agent_Heartbeat_&_Error_Handling
Agent_List_&_Detail_UI
Base Model Schema System
BullMQ_Queue_Architecture_&_Redis_Integration
CLAUDE
CONTRIBUTING
CONTRIBUTING
Campaign_Creation_Wizard_UI
Campaign_List_&_Detail_UI
Campaign_Orchestration_API
Code Quality Automation with Husky and Kiro Hooks
Core_Flows__HashHive_User_Journeys
Dashboard_&_Real-Time_Monitoring_UI
Dashboard_Stats_API_Endpoint_(GET__api_v1_dashboard_stats)
Development Workflow and Tooling Integration
ESLint and Formatting Configuration
Epic_Brief__HashHive_-_Modern_Distributed_Password_Cracking_Platform
GOTCHAS
GOTCHAS
Health Check Endpoint Enhancements
Login_&_Project_Selection_UI
MERN_proposal
Mixed Hash Type Detection & Automatic Campaign Splitting (#202)
MongoDB Connection Management
Object_Storage_&_File_Management
Project_Selection_&_User_Authentication_API
README
README
README
README
README
README
Real-Time_Events_&_WebSocket_Infrastructure
Resource_Management_API
Resource_Management_UI
Results_API_&_CSV_Export_(Dashboard_Backend)
Results_Analysis_&_Export_UI
SECURITY
SECURITY
STRATEGY
Task_Distribution_&_Assignment
Tech_Plan__HashHive_Architecture
Testing Strategy for Database and Models
advanced_task_scheduler
agent
agent-resource-protocol
agent-server-collaboration-vision
agent-token-rotation
agent_notes
agent_sync_extensions
agent_v1_contract_violations
allow_hybrid_hash_lists
attack
attack_notes
authentication_cleanup
back-compat-credential-format-migration
barrel-plus-subdir-service-split
brute_force_attack_editor
bullmq-jobid-dedup-requires-eviction
bun-test-mock-module-import-order
campaign_list_view
campaign_notes
campaigns
ci_check.prompt
code_review.prompt
contract-test-mocks-mirror-service-not-schema
copilot-instructions
core_algorithm_implementation_guide
crackable_uploads_plan
dashboard-read-endpoint-contract
dashboard-ux
default_config_suggestions
development
development
feat-agent-list-detail-ui
feat-betterauth-project-selection-rbac
feat-campaign-list-detail-ui
feat-masklist-keyspace
form-submit-payload-null-checks-2026-05-19
full_testing_architecture
getbytext-collision-waitfor-timeout
hard_password_attack_strategies
hash_hive_gap_analysis
health_status_screen
implementation_plan
learned_rules_parser_plan
llmstxt.prompt
markov_autogen_plan
new_dictionary_attack_editor
new_mask_attack_editor
openldap-testcontainer-bootstrap-race
performance_tuning.prompt
phase-1-core-infrastructure
phase-2-api-implementation
phase-2-api-implementation-part-1
phase-2-api-implementation-part-2
phase-2-api-implementation-part-3
phase-2b-resource-management
phase-2c-refactor-cleanup
phase-3-e2e-test-coverage-plan
phase-3-step-1
phase-3-step-2
phase-3-step-3
phase-3-step-4
phase-3-step-5
phase-3-web-ui-foundation
phase-4-containerization-deployment
phase-5-task-distribution
phase-6-monitoring-testing-documentation
playwright-shared-seed-user-last-project-id-flake
playwright-visual-baselines
pre-prod-wire-rename-and-schema-version-bump
previous_password_dictionary_attack_editor
projection-narrows-zrecord-wire-shape
psycopg_migration
radix-roving-focus-preventdefault-breaks-keyboard-nav
reactflow-position-by-array-index-2026-05-19
rule_explanation
salvage_templates
security_hardening.prompt
shadcn-radix-non-destructive-add-on-tailwind-v4
shared-zod-openapi-wire-contract-mirror-2026-05-25
spa_to_ssr
summary
template
test-coverage-plan
testcontainers_minio_support
testing
testing
user_flows_notes
v2-upgrade-overview
v2_agent_api_removal
work_next_task.prompt