Skip to content

Commit 096b2dc

Browse files
committed
Merge origin/main into claude/issue-19-seed-files
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017nzWFRUo2U7evMkPdVniAn
2 parents e05d198 + 6abe6a0 commit 096b2dc

18 files changed

Lines changed: 363 additions & 147 deletions

‎objectstack.config.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ export default defineStack({
203203
positions: ClmPositions,
204204
permissions: Object.values(profiles),
205205

206-
// The eleven authorization tokens the five permission sets grant in
206+
// The twelve authorization tokens the five permission sets grant in
207207
// `systemPermissions` (ADR-0066 D1) — this app DEFINES them; it is not a
208208
// `requires:` service and adds no plugin. Two reasons to declare rather than
209209
// let the platform derive them from the sets:
@@ -232,7 +232,8 @@ export default defineStack({
232232
{ name: 'clm_records.access', scope: 'org', label: 'CLM: Records', description: 'Serves the Records group of the CLM app.' },
233233
{ name: 'clm_admin.access', scope: 'org', label: 'CLM: Administration', description: 'Serves the Administration group of the CLM app.' },
234234
{ name: 'approve_contract', scope: 'org', label: 'Approve contracts', description: 'DESIGN.md §04 action gate for the approval ladder; which request a holder decides is the approval flow\'s assignment.' },
235-
{ name: 'execute_contract', scope: 'org', label: 'Execute contracts', description: 'DESIGN.md §04 action gate for signing, activation and backfill of executed contracts.' },
235+
{ name: 'execute_contract', scope: 'org', label: 'Execute contracts', description: 'DESIGN.md §04 action gate for signing and activation.' },
236+
{ name: 'backfill_contract', scope: 'org', label: 'Backfill contracts', description: 'DESIGN.md §04 gate for F16: recording a contract executed outside this system. Held by records, legal and admin; gates the backfill action and its flow.' },
236237
{ name: 'archive_contract', scope: 'org', label: 'Archive contracts', description: 'DESIGN.md §04 action gate for archiving.' },
237238
{ name: 'terminate_contract', scope: 'org', label: 'Terminate contracts', description: 'DESIGN.md §04 action gate for ending a contract in force.' },
238239
{ name: 'manage_clauses', scope: 'org', label: 'Manage clauses', description: 'DESIGN.md §04 action gate for the clause playbook.' },

‎src/actions/contract-backfill.actions.ts‎

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,41 @@ import type { Action } from '@objectstack/spec/ui';
1010
* CREATES a contract, and it creates it born `active`, which
1111
* `contract_type_stamp` refuses for anything but a system write ("A contract
1212
* is created as a draft, not as active"). `executed_upload` is that system
13-
* write — a flow with `runAs: 'system'` — and this action is its door. The
14-
* caller's identity still rides through the elevation, so `created_by` names
15-
* the person who backfilled and the row lands in their organization.
13+
* write — a `screen` flow with `runAs: 'system'` — and this action is its
14+
* door. The caller's identity still rides through the elevation, so
15+
* `created_by` names the person who backfilled and the row lands in their
16+
* organization.
1617
*
1718
* `list_toolbar` only, like `launch_contract`: the action makes a record, so
1819
* it has no record to sit on, and declaring a record-scoped location would
1920
* make the console demand a selected row first.
2021
*
21-
* ## The gate, and the half of it this platform cannot express
22+
* ## The gate: `backfill_contract`
2223
*
23-
* §06 F16 says "仅 `clm_records.access` 与 `clm_legal.access` 可用" — records
24-
* OR legal. `requiredPermissions` is an AND: the runtime refuses unless the
25-
* caller holds EVERY capability listed
26-
* (`missing = required.filter(p => !held.has(p))`), and no capability is held
27-
* by both `clm_records` and `clm_legal` today. So the declaration below gates
28-
* on `execute_contract`, the §04 capability for the execution lane — held by
29-
* `clm_records` and `clm_admin` — which delivers the records half of the rule
30-
* exactly and leaves the legal half out. The legal counsel keeps every other
31-
* path (§04 grants `clm_legal` RCU on `clm_contract`); what they lose is this
32-
* button.
24+
* §06 F16 says the records manager OR legal may backfill. The gate is one
25+
* capability both hold rather than an OR of two: `backfill_contract`, granted
26+
* by `clm_records`, `clm_legal` and `clm_admin` (§04; issue #43, ruling A —
27+
* backfilling and registering an execution are two business acts, so the
28+
* backfill gets its own name instead of borrowing `execute_contract`).
3329
*
34-
* That gap is REPORTED, not papered over: closing it needs either a new §04
35-
* capability granted to both sets (a governed-surface decision, not a
36-
* developer's) or an OR-form gate on the platform. Gating on `visible` instead
37-
* would hide the button without stopping the request, which is the thing the
38-
* spec's own guidance calls out — "hiding is not gating".
30+
* It is declared twice, on purpose, with the same list. The flow's
31+
* `requiredPermissions` is the gate: every door that starts the flow by name
32+
* (this action over REST and MCP, the trigger route) refuses a caller without
33+
* it, `403 PERMISSION_DENIED`, before anything runs. The action repeats it
34+
* because only the action's OWN list hides the button: the console's action
35+
* strip and MCP `list_actions` read the action, not the flow it starts
36+
* (objectstack#25643). Hiding is not gating — the flow's list is what stops
37+
* the request — but without the repeat every member would see a button that
38+
* answers 403.
39+
*
40+
* ## The business owner is asked, not assumed
41+
*
42+
* `owner_id` is a required param (issue #99, item 7): whoever types a legacy
43+
* contract in is rarely the requester who owns it on the business side, and
44+
* the owner is who §04 widens rows to (the private OWD, 我的合同, rung 1's
45+
* manager). The platform stamps the acting user only on an insert that leaves
46+
* `owner_id` empty, so the value given here is the one stored. `legal_owner`
47+
* is a different field (§03) and is not asked here.
3948
*/
4049
export const ExecutedUploadAction: Action = {
4150
name: 'executed_upload',
@@ -47,7 +56,8 @@ export const ExecutedUploadAction: Action = {
4756
locations: ['list_toolbar'],
4857
// The flow inserts the row straight into `active` with `is_backfilled: true`.
4958
description: 'Record a contract that was signed before this system, or outside it. It is created directly as active and marked as backfilled, skipping review and approval, and the executed copy is filed as its final signed version.',
50-
requiredPermissions: ['execute_contract'],
59+
// The same list as the flow's (see the header): this copy hides the button.
60+
requiredPermissions: ['backfill_contract'],
5161
params: [
5262
// Field-backed where a picker is wanted: the param inherits the field's
5363
// type, its label and its `lookupFilters`, so inactive types, blocked
@@ -57,6 +67,8 @@ export const ExecutedUploadAction: Action = {
5767
{ field: 'contract_type', required: true, helpText: 'The workflow this contract would have run. It still stamps the number, the category and the execution formalities.' },
5868
{ field: 'party', required: true, helpText: 'The counterparty on the executed document.' },
5969
{ field: 'title', required: true },
70+
// Who owns the contract on the business side; the flow writes it as given.
71+
{ field: 'owner_id', required: true, helpText: 'The requester who owns this contract on the business side. It is stored as given: the person recording the backfill is not assumed to be the owner.' },
6072
// `signed_date` becomes both `signed_at` and `executed_at`; `executed_file`
6173
// is filed as version 1 with `kind: 'final_signed'` (executed-upload.flow.ts).
6274
{ name: 'signed_date', type: 'date', label: 'Signed On', required: true, helpText: 'The date on the executed document. It is recorded as both the signed date and the execution date.' },

‎src/actions/contract-lifecycle.actions.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,12 @@ export const TerminateContractAction: Action = {
341341
* covers the ordinary case (the F12 sweep flags `is_expiring` and the
342342
* notification points here) and `expired` covers the one that ran out before
343343
* anyone acted.
344+
*
345+
* Once the run completes, the console takes the user to the draft it made
346+
* (#99 item 3; a flow action's `onSuccess`, objectstack#25800, 18.2.0):
347+
* `${result.output.renewal.id}` reads the flow's `renewal` output variable,
348+
* the record `create_draft` wrote. A refused run (a second press) shows its
349+
* sentence and does not move.
344350
*/
345351
export const StartRenewalAction: Action = {
346352
name: 'start_renewal',
@@ -353,5 +359,6 @@ export const StartRenewalAction: Action = {
353359
locations: ['record_header'],
354360
visible: P`record.status == 'active' || record.status == 'expired'`,
355361
successMessage: 'Renewal draft created.',
362+
onSuccess: { navigate: '/apps/clm/clm_contract/record/${result.output.renewal.id}' },
356363
refreshAfter: true,
357364
};

‎src/email-templates/index.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { RenewalNoticeDueTemplates } from './renewal-notice.email-template.js';
55
import { ContractAutoRenewedTemplates, ContractExpiredTemplates } from './expiration-sweep.email-template.js';
66
import { LegalReviewOver30DaysTemplates, LegalReviewOver60DaysTemplates } from './legal-review-sla.email-template.js';
77
import { TurnStalledTemplates } from './turn-stalled.email-template.js';
8+
import { ObligationDueSoonTemplates, ObligationDueTodayTemplates, ObligationOverdueTemplates } from './obligation-due.email-template.js';
9+
import { PaymentOverdueTemplates } from './payment-overdue.email-template.js';
810

911
/**
1012
* Every notification this app sends itself, one `email_template` bundle each
@@ -22,4 +24,8 @@ export const allEmailTemplates: EmailTemplateDefinition[] = [
2224
...LegalReviewOver30DaysTemplates,
2325
...LegalReviewOver60DaysTemplates,
2426
...TurnStalledTemplates,
27+
...ObligationDueSoonTemplates,
28+
...ObligationDueTodayTemplates,
29+
...ObligationOverdueTemplates,
30+
...PaymentOverdueTemplates,
2531
];
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { noticeBundle } from './_bundle.js';
2+
3+
/** F10 `obligation_due`: an open obligation seven days out, due today, or past due. Sent to the obligation owner. */
4+
5+
const VARIABLES = [
6+
{ name: 'title', description: 'The obligation title.' },
7+
{ name: 'due_date', description: 'The obligation due date.' },
8+
];
9+
10+
export const ObligationDueSoonTemplates = noticeBundle({
11+
name: 'clm.obligation_due_soon',
12+
description: 'F10: an open obligation falls due in seven days. Sent to the obligation owner.',
13+
variables: VARIABLES,
14+
en: {
15+
label: 'Obligation due in 7 days',
16+
subject: 'Due in 7 days: {{ title }}',
17+
body: 'This contract obligation is due on {{ due_date }}. Record progress, or mark it done once it is performed.',
18+
},
19+
zhCN: {
20+
label: '履约义务 7 天后到期',
21+
subject: '7 天后到期:{{ title }}',
22+
body: '这项合同履约义务将于 {{ due_date }} 到期。请记录进展,履行后把它标记为已完成。',
23+
},
24+
});
25+
26+
export const ObligationDueTodayTemplates = noticeBundle({
27+
name: 'clm.obligation_due_today',
28+
description: 'F10: an open obligation falls due today. Sent to the obligation owner.',
29+
variables: VARIABLES,
30+
en: {
31+
label: 'Obligation due today',
32+
subject: 'Due today: {{ title }}',
33+
body: 'This contract obligation is due today ({{ due_date }}). It moves into overdue tomorrow if it is not done or waived.',
34+
},
35+
zhCN: {
36+
label: '履约义务今天到期',
37+
subject: '今天到期:{{ title }}',
38+
body: '这项合同履约义务今天({{ due_date }})到期。如果今天没有完成或豁免,明天会转为已逾期。',
39+
},
40+
});
41+
42+
export const ObligationOverdueTemplates = noticeBundle({
43+
name: 'clm.obligation_overdue',
44+
description: 'F10: an open obligation passed its due date and was marked overdue. Sent to the obligation owner.',
45+
variables: VARIABLES,
46+
en: {
47+
label: 'Obligation overdue',
48+
subject: 'Overdue: {{ title }}',
49+
body: 'This contract obligation was due on {{ due_date }} and is now overdue. Perform it and mark it done, or ask legal to waive it.',
50+
},
51+
zhCN: {
52+
label: '履约义务已逾期',
53+
subject: '已逾期:{{ title }}',
54+
body: '这项合同履约义务应于 {{ due_date }} 完成,现已逾期。请履行后把它标记为已完成,或请法务豁免。',
55+
},
56+
});
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { noticeBundle } from './_bundle.js';
2+
3+
/**
4+
* F11 `payment_overdue`: an unpaid instalment past its planned date.
5+
*
6+
* `actual_amount` is null on an instalment that went from due to overdue with
7+
* nothing received, and a bare hole renders null as nothing ("received so far
8+
* ."). The mail renderer has no conditional to drop the clause, but its
9+
* `default` formatter fills an empty value, so the hole reads 0 there: nothing
10+
* received is exactly what null means on this column. Amounts stay bare
11+
* numbers: the `currency` formatter takes its ISO code as a literal in the
12+
* template, and this bundle serves every contract currency.
13+
*/
14+
15+
export const PaymentOverdueTemplates = noticeBundle({
16+
name: 'clm.payment_overdue',
17+
description: 'F11: an instalment that is not settled passed its planned date and was marked overdue. Sent to the contract owner and the finance controllers.',
18+
variables: [
19+
{ name: 'seq', description: 'The instalment number within the schedule.' },
20+
{ name: 'title', description: 'The contract title.' },
21+
{ name: 'contract_number', description: 'The contract number.' },
22+
{ name: 'planned_date', description: 'The instalment planned date.' },
23+
{ name: 'planned_amount', description: 'The instalment planned amount, in the contract currency.' },
24+
{ name: 'actual_amount', description: 'The amount received or paid on the instalment so far; null when nothing has been, which the body shows as 0.' },
25+
],
26+
en: {
27+
label: 'Instalment overdue',
28+
subject: 'Instalment {{ seq }} overdue: {{ title }}',
29+
body: 'Instalment {{ seq }} of contract {{ contract_number }} was due on {{ planned_date }} and is not settled. Planned {{ planned_amount }}; received so far {{ actual_amount | default:0 }}.',
30+
},
31+
zhCN: {
32+
label: '分期已逾期',
33+
subject: '第 {{ seq }} 期已逾期:{{ title }}',
34+
body: '合同 {{ contract_number }} 的第 {{ seq }} 期应于 {{ planned_date }} 收付,目前尚未结清。计划金额 {{ planned_amount }},目前已收付 {{ actual_amount | default:0 }}。',
35+
},
36+
});

0 commit comments

Comments
 (0)