Skip to content

Commit 84582ed

Browse files
Merge pull request #183 from ContextLab/feature/onboarding-bot
Add CDL onboarding Slack bot (#181)
2 parents b97bba3 + bd82bdb commit 84582ed

33 files changed

Lines changed: 8382 additions & 58 deletions

.gitignore

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,47 @@ html_test/
2828

2929
# Playwright MCP screenshots
3030
.playwright-mcp/
31+
32+
# CDL Onboarding Bot
33+
scripts/onboarding/.env
34+
scripts/onboarding/output/
35+
scripts/onboarding/*.json
36+
scripts/onboarding/secrets/
37+
scripts/onboarding/data/
38+
*.credentials.json
39+
service-account*.json
40+
google-credentials.json
41+
42+
# Python
43+
__pycache__/
44+
*.py[cod]
45+
*$py.class
46+
*.so
47+
.Python
48+
build/
49+
develop-eggs/
50+
dist/
51+
downloads/
52+
eggs/
53+
.eggs/
54+
lib/
55+
lib64/
56+
parts/
57+
sdist/
58+
var/
59+
wheels/
60+
*.egg-info/
61+
.installed.cfg
62+
*.egg
63+
.pytest_cache/
64+
.coverage
65+
htmlcov/
66+
67+
# Virtual environments
68+
venv/
69+
ENV/
70+
env/
71+
.venv/
72+
73+
# Claude session notes
74+
notes/

CLAUDE.md

Lines changed: 70 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,82 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
44

55
## Repository Overview
66

7-
This is the lab manual for the Contextual Dynamics Laboratory (CDL) at Dartmouth College. It's a LaTeX document using the Tufte-book class that describes lab policies, member responsibilities, and research approach.
7+
This is the lab manual for the Contextual Dynamics Laboratory (CDL) at Dartmouth College. It's a LaTeX document using the Tufte-book class that describes lab policies, member responsibilities, and research approach. The repo also contains a **Slack onboarding bot** (`scripts/onboarding/`) that automates member on/offboarding.
88

99
## Build Commands
1010

1111
**Compile the PDF:**
1212
```bash
1313
./compile.sh
1414
```
15+
Runs `latex` 5x (for cross-references/index), then `pdflatex`, and cleans up intermediate files. Requires a LaTeX distribution (`brew install --cask mactex` on macOS).
1516

16-
This runs `latex` multiple times (for cross-references and index), then `pdflatex`, and cleans up intermediate files. Requires a LaTeX distribution (e.g., `brew install --cask mactex` on macOS).
17+
**Run onboarding bot tests:**
18+
```bash
19+
# No API keys needed
20+
pytest tests/test_onboarding/test_models.py -v
21+
pytest tests/test_onboarding/test_image_service.py -v
22+
23+
# Requires GITHUB_TOKEN
24+
pytest tests/test_onboarding/test_github_service.py -v
25+
26+
# Requires ANTHROPIC_API_KEY
27+
pytest tests/test_onboarding/test_bio_service.py -v
28+
29+
# All tests
30+
pytest tests/test_onboarding/ -v
31+
```
32+
Tests use real API calls (no mocks). Tests skip automatically when credentials are missing.
1733

18-
**HTML version:** The HTML version is automatically generated via GitHub Actions when changes are pushed to master. No manual build is needed. The workflow uses make4ht (TeX4ht) with `tufte.cfg` configuration to convert to tufte-css styled HTML.
34+
**Run the onboarding bot:**
35+
```bash
36+
python -m scripts.onboarding.bot
37+
```
38+
Requires `.env` in `scripts/onboarding/` with Slack tokens, GitHub PAT, and optionally Google/Anthropic credentials.
1939

2040
## Project Structure
2141

22-
- `lab_manual.tex` - Main document source (single file containing all content)
23-
- `lab_manual.pdf` - Compiled output (committed to repo)
24-
- `tufte.cfg` - TeX4ht configuration for HTML generation
25-
- `tufte-book.cls`, `tufte-common.def`, `tufte-handout.cls` - Custom Tufte template files
26-
- `lab_logo/` - Lab logo images (PNG, PDF)
27-
- `resources/` - Additional resources (cheatsheets, cluster tutorials)
28-
- `.github/workflows/` - CI/CD workflows (LaTeX validation, HTML generation)
42+
- `lab_manual.tex` — Main document source (single file, all content)
43+
- `lab_manual.pdf` — Compiled output (committed to repo)
44+
- `compile.sh` — PDF build script
45+
- `tufte.cfg` — TeX4ht configuration for HTML generation
46+
- `tufte-book.cls`, `tufte-common.def` — Custom Tufte template files (do not modify casually)
47+
- `toc.js`, `checklist.js`, `lab-manual.css` — HTML version enhancements (TOC nav, interactive checklist, custom styling)
48+
- `scripts/onboarding/` — Slack onboarding bot (see architecture below)
49+
- `tests/test_onboarding/` — Bot tests (real API calls, no mocks)
50+
51+
### Onboarding Bot Architecture
52+
53+
```
54+
scripts/onboarding/
55+
├── bot.py # Entry point, Slack app setup
56+
├── config.py # Environment/config management
57+
├── handlers/
58+
│ ├── onboard.py # /cdl-onboard slash command
59+
│ ├── approval.py # Admin approval workflow (interactive messages)
60+
│ ├── offboard.py # /cdl-offboard slash command
61+
│ └── workflow_step.py # Slack Workflow Builder custom steps
62+
├── models/
63+
│ └── onboarding_request.py # Data models
64+
└── services/
65+
├── github_service.py # GitHub org invitations
66+
├── calendar_service.py # Google Calendar sharing
67+
├── image_service.py # Photo border processing (Pillow)
68+
└── bio_service.py # Bio editing via Claude API
69+
```
70+
71+
## CI/CD
72+
73+
- **`compile-latex.yml`** — On PRs touching `.tex` files: compiles LaTeX, posts error comment and closes PR on failure
74+
- **`build-html.yml`** — On push to `master`: converts LaTeX to HTML via tex4ht, deploys to GitHub Pages at `contextlab.github.io/lab-manual`
2975

3076
## LaTeX Conventions
3177

32-
The document uses several custom commands defined in `lab_manual.tex`:
33-
- `\marginnote{}` - For margin notes (TASK items and NOTEs)
34-
- `\newthought{}` - For section introductions
35-
- `\ourschool` - Expands to "Dartmouth College"
36-
- `\director`, `\coordinator` - Lab director references
78+
Custom commands in `lab_manual.tex`:
79+
- `\marginnote{}` — Margin notes (TASK items and NOTEs)
80+
- `\newthought{}` — Section introductions
81+
- `\ourschool` Expands to "Dartmouth College"
82+
- `\director`, `\coordinator` Lab director references
3783
- Links use `dartmouthgreen` color (RGB: 0, 105, 62)
3884

3985
## Workflow Notes
@@ -42,3 +88,12 @@ After editing `lab_manual.tex`:
4288
1. Run `./compile.sh` to regenerate the PDF
4389
2. Verify the PDF looks correct (check TOC links, margin notes positioning)
4490
3. Commit both the `.tex` source and updated `.pdf`
91+
92+
The HTML version is auto-generated by CI — no manual build needed.
93+
94+
## Key Gotchas
95+
96+
- `lab_manual.tex` is gitignored (the `.tex` line in `.gitignore`) — this is intentional to avoid accidental commits of intermediate build state. The file IS tracked by git despite the gitignore entry.
97+
- The CI will **close PRs** that fail LaTeX compilation — always test locally with `./compile.sh` first.
98+
- Onboarding bot credentials go in `scripts/onboarding/.env` (gitignored). Never commit tokens or service account JSON files.
99+
- Bot tests require running from the repo root so `scripts.onboarding` is importable as a package.

lab_manual.pdf

1.91 KB
Binary file not shown.

lab_manual.tex

Lines changed: 80 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163

164164
\newcommand{\director}{Jeremy}
165165
\newcommand{\coordinator}{\director}
166-
\newcommand{\meeting}{\href{https://context-lab.youcanbook.me}{YouCanBook.me}}
166+
\newcommand{\meeting}{\href{https://context-lab.com/scheduler}{context-lab.com/scheduler}}
167167

168168
\cleardoublepage
169169
\chapter{Introduction}\label{ch:intro} % Adding an asterisk leaves out this chapter from the table of contents
@@ -207,13 +207,7 @@ \chapter{Introduction}\label{ch:intro} % Adding an asterisk leaves out this chap
207207

208208
\newthought{What should you do if you don't understand something?}
209209

210-
\noindent \marginnote{\texttt{TASK:} If you haven't used \LaTeX~before
211-
(i.e., the document formatting language in which this manual is
212-
written), you'll want to
213-
\href{https://www.latex-project.org/get/}{download \LaTeX} and take
214-
a look at
215-
\href{https://www.latex-tutorial.com/tutorials/quick-start/}{this
216-
``quick start'' tutorial}.} If you don't understand something in
210+
\noindent If you don't understand something in
217211
this manual, \textit{ask another lab
218212
member for help}. Every member of the lab brings their own unique
219213
knowledge base, training, life experiences, and perspectives.
@@ -224,10 +218,14 @@ \chapter{Introduction}\label{ch:intro} % Adding an asterisk leaves out this chap
224218
inconsistency!
225219

226220
\marginnote{\texttt{TASK:} When you are done reading this manual and
227-
carrying out all required tasks, please fill out the signature page,
228-
sign it (electronically), and email a PDF (of just the signature
229-
page) to
230-
\href{mailto:contextualdynamics@gmail.com}{contextualdynamics@gmail.com}.
221+
carrying out all required tasks, please complete the checklist and
222+
signature page. You can either (a) fill out the signature page in
223+
this PDF, sign it electronically, and email a PDF (of just the
224+
signature page) to
225+
\href{mailto:contextualdynamics@gmail.com}{contextualdynamics@gmail.com},
226+
or (b) use the
227+
\href{https://context-lab.com/lab-manual/\#checklist-and-signature-page}{checklist
228+
and signature page in the HTML version} of the lab manual.
231229
\textbf{You are officially a lab member once you have completed all
232230
tasks in this manual and receipt of your signed and filled-out
233231
signature page and checklist has been acknowledged by \director.}}
@@ -507,11 +505,11 @@ \chapter{Official lab practices and policies}\label{ch:policy}
507505
coordination between project team members.
508506

509507
\item At regular intervals, the team reflects on how to become more effective,
510-
then tunes and adjusts its behavior accordingly. At minimum, all active lab
511-
members need to reflect on their projects once each week in your \textit{Weekly
512-
Snippet} (defined below). You should also schedule regular meetings with your
508+
then tunes and adjusts its behavior accordingly. All active lab
509+
members are encouraged to reflect on their projects once each week (e.g., via the optional \textit{Weekly
510+
Snippet}, defined below). You should also schedule regular meetings with your
513511
project team and/or~\director~(via~\meeting) to discuss progress, goals,
514-
roadblocks, and project logistics.
512+
roadblocks, and project logistics.
515513

516514
\end{enumerate}
517515

@@ -786,8 +784,8 @@ \subsection{Authorship guidelines}
786784
Attendees: all interested lab and non-lab Dartmouth community
787785
members.
788786

789-
\item \textbf{Weekly snippets.} Each week, all
790-
paid employees must fill out a ``weekly snippet''
787+
\item \textbf{Weekly snippets.} All lab members are
788+
encouraged (but not required) to fill out a ``weekly snippet''
791789
with brief answers to the following questions:
792790
\begin{enumerate}
793791
\item What did you work on over this past week?
@@ -796,19 +794,14 @@ \subsection{Authorship guidelines}
796794
\item Anything else you'd like to add?
797795
\end{enumerate}
798796

799-
Reminders to fill out your weekly snippet are automatically sent out (via
800-
Slack) each Monday at 9 AM. Weekly snippets are required for all paid
801-
employees and optional for all other lab members. If you are an unpaid
802-
employee but may request a letter of recommendation, weekly snippets
803-
help me maintain a sense of what you are working on
804-
and how you are progressing over time. I'll also refer to
805-
your snippets during check-in meetings (e.g., to discuss project progress,
797+
Weekly snippets help \director~maintain a sense of what you are working on
798+
and how you are progressing over time. They are also referred to
799+
during check-in meetings (e.g., to discuss project progress,
806800
contributions, letters of recommendation, annual reviews, etc.).
807801
Submit your snippet using the ``Fill out your snippet!''
808802
workflow on Slack, accessible via the Workflows menu in the \texttt{\#general}
809803
channel (usually near the top left of the window).
810-
Participants: all paid lab members and any other lab members who want to
811-
participate.
804+
Participants: any lab members who want to participate.
812805
\end{itemize}
813806

814807
%\newpage
@@ -828,7 +821,7 @@ \subsection{Authorship guidelines}
828821
an interface for asking questions, storing notes, and sharing
829822
ideas. If you have a~\ourschool~NetID you should be able to join the workspace by clicking the link.
830823
If you do \textit{not} have a NetID, you'll need to \href{https://services.dartmouth.edu/TDClient/1806/Portal/Requests/ServiceDet?ID=30581}{request one here}.
831-
\marginnote{\texttt{TASK:} When you join our Slack workspace, initiate our onboarding process using the ``Join the lab!'' workflow. You can access this workflow in the \texttt{\#general} channel
824+
\marginnote{\texttt{TASK:} When you join our Slack workspace, initiate our onboarding process using the \href{https://slack.com/shortcuts/Ft07ESC6CP3J/b1531b6fe100db8522fbd05c6a49ef63}{``Join the lab!'' workflow}. You can also access this workflow in the \texttt{\#general} channel
832825
through the Workflows menu (usually near the top left of the window). Once you initiate the workflow, you'll be guided through the onboarding process.}
833826

834827
\item \href{https://www.github.com}{\textbf{GitHub.}}
@@ -866,6 +859,38 @@ \subsection{Authorship guidelines}
866859
feel you don't have the appropriate account type, please communicate
867860
your concerns to \director.
868861

862+
\newthought{Onboarding and offboarding}
863+
\label{sec:onboarding}
864+
865+
\noindent The lab uses an automated onboarding system to help new members get set up quickly and consistently. When you initiate the ``Join the lab!'' workflow in Slack, you'll be asked to provide:
866+
\begin{itemize}
867+
\item Your GitHub username
868+
\item Your email address (preferably Gmail or Dartmouth)
869+
\item Your preferred name for the lab website
870+
\item A short bio (2--3 sentences about yourself and your research interests)
871+
\item A link to your personal website (optional)
872+
\end{itemize}
873+
874+
\marginnote{\texttt{NOTE:} After submitting the workflow, please also send a profile photo to \director~via Slack DM. Once approved, your photo and bio will be added to the lab website.}
875+
876+
Once you submit this information, \director~will review your submission and approve your onboarding. The system will then automatically:
877+
\begin{itemize}
878+
\item Send you an invitation to the \href{https://github.com/ContextLab}{ContextLab GitHub organization}
879+
\item Grant you access to the lab's Google Calendars (Contextual Dynamics Lab, Out of lab, and CDL Resources)
880+
\item Add your profile to the \href{https://contextlab.github.io}{lab website} via a pull request
881+
\item Update the lab's internal records
882+
\end{itemize}
883+
884+
You will receive notifications in Slack as each step completes. If any issues arise during the process, \director~will reach out to help resolve them.
885+
886+
\textbf{When leaving the lab,} please notify \director~in advance via Slack to initiate the offboarding process. The offboarding process will:
887+
\begin{itemize}
888+
\item Move your profile to the alumni section of the lab website
889+
\item Revoke access to GitHub repositories and calendars (as appropriate)
890+
\item Update lab records
891+
\end{itemize}
892+
You may be asked to provide your current position and institution URL for the alumni listing.
893+
869894
\newthought{Setting up your development environment}
870895
\label{sec:dev-environment}
871896

@@ -1212,7 +1237,7 @@ \subsection{Authorship guidelines}
12121237
When2Meet is best for selecting a specific time from a
12131238
small number of dates. \meeting~is used to sign up
12141239
for meeting slots with \director. You can book a meeting in a free
1215-
slot through YouCanBook.Me at any time.
1240+
slot at any time.
12161241
\end{itemize}
12171242

12181243
\newthought{Attendance policy}
@@ -1557,6 +1582,8 @@ \subsection{Repository of shared lab papers and books}
15571582
you may be required to withdraw your submission and/or cover any
15581583
conference-related expenses that you incurred, at \director's
15591584
discretion.} The preferred methods for creating posters are to use
1585+
\href{https://github.com/ContextLab/cdl-slides}{cdl-slides} (our
1586+
custom tool for creating posters from Markdown files),
15601587
\href{https://github.com/deselaers/latex-beamerposter}{LaTeX
15611588
BeamerPoster}, Adobe Illustrator, or
15621589
\href{https://inkscape.org/en/}{Inkscape}. The lab has several
@@ -1765,6 +1792,14 @@ \chapter{Internal Review Board (IRB) approvals}\label{ch:irb}
17651792
\item \textbf{Network dynamics in human epilepsy (STUDY00029400).}
17661793
Hospital protocol used for studying network dynamics inferred
17671794
via electrocorticographic activity in epilepsy patients.
1795+
\item \textbf{Decision Making (STUDY00033619).} Used to study
1796+
how decisions and moral judgements are impacted by group
1797+
dynamics. Behavior only.
1798+
\item \textbf{Self-Concept and Misperceptions (STUDY00033592).}
1799+
Study beliefs about the self and others. Behavior only.
1800+
\item \textbf{CalmNight Nightmare Monitoring and Intervention
1801+
Study (STUDY00033484).} Study and treat nightmares using the
1802+
FRENZ EEG headband. Used for at-home sleep studies.
17681803
\item \textbf{Perceptual and Memory Dynamics (STUDY00031514).}
17691804
Used for studies investigating the relationship between
17701805
perceptual and memory metrics and symptoms associated with
@@ -1863,6 +1898,11 @@ \subsection{Current lab members}\label{sec:curr_members}
18631898
\item Andrew Richardson (2025 -- )
18641899
\item Keene Dampal (2025 -- )
18651900
\item Kevin Chang (2025 -- )
1901+
\item Theo Larson (2025 -- )
1902+
\item Jason Kang (2025 -- )
1903+
\item Sam Haskel (2025 -- )
1904+
\item Mak Kelly (2026 -- )
1905+
\item Hye-Sung Kim (2026 -- )
18661906
\end{list}
18671907
\end{multicols}
18681908

@@ -2005,15 +2045,8 @@ \chapter{Checklist and signature page}
20052045
\item I have created a GitHub account and have been added to the appropriate lab
20062046
GitHub group(s). If I am unfamiliar with Git, I have gone through
20072047
the GitHub tutorials.
2008-
\item I am proficient in \LaTeX, allowing me to edit and understand
2009-
this lab manual's source code.
2010-
\item I have submitted a pull request to the
2011-
\href{https://github.com/ContextLab/lab-manual}{GitHub repository}
2012-
that adds my name to the \hyperref[sec:curr_members]{lab members}
2013-
section, along with any other updates I think would be helpful. I
2014-
have also recompiled the PDF of the lab manual by running
2015-
\texttt{pdflatex} \textbf{twice}, and have ensured that (a) the PDF compiled
2016-
without errors, and (b) the table of contents was generated correctly.
2048+
\item I have verified that my name appears in the
2049+
\hyperref[sec:curr_members]{lab members} section of this manual.
20172050
\item I have run the CDL setup script (described in the
20182051
\hyperref[sec:dev-environment]{Setting up your development environment}
20192052
section) and verified that my development environment is correctly
@@ -2041,7 +2074,7 @@ \chapter{Checklist and signature page}
20412074
\item I agree to regularly attend lab meetings (unless I have a
20422075
course conflict and have informed \director).
20432076
\item I agree to send \director~regular updates regarding my
2044-
progress and work, including weekly snippets, meetings, Slack
2077+
progress and work, including meetings, Slack
20452078
discussions, and/or GitHub updates.
20462079
\item If/when I decide to end my affiliation with the lab, I
20472080
will notify \director~and any project members affected by my departure. I will also coordinate with
@@ -2062,10 +2095,14 @@ \chapter{Checklist and signature page}
20622095
\item I have carefully read through the entire lab manual, and I
20632096
have checked off all of the above items to indicate that I have
20642097
carried out the indicated tasks.
2065-
\item I will send a digital copy (PDF) of the final two pages of
2066-
this manual, including checked-off list items, my digital
2067-
signature, and today's date, to
2068-
\href{mailto:contextualdynamics@gmail.com}{contextualdynamics@gmail.com}.
2098+
\item I will complete and sign this checklist by either (a) sending
2099+
a digital copy (PDF) of the final two pages of this manual,
2100+
including checked-off list items, my digital signature, and
2101+
today's date, to
2102+
\href{mailto:contextualdynamics@gmail.com}{contextualdynamics@gmail.com},
2103+
or (b) using the
2104+
\href{https://context-lab.com/lab-manual/\#checklist-and-signature-page}{online
2105+
checklist and signature page}.
20692106
\end{todolist}
20702107

20712108
\vspace{0.25in}

0 commit comments

Comments
 (0)