This plan migrates behavioral task code out of the original monorepo into RPi4_behavior_tasks with architectural cleanup first.
- Phase 0: completed.
- Phase 1: completed.
- Phase 2: completed.
- Phase 3: completed (experimental staging with opt-in execution).
- Phase 4: completed (production guardrails, runbook, and contributor boundaries).
- Phase 5: completed (optional tag-strict production lock and CI automation).
- Phase 6: completed (artifact integrity validation and verifier CLI).
- Phase 7: completed (semantic run-quality checks and quality reports).
- Phase 8: completed (deterministic seeded baseline regression harness).
Inputs agreed during planning:
- Priority: architectural cleanup over direct code copy.
- Active users/tasks to support first: Julia/Duy go-no-go, Matt context tasks.
- Soyoun treadmill task status is unknown; include later as experimental.
- Exclude
obsolete/content from migration. - Collapse duplicated task files into parameterized protocols + presets.
- IVSA-family tasks are currently inactive; keep as experimental (not in initial maintained set).
- Task-source precedence: runnable/sane first, newest commit date as tie-breaker.
- Runtime compatibility: keep an interactive compatibility layer during transition.
- Validation target: log parity and trial outcome parity, with seeded and distribution checks for random tasks.
- Add
users/namespace for user/project-specific configuration and metadata. - Keep
mouse_infoversioned in Git; keep per-session runtime files out of Git.
Current decision: one shared checkout per Pi.
Risk note: A single shared checkout is fragile when multiple users change branches on the same machine. It can still work if branch and release controls are strict.
Required controls for this model:
- Production runs always use a protected release tag or release branch (never a personal WIP branch).
- User branches are only used in scheduled debugging windows.
- Before task start, run a preflight command that prints branch/commit and requires explicit confirmation.
- Record branch and commit hash in each session artifact.
- Main task_protocol lineage (
main,charlie-irig,reorganization,luke_agent_test) with mostly equivalent maintained task layout. - Headfixed extension lineage (
headfixed_soyounk) adding headfixed variants and treadmill-related additions. - Go/no-go lineage (
go_nogo,go_nogo_temp_branch,benville_gonogo, plus Julia/Duy variant inrbb-lab). - Context-heavy lineage (
context,context_vis,context_video_stim, and broad experimental superset inmitchfarrell-context). - New model/presenter architecture lineage (
matt-behavior) with clearer separation of model and presenter. - IVSA-focused lineage (
juliabenville_CueIVSA) with active research code but currently out of immediate use.
For each protocol family:
- Prefer code that is runnable/sane (syntax-valid, coherent runtime path, no obvious breakage).
- If multiple options remain, pick newest commit date.
Initial structure for RPi4_behavior_tasks:
RPi4_behavior_tasks/
README.md
MIGRATION_PLAN.md
users/
julia_duy/
mouse_info/
session_templates/
presets/
wrappers/
matt_context/
mouse_info/
session_templates/
presets/
wrappers/
shared/
README.md
protocols/
gonogo/
model.py
runner.py
presets/
julia_duy_phaseX.yaml
training_phaseX.yaml
context/
model.py
presenter.py
runner.py
presets/
matt_default.yaml
matt_with_stimuli.yaml
experimental/
soyoun_treadmill/
ivsa/
runtime/
session_config.py
compatibility_layer.py
preflight.py
logging_schema.py
tests/
parity/
test_gonogo_parity.py
test_context_parity.py
smoke/
test_runner_smoke.py
Current branch history has many near-duplicate task scripts. Migration will:
- Keep one protocol implementation per task family.
- Move behavior differences to preset configuration files.
- Keep legacy naming as aliases during transition.
- Core runnable protocols remain in
protocols/and are the default maintained path. - User/project-specific files live under
users/<project_or_user>/. - User-owned protocol forks are allowed only when needed, under
users/<project_or_user>/wrappers/or a dedicated local protocol subpath, and should be treated as experimental until promoted. - Merge policy expectation: user branches should primarily touch their own
users/<...>/paths and only touch shared core with review.
Support both paths initially:
- Interactive prompts (
input) for users who rely on current flow. - Config/CLI execution for reproducible runs and automation.
Planned behavior:
- If CLI/config values are present, use non-interactive mode.
- If missing, fall back to interactive prompts.
Every run writes consistent metadata:
- Task family and preset name.
- Git branch and commit hash.
- Random seed (if used).
- Session start/end timestamps.
- Version in Git: protocol code, presets,
mouse_info, and session templates. - Do not version in Git: per-session generated session files, outputs, timestamps, and daily mutable runtime artifacts.
- Each run records which template and mouse record were used.
- Create core package layout (
protocols/,runtime/,tests/,users/). - Add common runner contract and session config schema.
- Add preflight command to print branch/commit and active preset.
- Add user/project folder conventions and template loaders.
Deliverable:
- Runnable skeleton with one no-op sample protocol.
- Select canonical go/no-go source files using runnable/sane then newest tie-breaker.
- Implement unified go/no-go protocol.
- Add presets and templates under
users/julia_duy/. - Keep legacy alias runner names mapping to presets.
Validation:
- Seeded parity test against selected reference behavior.
- Outcome distribution checks for non-seeded runs.
- Log schema parity against required fields.
- Port Matt context model/presenter style into cleaned protocol package.
- Extract context variants into presets and user templates under
users/matt_context/. - Ensure compatibility-layer execution path remains available.
Validation:
- Seeded trial-outcome parity where deterministic behavior is expected.
- Distribution checks for stochastic transitions.
- Log event parity for key state transitions and rewards.
- Add Soyoun treadmill lineage under
protocols/experimental/soyoun_treadmill. - Keep excluded from default maintained set until status is confirmed.
- Stage IVSA lineage under
protocols/experimental/ivsaonly (inactive).
Validation:
- Smoke tests only until protocol owners confirm target behavior.
- Add release tags and protected release branch policy.
- Add pre-run guardrails for shared-checkout mode.
- Add operator runbook for branch hygiene on shared Pis.
- Add contributor guidance for
users/ownership boundaries.
- Add optional strict release-tag guardrail for production runs.
- Add CI automation for smoke/parity test coverage.
- Document stricter shared-Pi production commands.
- Add runtime validation of run artifacts (metadata, events, results).
- Add a CLI verification tool for existing run directories.
- Add tests covering valid and invalid artifact structures.
- Add protocol-aware semantic quality checks across events and results.
- Write a
quality_report.jsonartifact per run. - Enforce quality failures as run failures unless explicitly disabled in debug mode.
- Define deterministic baseline cases across maintained and staged protocols.
- Add snapshot generation tooling for intentional baseline refreshes.
- Add regression tests that require exact snapshot matches.
Use fixed seeds and fixed presets to compare:
- Trial outcome sequence.
- Reward/no-reward decisions.
- Key state-transition event ordering.
For random tasks, compare distributions over repeated runs:
- Outcome rates (hit/miss/cr/fa) within tolerance windows.
- Reward probability and switch behavior within tolerance windows.
Not byte-for-byte matching. Compare required semantic fields:
- Session metadata fields.
- Transition and outcome event classes.
- Reward and punishment action records.
obsolete/directory content is excluded.- Broken or syntax-invalid files are excluded from maintained code paths unless repaired in a dedicated experimental track.
- IVSA is excluded from initial maintained rollout.
Mitigation:
- Require release-tag checkout for production sessions.
- Preflight prints branch/commit and requires operator confirmation.
- Save branch/commit in session metadata.
Mitigation:
- Use runnable/sane-first source-selection rubric.
- Document source commit per migrated protocol and preset.
Risk: hidden user workflow dependencies on interactive prompts
Mitigation:
- Preserve interactive path through compatibility layer.
- Add opt-in non-interactive mode without forcing immediate behavior change.
Mitigation:
- Keep shared protocols as primary maintained implementations.
- Treat user-local protocol overrides as experimental unless promoted.
- Periodically upstream stable user logic into
protocols/.
- Go/no-go and context families run end-to-end from
RPi4_behavior_tasks. - Required parity checks pass:
- seeded parity for deterministic checks,
- distribution parity for stochastic checks,
- required log-field parity.
obsolete/content excluded.- Soyoun treadmill and IVSA staged under experimental only.
- Shared-checkout preflight guardrails and runbook documented.
users/hierarchy active with Git-versionedmouse_infoand session templates.
- Implement Phase 0 skeleton in this repo.
- Port and validate go/no-go family (Julia/Duy path first).
- Port and validate Matt context family.
- Stage Soyoun treadmill and IVSA as experimental tracks.
- Add initial
users/julia_duy/andusers/matt_context/template folders.