Skip to content

Commit b14b3cc

Browse files
committed
feat(demo): declare the demo staff so pnpm demo needs no hand-made accounts
The platform's `demoStaff` (@objectstack 18.2.0, objectstack#25777) creates the accounts an application declares on a local development boot, after the dev admin and before the seed runs. Ruling D on #28: the platform creates the demo accounts, the app only declares them. - objectstack.config.ts declares eleven demo accounts, gated on CLM_DEMO_SEED like the dataset: the three business requesters and two legal counsel by the same constants the fixture deals rows by, and one account for each of the other six positions. No password (the platform refuses one), no sys_user row in any fixture. - scripts/demo.mjs drops the closing operator note and the roster read behind it: no account is left for the operator to create. - README replaces the hand-made-accounts section with the declared staff, their sign-in addresses and the shared dev seed password. Setting a requester's manager stays a manual step: a demoStaff entry cannot carry one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017nzWFRUo2U7evMkPdVniAn
1 parent 2cbcb8b commit b14b3cc

3 files changed

Lines changed: 139 additions & 460 deletions

File tree

‎README.md‎

Lines changed: 71 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ pnpm demo:zh # the same rows, in Chinese
3636
else's contract book into a fresh deployment. `pnpm demo` is the opposite
3737
intention — a fictional multi-entity group, six months of negotiation and a
3838
book of contracts already in force, so every list has something on its first
39-
screen. Sign in with `admin@objectos.ai` / `admin123`.
39+
screen. Sign in with `admin@objectos.ai` / `admin123`, or as one of the
40+
[demo staff](#the-demo-staff--created-for-you) with the same password: a
41+
business requester such as `requester1@example.com` is an account whose 我的合同
42+
the demo fills.
4043

4144
`pnpm demo` also turns on the platform's scheduled work, which is off by
4245
default, so the daily reminder sweeps run on the demo book; a deployment that
@@ -74,51 +77,61 @@ rounds, obligations and payment instalments.
7477
Every date is relative to boot, so ten contracts always expire within the next
7578
thirty days and the arrears lists are always in arrears.
7679

77-
### Users are not seeded — create them, then assign these positions
78-
79-
A seed cannot create a user, so `pnpm demo` produces exactly one account. To see
80-
the permission model of [DESIGN.md](./DESIGN.md) §04 do anything, create
81-
accounts in **Setup → Users**, assign the seven positions, and give every business
82-
requester a manager ([below](#rung-1-of-the-approval-ladder-is-a-manager)):
83-
84-
| Position | How many | What it changes |
85-
|---|---|---|
86-
| `clm_legal_counsel` | 2 | Receives contracts on submission (round-robin by open load) and owns review. **Name these two exactly** — see below |
87-
| `clm_legal_head` | 1 | Rung 2 of the approval ladder whenever `route_legal_head` is stamped |
88-
| `clm_finance_controller` | 1 | Rung 2/3, reads every contract with `route_finance`, and the only position that may edit bank details |
89-
| `clm_executive` | 1 | Rung 4, and reads every contract with `route_executive` |
90-
| `clm_general_manager` | 1 | Rung 5, and reads every contract with `route_gm` |
91-
| `clm_records_manager` | 1 | Execution formalities, the executed copy and the archive number |
92-
| `clm_admin` | 1 | Maintains the configuration objects and holds full reach over every CLM object: the only position that may write `clm_contract_type` and `clm_approval_rule`, and the only one the app's **Administration** group is served to |
93-
94-
**Three more accounts are business requesters, which is not a position.**
95-
Every member of the organization holds `clm_requester` by default
96-
([DESIGN.md](./DESIGN.md) §04): it is the app's default permission set, bound
97-
to the platform's `everyone` anchor, so a requester needs no position and no
98-
grant — creating the account is the whole of it. They launch contracts and see
99-
their own. The seven positions above hold the same set the same way, on top of
100-
their own.
101-
102-
**Five of the accounts above have to be named exactly**, because the fixture
103-
references them by name:
104-
105-
| Name it exactly | Give it | It receives |
106-
|---|---|---|
107-
| `Business Requester 1` · `Business Requester 2` · `Business Requester 3` | nothing — every member already holds `clm_requester` | the 120 contracts' `owner_id`, dealt by counterparty — 43 / 43 / 34 · and the 143 delivery and reporting obligations under them — 50 / 53 / 40 |
108-
| `Legal Counsel 1` · `Legal Counsel 2` | the `clm_legal_counsel` position | the `legal_owner` of every contract legal has accepted — 34 / 34 · all 56 compliance obligations, by the same counterparty relationship — 29 / 27 · and the `decided_by` of all 17 decided deviations — 10 / 7 |
109-
110-
Each requester's **我的合同 › Launched by Me** and **› My Obligations**, and each
111-
lawyer's **法务工作台 › 审查中** and their own **My Obligations**, fill the moment
112-
the account exists; a decided deviation's **Decided By** shows its lawyer on the
113-
contract page's Deviations grid. All four columns are optional references, so
114-
naming an account that is not there yet costs nothing and no row: it simply
115-
stays empty.
116-
Every dataset is an upsert, so **create the accounts and run `pnpm demo` again**
117-
and their contracts and obligations are handed over. Get a name wrong by one
118-
character and the column stays empty with no error — that is the one thing to
119-
double-check in the names.
120-
121-
**Do that re-run before the daily jobs have run on the database.** Only a clean
80+
### The demo staff — created for you
81+
82+
The people the demo book is dealt to are declared in `objectstack.config.ts`
83+
(`demoStaff`), and the platform creates them on the demo boot — after the dev
84+
admin, before the seed runs — so every seeded row that names a person reaches
85+
them on the first `pnpm demo`, with no step of yours. They are the persona mix
86+
of [DESIGN.md](./DESIGN.md) §10: three business requesters and one account per
87+
position of §04, two for legal counsel.
88+
89+
Every one signs in with the development seed password, the dev admin's:
90+
`admin123` (or whatever `OS_SEED_ADMIN_PASSWORD` says when it is set). The
91+
console does not list them; this table is where they are named.
92+
93+
| Account | Sign in as | Position | What it holds in the demo |
94+
|---|---|---|---|
95+
| `Business Requester 1` · `2` · `3` | `requester1@example.com` · `requester2@example.com` · `requester3@example.com` | none — every member holds `clm_requester` | the 120 contracts' `owner_id`, dealt by counterparty — 43 / 43 / 34 · and the 143 delivery and reporting obligations under them — 50 / 53 / 40 |
96+
| `Legal Counsel 1` · `2` | `counsel1@example.com` · `counsel2@example.com` | `clm_legal_counsel` | receives contracts on submission (round-robin by open load) and owns review · the `legal_owner` of every contract legal has accepted — 34 / 34 · all 56 compliance obligations — 29 / 27 · the `decided_by` of all 17 decided deviations — 10 / 7 |
97+
| `Head of Legal` | `legal.head@example.com` | `clm_legal_head` | rung 2 of the approval ladder whenever `route_legal_head` is stamped |
98+
| `Finance Controller` | `finance@example.com` | `clm_finance_controller` | rung 2/3, reads every contract with `route_finance`, and the only position that may edit bank details |
99+
| `Executive` | `executive@example.com` | `clm_executive` | rung 4, and reads every contract with `route_executive` |
100+
| `General Manager` | `gm@example.com` | `clm_general_manager` | rung 5, and reads every contract with `route_gm` |
101+
| `Records Manager` | `records@example.com` | `clm_records_manager` | execution formalities, the executed copy and the archive number |
102+
| `CLM Administrator` | `clm.admin@example.com` | `clm_admin` | maintains the configuration objects and holds full reach over every CLM object: the only position that may write `clm_contract_type` and `clm_approval_rule`, and the only one the app's **Administration** group is served to |
103+
104+
A business requester is not a position. Every member of the organization holds
105+
`clm_requester` by default ([DESIGN.md](./DESIGN.md) §04): it is the app's
106+
default permission set, bound to the platform's `everyone` anchor, so a
107+
requester needs no position and no grant. They launch contracts and see their
108+
own. The seven positions hold the same set the same way, on top of their own.
109+
110+
Signed in, each requester lands on **我的合同 › 我发起的** (Launched by Me) with
111+
their contracts, and finds their obligations under **我负责的履约** (My
112+
Obligations); each lawyer lands on **法务工作台** and finds their contracts under
113+
**我的审查** (My Reviews); finance lands on **财务**, records on **执行与档案** and
114+
the CLM administrator on **管理**. A decided deviation's **Decided By** shows its
115+
lawyer on the contract page's Deviations grid.
116+
117+
Three things about where these accounts exist:
118+
119+
- **On a local development boot only.** `os dev` creates them; a production
120+
boot, a migration run or a server whose auth base URL is not a loopback
121+
address creates none and logs why. `os build` leaves the declaration out of
122+
the artifact, so no deployment boots with them. They are not seeded users:
123+
no fixture carries a `sys_user` row, and §10's 「用户不可种子」 stands.
124+
- **With the demo only.** The declaration is gated on `CLM_DEMO_SEED`, the
125+
switch that loads the dataset, so `pnpm dev` stays empty of people as well as
126+
of contracts: it signs in the dev admin and nobody else.
127+
- **Once.** Running `pnpm demo` again finds every address already there and
128+
leaves that account exactly as it is — name, password, manager — adding only
129+
a position it is missing. No account is duplicated.
130+
131+
Every dataset is an upsert, so `pnpm demo` also runs again on a database that
132+
already holds the demo, sliding every boot-relative date forward.
133+
134+
**Run it again only before the daily jobs have run on the database.** Only a clean
122135
database is guaranteed to come back as the known corpus: the fixture re-asserts
123136
every column it declares, the job-written ones included, so once rows have
124137
moved on — the jobs' work above all — a re-run does one of two things to each.
@@ -143,9 +156,6 @@ to tell" edge when there is none — the demo keeps exactly one unowned row, due
143156
seven days after boot, so that edge stays exercised. `src/data/plan-children.ts`
144157
proves it reachable and says why one is both the minimum and the maximum.
145158

146-
The other six positions are named however you like; they are reached through
147-
the position, not by name.
148-
149159
The dev admin is deliberately none of them. Like every member it holds
150160
`clm_requester`, so it sees 我的合同 and 分析 (`GET /api/v1/meta/app/clm` serves
151161
it exactly those two groups), but it holds no position and no other `clm_*` set:
@@ -156,24 +166,27 @@ the dev admin cannot open, and as a business owner or an obligation's owner it
156166
fills the setup account's 我的合同 instead of the requester's — and its
157167
reminders go to somebody who is not going to act on them.
158168

159-
`clm_review.reviewer` is the one reference that still **has to** name the dev
160-
admin: it is `required: true`, so a name that resolves to nothing takes the row
161-
with it, and the dev admin is the only account that exists while the seed runs.
162-
Reassign it once the real accounts are there.
169+
`clm_review.reviewer` is the one reference that still names the dev admin. It is
170+
`required: true`, so a name that resolves to nothing takes the row with it, and
171+
the fixture names the account `pnpm demo` makes sure of before anything is
172+
seeded. Reassign it if you want the reviews on a lawyer's desk.
163173

164174
### Rung 1 of the approval ladder is a manager
165175

166176
Every contract sent for approval opens on rung 1: the direct manager of the
167177
contract's **owner** — the business requester who launched it, not the lawyer
168178
who pressed **Send for Approval** — read from that account's
169179
`sys_user.manager_id`. No seed, position or permission set fills that column,
170-
so on an install set up from the tables above alone, no contract gets past
171-
rung 1.
180+
and neither do the demo staff: a `demoStaff` entry carries a position and
181+
permission sets and nothing else, so it cannot name a manager. On a fresh
182+
`pnpm demo` no requester has one, and no contract gets past rung 1 until you
183+
set it — the one step of the demo that is still yours.
172184

173185
Set it in **Setup → Users → the user → ⋯ → Set Manager**, for each of the three
174186
business requesters and for anyone else who launches contracts. Any other
175187
account in the organization will do — the persona mix has no line managers of
176-
its own, so point all three at one of the accounts above (the executive, say).
188+
its own, so point all three at one of the demo staff (`Executive`, say). A
189+
second `pnpm demo` leaves the manager you set where it is.
177190
The manager needs nothing more: `approve_contract`, the gate a rung acts
178191
through, is in `clm_requester`, which every account holds.
179192

@@ -216,7 +229,8 @@ it approves.
216229

217230
### Assigning a position from a script
218231

219-
Clicking through Setup → Users needs nothing more than the table above. Automating it does: the
232+
The demo staff get their positions from the platform. Staffing an organization of your own goes
233+
through Setup → Users, and automating that needs one more fact: the
220234
assignment binds by the position's **name**, not by its id. Read that off the declaration, not off
221235
the field name — `sys_user_position.position` is declared `text`, and its own description says what
222236
it carries: *"Position machine name (references `sys_position.name`)."* The field name tells you

‎objectstack.config.ts‎

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import { allHooks } from './src/objects/hooks.js';
44
import * as actions from './src/actions/index.js';
55
import { allFlows, flowFunctions } from './src/flows/index.js';
66
import * as profiles from './src/profiles/index.js';
7-
import { ClmPositions, ClmSharingRules } from './src/sharing/index.js';
8-
import { clmSeeds } from './src/data/index.js';
7+
import { CLM_POSITION, ClmPositions, ClmSharingRules } from './src/sharing/index.js';
8+
import { clmSeeds, demoSeedRequested } from './src/data/index.js';
9+
import { CONTRACT_OWNERS, LEGAL_OWNERS } from './src/data/keys.js';
910
import * as apps from './src/apps/index.js';
1011
import * as datasets from './src/datasets/index.js';
1112
import * as dashboards from './src/dashboards/index.js';
@@ -241,4 +242,54 @@ export default defineStack({
241242
// install somebody else's contract book into every fresh deployment.
242243
// `OS_SEED_LOCALE` chooses which language the fixture is written in.
243244
data: clmSeeds,
245+
246+
// The demo staff (DESIGN.md §10's persona mix, issue #28 ruling D): the
247+
// people the demo dataset is dealt to. The app only DECLARES them; the
248+
// platform creates them (`demoStaff`, @objectstack 18.2). On a local
249+
// development boot `os dev` signs each one up after the dev admin, assigns
250+
// its position in the Default Organization, and only then runs the seed, so
251+
// `owner_id: 'Business Requester 1'` resolves on the first `pnpm demo`.
252+
// Idempotent: an address that already has an account is left as it is and
253+
// only its missing assignments are added.
254+
//
255+
// This is not a seeded user (§10 「用户不可种子」 stands). Nothing here is a
256+
// `sys_user` row in `data`, and `os build` drops the key from the artifact,
257+
// so no deployment ever boots with these accounts. A non-development boot
258+
// creates nothing and says why.
259+
//
260+
// Gated on the same switch as `data`: the staff exist for the demo book, and
261+
// `pnpm dev` is deliberately empty. `pnpm demo` sets `CLM_DEMO_SEED` for the
262+
// boot that loads this file, so the declaration and the rows that name it
263+
// always arrive together.
264+
//
265+
// No password: every demo account signs in with the development seed
266+
// password (`os dev --admin-password`, default `admin123`) — the platform
267+
// refuses a `password` key, so no credential is committed here.
268+
//
269+
// - The business requesters and the two counsel are named by the SAME
270+
// constants the fixture deals rows by (`src/data/keys.ts`), so a name here
271+
// cannot drift from the `owner_id` / `legal_owner` / `owner` /
272+
// `decided_by` values that resolve against it. A requester holds no
273+
// position: `clm_requester` is every member's default set (`isDefault`).
274+
// - The other six positions are staffed once each, so every rung of the
275+
// approval ladder and every audience group of §05 has someone to sign in
276+
// as. The fixture names none of them; they are reached through the
277+
// position, not by name.
278+
//
279+
// ⚠️ A line manager cannot be declared: a `demoStaff` entry carries a
280+
// `position` and `permissionSets` and nothing else, and `sys_user.manager_id`
281+
// is an admin operation (README, "Rung 1 of the approval ladder is a
282+
// manager"). Setting the requesters' manager stays a manual Setup step.
283+
demoStaff: demoSeedRequested()
284+
? [
285+
...CONTRACT_OWNERS.map((name, i) => ({ name, email: `requester${i + 1}@example.com` })),
286+
...LEGAL_OWNERS.map((name, i) => ({ name, email: `counsel${i + 1}@example.com`, position: CLM_POSITION.legalCounsel })),
287+
{ name: 'Head of Legal', email: 'legal.head@example.com', position: CLM_POSITION.legalHead },
288+
{ name: 'Finance Controller', email: 'finance@example.com', position: CLM_POSITION.financeController },
289+
{ name: 'Executive', email: 'executive@example.com', position: CLM_POSITION.executive },
290+
{ name: 'General Manager', email: 'gm@example.com', position: CLM_POSITION.generalManager },
291+
{ name: 'Records Manager', email: 'records@example.com', position: CLM_POSITION.recordsManager },
292+
{ name: 'CLM Administrator', email: 'clm.admin@example.com', position: CLM_POSITION.admin },
293+
]
294+
: [],
244295
});

0 commit comments

Comments
 (0)