Skip to content
This repository was archived by the owner on Nov 16, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,14 @@ compose.yaml Local Postgres + Kafka
## Docs

- [docs/](docs/) — planning pack and lab notes
- [Lab 48 planning pack index](docs/lab48/README.md) — every Lab 48 deliverable, file and status
- [Architecture](docs/architecture.md)
- [AI usage plan](docs/ai-usage-plan.md)
- [Environment strategy](docs/environment-strategy.md)
- [GitHub Actions plan](docs/github-actions-plan.md)
- [Terraform / Ansible plan](docs/terraform-ansible-plan.md)
- [Backlog](docs/backlog.md)
- [ADRs](docs/adrs/) · [NFRs](docs/nfrs.md) · [Risk register](docs/risk-register.md) · [Team roles](docs/team-roles.md)
- [Lab 49 backend notes](docs/lab49/README.md) · [Lab 50 frontend + persistence notes](docs/lab50/README.md)
- [Lab 51 CI/CD runbook](docs/capstone-cicd-runbook.md)
- [Lab 51 security and observability](docs/lab51/security-and-observability.md) — roles, endpoint matrix, negative tests, health
Expand Down
19 changes: 18 additions & 1 deletion defense/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Defense packet (Lab 52)

Placeholder for the Lab 52 demo and defense materials (slides, demo script, evidence index, Q&A, retrospective). Fill this folder during Lab 52 — linked from the root README so the path exists now.
Notes for the Thu/Fri Oct 22-23 defense. No PDF in this folder. Slides get built from `final-presentation-outline.md`.

| File | What it is |
| --- | --- |
| [evidence-index.md](evidence-index.md) | Claim to file, commit, run, or digest |
| [demo-script.md](demo-script.md) | ~11 min speaker / operator script |
| [demo-walkthrough.sh](demo-walkthrough.sh) | The demo curls with check marks. `bash defense/demo-walkthrough.sh` from the repo root |
| [technical-q-and-a.md](technical-q-and-a.md) | Short answers with evidence |
| [retrospective.md](retrospective.md) | Blameless retro, five actions |
| [self-assessment.md](self-assessment.md) | Outcome, evidence, status |
| [final-presentation-outline.md](final-presentation-outline.md) | 11 slides |
| [feedback-log.md](feedback-log.md) | Empty until the panel |
| [notes/demo-commands.md](notes/demo-commands.md) | Start the stack and every demo command by hand |
| [notes/demo-recording-guide.md](notes/demo-recording-guide.md) | How to record the backup video |
| [notes/walkthrough-run.txt](notes/walkthrough-run.txt) | Saved green run of the script, Oct 22 |
| [notes/](notes/) | How to start, fallback, failure runs, deploy gap |

Do not open `backend/src/main/resources/application-local.yml` on the projector. It has the local signing key.
58 changes: 58 additions & 0 deletions defense/demo-script.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Demo script — Northstar CRM

**Total:** about 11 minutes, plus questions after.
**Fixtures:** `CUS-1001` Amina Khan, `CUS-1002` Ravi Singh, correlation `lab-request-001`.
**Roles:** Speaker: TBD / Operator: TBD.
**Where:** UI http://localhost:4200 and API http://localhost:8081. Stack notes: `defense/notes/demo-validation.md`.

If the laptop API dies, say the failover line in `defense/notes/fallback-pack.md` and stop clicking.

## Pre-seed (before they walk in)

| # | Confirm | What we know |
| --- | --- | --- |
| 1 | Amina (`CUS-1001`) searchable | API GET returned Amina Khan, ACTIVE. UI search was not clicked in this session. |
| 2 | Ravi (`CUS-1002`) searchable | API GET returned Ravi Singh, PROSPECT. |
| 3 | Agent login works | Login as `agent` returned 200, `expiresIn` 900. Do not mint the token early. It dies in 15 minutes. Password is the local one in `README.md`. Do not put it on a slide. |
| 4 | Kafka console bookmarked | Command in `defense/notes/demo-validation.md`. Binary path checked on `crm-kafka`. |
| 5 | SQL ready | `docker exec crm-postgres psql -U crm -d crm` works. Query is in the validation notes. |
| 6 | Fallback pack open | `defense/notes/fallback-pack.md`. No screenshot folder. |

Also: the lookup list has two extra local customers (`CUS-1003`, `CUS-1004`). Search Amina. Do not scroll the full list on the projector.

Sign in as **agent** for the whole demo. The close button will be hidden. The 403 is a curl.

## Timed beats

From 5:15 to 9:15 the operator can run `bash defense/demo-walkthrough.sh` from the repo root instead of typing curls. It asks for the agent password (from `README.md`, it does not show), never prints the token, and puts a check mark on each step. Raw commands are in `defense/notes/demo-commands.md`. A saved green run is in `defense/notes/walkthrough-run.txt`.

| Time | Speaker | Operator | Evidence |
| --- | --- | --- | --- |
| 0:00 | Agents need one place to find a customer and write down the call. That is the slice. Success is CAP-12: save a note for Amina, keep it in Postgres, publish one event. | Show the home screen, or the title slide if the UI is not up yet. | E02, E01 |
| 0:45 | Angular talks to Spring. Spring checks the JWT, writes Postgres, then Kafka. We deploy image digests, not a rebuild. | If a diagram slide exists, leave it up. Otherwise stay on the sign-in page. | E01, E10, E12 |
| 1:20 | Sign in as the agent. The token stays in memory. A refresh logs you out. The page is not the security check. | Open http://localhost:4200/login. Username `agent`. Password from `README.md`. Click **Sign in**. Expect the header `agent (AGENT)` and the home heading "What would you like to do?" | E18, E21 |
| 2:20 | Look up Amina. She is the seeded active customer, `CUS-1001`. | Click **Look up a customer**. Search `Amina`. Click **Search**. Open **Profile** on the `CUS-1001` row. Expect name Amina Khan, id `CUS-1001`, status ACTIVE. | E04, E27 |
| 3:20 | An agent does not get a Close button. The line on the page is only a hint. The API is what blocks it. We will show the 403 at the end so we do not close Ravi by mistake. | Point at `Only an ADMIN can close a customer.` (`data-testid="close-requires-admin"`). Do not hunt for a button. | E19, E21 |
| 4:00 | Record a note. The app sends correlation `lab-request-001` on API calls. | Click **Record an interaction**. Type `NOTE` if it is not already selected. Summary: `Resolved login question`. Click create. Expect the detail page for a new id, customer `CUS-1001`. | E03, E09 |
| 5:15 | The row is in Postgres. That is the source of truth. | Script step 4 (steps 1-3 are health, seed rows, sign-in; press Enter through them). Or run the SQL in `demo-validation.md` for `lab-request-001`. Expect `CUS-1001`, `NOTE`, that correlation, visible true. | E04, E11 |
| 6:15 | After commit we publish `CustomerInteractionRecorded` on `crm.customer.interactions.v1`. The summary is not in the event. | In the backend terminal, find `Publishing` and `Applied` with `correlationId=lab-request-001`. If the terminal is not on screen, script step 5 runs the kafka-console-consumer. Point at `correlationId` and `customerId`. | E10, E09 |
| 7:15 | Bad input does not get a stack trace. It gets Problem Details. The form's dropdown cannot send a bad type, so this one is a curl. | Script step 6. It sends `POST /api/v1/interactions` type `TEXT`, header `X-Correlation-Id: lab-request-001`. Expect **400**, `detail` `Validation failed`, `errors` mentioning CALL, EMAIL, NOTE, or MEETING. | E05, `defense/notes/failure-experiments.md` |
| 8:15 | Same agent, close Ravi. The UI hid the button. The API still says no. | Script step 7. It sends `DELETE /api/v1/customers/CUS-1002` with the agent token and `X-Correlation-Id: lab-request-001`. Expect **403**, `detail` `Your role does not allow this action.`, and the correlation echoed. Then it reads Ravi back and shows `Ravi is still PROSPECT`. | E19, E20 |
| 9:15 | Optional if you are ahead: `CUS-9999` is not a customer. | Script step 8, `GET /api/v1/customers/CUS-9999`. Expect **404** `Unknown customer: CUS-9999`. Step 9 (fake token, **401**) follows. Skip both if you are past 9:30. | E02 |
| 9:30 | CI on main run 39777251733 (merge of PR #25, `ebda5ed`) passed. Frontend 56 tests, backend 99. Images were pushed by digest. Trivy wrote reports and did not fail the job. CodeQL passes on main now. | Open the Actions run. Read the two digest lines. Do not open a kubeconfig. | E23, E31, E35, E39 |
| 10:20 | We have not deployed. The class fixes are on `feature/k3s-class-deploy`, not main. Rollback is a new deploy of the previous digests, or `kubectl rollout undo` after a real rollout. Neither has been run. | Show `defense/notes/deployment-gap.md` or the rollback section of `docs/capstone-cicd-runbook.md`. | E06, E33, E37, E38 |
| 10:50 | What we can stand behind is the slice, the tests, and the digests. What we cannot stand behind is a running cluster. Next step is the student namespace, then smoke `CUS-1001`. | Stop. Leave the profile or the Actions tab up for questions. `unset TOKEN`. | E07, E08 |

## Controlled failure

The 8:15 beat is the one we keep if we have to cut. 403, correlation echoed, Ravi unchanged.

If that call fails because the API is down, read the saved 403 body in `defense/notes/walkthrough-run.txt` (step 7, Oct 22) or `defense/notes/failure-experiments.md` (Oct 21). Say it was captured on this laptop, not on the cluster.

## If you are long at 7:00

Drop the architecture sentence you already said, drop `CUS-9999`, and keep sign-in, Amina, the note, the 403, and the digest. Do not drop the 403.

## Close, if they ask "one more week"

Get the kubeconfig, deploy the class overlay, smoke CUS-1001, and only then practice rollback. Until that smoke line exists, the deploy slide stays a plan.
130 changes: 130 additions & 0 deletions defense/demo-walkthrough.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#!/usr/bin/env bash
# Northstar CRM demo walkthrough. Press Enter to move between steps.
# Usage, from the repo root: bash defense/demo-walkthrough.sh
# Run it AFTER you saved the note in the UI.
# Nothing here changes data except the 400/403 attempts, which the API rejects.

API="${API:-http://localhost:8081}"
CID="lab-request-001"
AUTO="${AUTO:-0}" # AUTO=1 skips the pauses (for testing)

bold=$(tput bold 2>/dev/null); dim=$(tput dim 2>/dev/null)
green=$(tput setaf 2 2>/dev/null); red=$(tput setaf 1 2>/dev/null)
blue=$(tput setaf 4 2>/dev/null); reset=$(tput sgr0 2>/dev/null)

step() { echo; echo "${bold}${blue}== $1 ==${reset}"; echo "$2"; }
show() { echo "${dim}\$ $1${reset}"; }
ok() { echo "${green}✔ $1${reset}"; }
bad() { echo "${red}✘ $1${reset}"; }
pause() { [ "$AUTO" = "1" ] && return; echo; read -r -p "${dim}Press Enter to continue...${reset}" _; }
pretty(){ python3 -m json.tool 2>/dev/null || cat; }
psqlq() { docker exec crm-postgres psql -U crm -d crm -At -c "$1"; }

# call METHOD PATH [JSON]: prints status + pretty body, sets $STATUS and $BODY
call() {
local method="$1" path="$2" data="$3"
local args=(-sS -o /tmp/demo_body.$$ -w '%{http_code}' -X "$method" "$API$path"
-H "X-Correlation-Id: $CID")
[ -n "$TOKEN" ] && args+=(-H "Authorization: Bearer $TOKEN")
[ -n "$data" ] && args+=(-H 'Content-Type: application/json' -d "$data")
STATUS=$(curl "${args[@]}")
BODY=$(cat /tmp/demo_body.$$); rm -f /tmp/demo_body.$$
echo "HTTP ${bold}$STATUS${reset}"
[ -n "$BODY" ] && echo "$BODY" | pretty
}

trap 'unset TOKEN' EXIT

# ---------------------------------------------------------------
step "1. Is the app up?" "Checking the API's readiness endpoint."
show "curl $API/actuator/health/readiness"
if curl -sS "$API/actuator/health/readiness" | grep -q '"UP"'; then
ok "API is up"
else
bad "API is not answering. Start the backend first (see defense/notes/demo-commands.md)."; exit 1
fi
pause

# ---------------------------------------------------------------
step "2. Our two test customers" "Amina should be ACTIVE, Ravi should be PROSPECT."
show "SELECT public_id, full_name, status FROM customer ..."
docker exec crm-postgres psql -U crm -d crm -c \
"SELECT public_id, full_name, status FROM customer WHERE public_id IN ('CUS-1001','CUS-1002') ORDER BY public_id;"
SEEDS=$(psqlq "SELECT string_agg(public_id || '=' || status, ',' ORDER BY public_id) FROM customer WHERE public_id IN ('CUS-1001','CUS-1002');")
[ "$SEEDS" = "CUS-1001=ACTIVE,CUS-1002=PROSPECT" ] && ok "Amina is ACTIVE, Ravi is PROSPECT" || bad "Seed rows look wrong: $SEEDS"
pause

# ---------------------------------------------------------------
step "3. Sign in as the agent" "The token stays in this shell only. It is never printed."
if [ -z "$DEMO_PASSWORD" ]; then
read -r -s -p "agent password: " DEMO_PASSWORD; echo
fi
show "POST $API/api/v1/auth/login (user: agent)"
TOKEN=$(curl -sS -X POST "$API/api/v1/auth/login" -H 'Content-Type: application/json' \
-d "{\"username\":\"agent\",\"password\":\"$DEMO_PASSWORD\"}" \
| python3 -c 'import json,sys; print(json.load(sys.stdin).get("accessToken",""))' 2>/dev/null)
unset DEMO_PASSWORD
if [ -n "$TOKEN" ]; then ok "Signed in as agent (token good for 15 minutes)"; else bad "Login failed"; exit 1; fi
pause

# ---------------------------------------------------------------
step "4. The note is in Postgres" "Postgres is the source of truth. Looking for correlation $CID."
show "SELECT ... FROM customer_interaction WHERE correlation_id = '$CID'"
docker exec crm-postgres psql -U crm -d crm -c \
"SELECT c.public_id, i.interaction_type, i.correlation_id, i.deleted_at IS NULL AS visible
FROM customer_interaction i JOIN customer c ON c.customer_id = i.customer_id
WHERE i.correlation_id = '$CID' ORDER BY i.created_at DESC LIMIT 3;"
NOTES=$(psqlq "SELECT count(*) FROM customer_interaction i JOIN customer c ON c.customer_id = i.customer_id
WHERE i.correlation_id = '$CID' AND c.public_id = 'CUS-1001' AND i.interaction_type = 'NOTE' AND i.deleted_at IS NULL;")
[ "${NOTES:-0}" -gt 0 ] && ok "Found a visible NOTE for CUS-1001" || bad "No visible NOTE for CUS-1001 yet. Save one in the UI first."
pause

# ---------------------------------------------------------------
step "5. The event went out on Kafka" "After the save, we publish CustomerInteractionRecorded. The summary is NOT in the event."
show "kafka-console-consumer --topic crm.customer.interactions.v1"
docker exec crm-kafka /opt/kafka/bin/kafka-console-consumer.sh \
--bootstrap-server localhost:9092 --topic crm.customer.interactions.v1 \
--from-beginning --timeout-ms 8000 2>/dev/null | grep "$CID" | grep 'CUS-1001' | tail -1 > /tmp/demo_event.$$
if [ -s /tmp/demo_event.$$ ]; then pretty < /tmp/demo_event.$$; ok "Event found for CUS-1001"; else bad "No event found for $CID"; fi
rm -f /tmp/demo_event.$$
pause

# ---------------------------------------------------------------
step "6. Bad input gets a clean error" "Sending a type of TEXT, which isn't allowed. Expect 400, not a stack trace."
show "POST $API/api/v1/interactions {interactionType: TEXT}"
call POST /api/v1/interactions \
"{\"customerId\":\"CUS-1001\",\"interactionType\":\"TEXT\",\"summary\":\"bad type\",\"correlationId\":\"$CID\"}"
[ "$STATUS" = "400" ] && ok "Rejected with 400" || bad "Expected 400, got $STATUS"
pause

# ---------------------------------------------------------------
step "7. An agent tries to close Ravi" "The UI already hides the Close button. This goes straight at the API. Expect 403."
show "DELETE $API/api/v1/customers/CUS-1002 (as agent)"
call DELETE /api/v1/customers/CUS-1002
[ "$STATUS" = "403" ] && ok "Blocked with 403" || bad "Expected 403, got $STATUS"
echo
echo "And Ravi didn't change:"
show "GET $API/api/v1/customers/CUS-1002"
call GET /api/v1/customers/CUS-1002 >/dev/null
RAVI=$(echo "$BODY" | python3 -c 'import json,sys; print(json.load(sys.stdin).get("status",""))' 2>/dev/null)
[ "$RAVI" = "PROSPECT" ] && ok "Ravi is still PROSPECT" || bad "Ravi status is '$RAVI'"
pause

# ---------------------------------------------------------------
step "8. Unknown customer" "Optional. Expect 404."
show "GET $API/api/v1/customers/CUS-9999"
call GET /api/v1/customers/CUS-9999
[ "$STATUS" = "404" ] && ok "404 as expected" || bad "Expected 404, got $STATUS"

pause

# ---------------------------------------------------------------
step "9. A fake token" "No real sign-in, no access. Expect 401."
show "GET $API/api/v1/customers/CUS-1001 (Authorization: Bearer not-a-real-jwt)"
REAL="$TOKEN"; TOKEN="not-a-real-jwt"
call GET /api/v1/customers/CUS-1001
TOKEN="$REAL"; unset REAL
[ "$STATUS" = "401" ] && ok "Rejected with 401" || bad "Expected 401, got $STATUS"

echo
ok "Demo done. Token cleared."
Loading
Loading