Files
co-lite/openspec/changes/add-company-scoping/tasks.md
T

6.8 KiB

Tasks

Design: design.md. All tasks run serially, ordered so that sign-in keeps working after each one. Every scoped endpoint gets a test where another company's record answers 404 (or is absent from the list).

1. Data

  • 1.1 SQL and local seed (design decisions 3, 7, 8 and 11).
    • Files in sql/:
      • 01-company-code-status.sql: add code and status; set company 1 to INS/ins; insert CV/cv.
      • 02-company-columns.sql: add company_id to event and email; set existing rows to company 1; move the interest unique key to (name).
      • 03-admin-login-names.sql: stop if any admin username contains @; set admin to company NULL; rewrite the other admin usernames to username@ins.
      • 99-rollback.sql.
    • Mirror them in local/seed/03-colite.sql, apply them locally, and confirm admin still signs in.
    • Scope: local/**, openspec/changes/add-company-scoping/sql/**
    • Verify: select shows the codes, the NULL-company admin, the rewritten usernames and the new columns.

2. Backend services

  • 2.1 services-system: companies, users and login security (decisions 1, 2, 3, 5 and 9).
    • Tests first:
      • company list, create, edit; duplicate code (ignoring case) refused; code format validated;
      • rename-code rewrites only that company's admin usernames, in one transaction;
      • user lookups return the company code and status;
      • the user search filters by company when given;
      • email uniqueness is per company;
      • role 1 cannot be saved on a user with a company;
      • login history and locked users filter by company, and NULL-company rows appear only for "all".
    • Scope: solvway-services-system/src/**
    • Verify: mvn -T 1C -B -q -pl solvway-services-system -am verify
  • 2.2 services-counter: events, leads, event leads and interests (decisions 6, 7 and 8).
    • Tests first:
      • an event is saved with its company and listed by company, or for all when none is given;
      • lead and event-lead lists accept "all companies";
      • detail lookups return the record's company;
      • interests are one list, unique by name ignoring case.
    • Scope: solvway-services-counter/src/**
    • Verify: mvn -T 1C -B -q -pl solvway-services-counter -am verify
  • 2.3 service-email and services-log (decisions 7 and 9).
    • Tests first:
      • an email saved with a company keeps it, and the email search filters by company;
      • the audit search filters by company, and NULL-company rows appear only for "all".
    • Scope: solvway-services-email/src/**, solvway-services-log/src/**
    • Verify: mvn -T 1C -B -q -pl solvway-services-email,solvway-services-log -am verify

3. mobile-api

  • 3.1 Sign-in, company scope and Companies API (decisions 1, 3, 4 and 5).
    • Tests first:
      • login and forgot-password build the login name from company and username; a blank company means a super admin;
      • a wrong company, an inactive company and an unknown user all give BAD_LOGIN;
      • the session guard ends an inactive company's sessions;
      • isSuper needs both no company and role 1;
      • scope ignores a staff request's company;
      • the Companies API is super admin only;
      • the login response carries the company and isSuper.
    • Scope: solvway-mobile-api/src/**
    • Verify: mvn -T 1C -B -q -pl solvway-mobile-api -am verify
  • 3.2 Users, roles, interests and login-security settings (decisions 1, 4 and 8).
    • Tests first:
      • users are listed, created and edited within the scope, and another company's user answers 404;
      • a username with @ is refused;
      • a super admin must choose a company or create a super admin;
      • role 1 is refused for company users;
      • role create, rename and grants, interest writes and lockout or password-rule changes answer 403 for company staff;
      • unlock works only within the caller's company.
    • Scope: solvway-mobile-api/src/**
    • Verify: mvn -T 1C -B -q -pl solvway-mobile-api -am verify
  • 3.3 Events, leads, event leads and exports (decision 6).
    • Tests first:
      • each list and export is limited to the scope;
      • another company's event, lead or event lead answers 404 on detail, edit, capture and export;
      • a super admin capture or event create without a company is refused;
      • the event team only offers users of the event's company.
    • Scope: solvway-mobile-api/src/**
    • Verify: mvn -T 1C -B -q -pl solvway-mobile-api -am verify
  • 3.4 Emails, login history and audit log (decisions 7 and 9).
    • Tests first:
      • each is limited to the scope;
      • emails for a user carry that user's company;
      • another company's email or audit event answers 404.
    • Scope: solvway-mobile-api/src/**
    • Verify: mvn -T 1C -B -q -pl solvway-mobile-api -am verify
    • Live check on the local stack:
      • INS and CV users each see only their own data;
      • admin sees both;
      • a CV record by id answers 404 to INS.

4. Portal

  • 4.1 Sign-in, session and Companies screen (decision 10).
    • Tests first:
      • the login and forgot-password pages send company, username and password, and a blank company is allowed;
      • the auth context holds isSuper and the company;
      • /companies lists, creates and edits companies, warns before a code change, and is refused for non-super users.
    • Scope: solvway-admin-portal/app/**
    • Verify: cd solvway-admin-portal && npx vitest run && npx tsc --noEmit && npm run lint && npm run build
  • 4.2 Company picker, Company column, company fields and super-admin-only screens (decision 10).
    • Tests first:
      • the picker is shown only to super admins and feeds the list queries;
      • the Company column appears for "All companies";
      • user, event and capture forms show Company for super admins only;
      • Roles, Interests and the Login security Settings tab are read-only or hidden for company staff.
    • Scope: solvway-admin-portal/app/**
    • Verify: cd solvway-admin-portal && npx vitest run && npx tsc --noEmit && npm run lint && npm run build

5. Check and docs

  • 5.1 Browser check and handover.
    • Playwright on the local stack:
      • admin creates CV users and a CV event, then switches the picker between all, INS and CV;
      • an INS user and a CV user with the same username each sign in with their company and see only their own leads, events, users, emails, login history and audit log;
      • an INS user opening a CV record by URL sees not-found;
      • renaming CV's code ends the CV user's session;
      • deactivating CV blocks its sign-in;
      • check at 1280 px and 360 px.
    • Docs, in docs/deployment.md:
      • section 3: the new SQL, and that it ends every session;
      • section 10: company sign-in and super admins.
    • Scope: docs/deployment.md
    • Verify: screenshots, and the steps above observed.

Workflow follow-up

  • Whole-branch review, with every /api/admin/** handler checked for scoping. Then push, PR to main and merge, and archive on its own branch.