mainsequence 8.1.25.dev26__py3-none-any.whl → 8.1.26.dev27__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agent_scaffold/AGENTS.md +8 -9
- agent_scaffold/skills/application_surfaces/api_surfaces/SKILL.md +1 -1
- agent_scaffold/skills/maintenance/bug_auditor/SKILL.md +2 -4
- agent_scaffold/skills/maintenance/code_repository_maintenance/SKILL.md +28 -13
- agent_scaffold/skills/maintenance/metatables_transition/SKILL.md +83 -0
- agent_scaffold/skills/platform_operations/access_control_and_sharing/SKILL.md +4 -10
- agent_scaffold/skills/platform_operations/orchestration_and_releases/SKILL.md +3 -6
- agent_scaffold/skills/sdk_code_repository_execution/SKILL.md +14 -20
- mainsequence/__init__.py +11 -1
- mainsequence/_request_identity.py +44 -0
- mainsequence/bootstrap.py +39 -2
- mainsequence/cli/__init__.py +1 -1
- mainsequence/cli/api.py +85 -996
- mainsequence/cli/cli.py +422 -2072
- mainsequence/cli/config.py +651 -222
- mainsequence/cli/docker_utils.py +2 -2
- mainsequence/cli/doctor.py +58 -7
- mainsequence/cli/local_ops.py +9 -3
- mainsequence/cli/sdk_utils.py +2 -2
- mainsequence/cli/ssh_utils.py +4 -12
- mainsequence/cli/ui.py +35 -89
- mainsequence/client/__init__.py +0 -7
- mainsequence/client/base.py +1 -7
- mainsequence/client/models_foundry.py +8 -130
- mainsequence/client/models_helpers.py +20 -4
- mainsequence/client/models_user.py +38 -137
- mainsequence/client/observability.py +4 -0
- mainsequence/client/utils.py +38 -94
- mainsequence/client/value_sets.py +1 -1
- mainsequence/code_repository_context.py +119 -62
- mainsequence/code_repository_skills.py +28 -11
- mainsequence/instrumentation/__init__.py +11 -4
- mainsequence/server/__init__.py +1 -0
- mainsequence/server/caller_assertions.py +243 -0
- mainsequence/server/fastapi.py +266 -0
- mainsequence-8.1.26.dev27.dist-info/METADATA +178 -0
- mainsequence-8.1.26.dev27.dist-info/RECORD +58 -0
- mainsequence-8.1.26.dev27.dist-info/licenses/LICENSE +21 -0
- agent_scaffold/skills/data_access/exploration/SKILL.md +0 -239
- agent_scaffold/skills/data_publishing/meta_table_migrations/SKILL.md +0 -153
- agent_scaffold/skills/data_publishing/meta_tables/SKILL.md +0 -470
- agent_scaffold/skills/data_publishing/time_index_table_updates/SKILL.md +0 -551
- mainsequence/cli/migrations.py +0 -1001
- mainsequence/client/data_sources_interfaces/__init__.py +0 -25
- mainsequence/client/data_sources_interfaces/duckdb.py +0 -1461
- mainsequence/client/data_sources_interfaces/local_paths.py +0 -14
- mainsequence/client/data_sources_interfaces/sqlite.py +0 -431
- mainsequence/client/dtype_codec.py +0 -515
- mainsequence/client/metatables/__init__.py +0 -27
- mainsequence/client/metatables/core.py +0 -4881
- mainsequence/meta_tables/__init__.py +0 -133
- mainsequence/meta_tables/__main__.py +0 -0
- mainsequence/meta_tables/compiled_sql/__init__.py +0 -5
- mainsequence/meta_tables/compiled_sql/v1.py +0 -166
- mainsequence/meta_tables/future_registry.py +0 -28
- mainsequence/meta_tables/hashing.py +0 -173
- mainsequence/meta_tables/migrations/__init__.py +0 -1668
- mainsequence/meta_tables/migrations/alembic.py +0 -165
- mainsequence/meta_tables/migrations/env.py +0 -119
- mainsequence/meta_tables/migrations/provider.py +0 -25
- mainsequence/meta_tables/migrations/registry.py +0 -75
- mainsequence/meta_tables/migrations/scaffold.py +0 -221
- mainsequence/meta_tables/migrations/templates/__init__.py +0 -1
- mainsequence/meta_tables/migrations/templates/env.py.mako +0 -8
- mainsequence/meta_tables/migrations/templates/script.py.mako +0 -28
- mainsequence/meta_tables/pydantic_metadata.py +0 -99
- mainsequence/meta_tables/schema_names.py +0 -304
- mainsequence/meta_tables/sqlalchemy_contracts.py +0 -1771
- mainsequence/meta_tables/time_index_table_refs.py +0 -303
- mainsequence/meta_tables/time_index_table_updates/__init__.py +0 -27
- mainsequence/meta_tables/time_index_table_updates/configuration.py +0 -617
- mainsequence/meta_tables/time_index_table_updates/dependencies.py +0 -9
- mainsequence/meta_tables/time_index_table_updates/managers.py +0 -827
- mainsequence/meta_tables/time_index_table_updates/namespacing.py +0 -52
- mainsequence/meta_tables/time_index_table_updates/runner.py +0 -858
- mainsequence/meta_tables/time_index_table_updates/updaters.py +0 -792
- mainsequence/meta_tables/time_index_table_updates/utils.py +0 -23
- mainsequence-8.1.25.dev26.dist-info/METADATA +0 -241
- mainsequence-8.1.25.dev26.dist-info/RECORD +0 -92
- mainsequence-8.1.25.dev26.dist-info/licenses/LICENSE +0 -40
- {mainsequence-8.1.25.dev26.dist-info → mainsequence-8.1.26.dev27.dist-info}/WHEEL +0 -0
- {mainsequence-8.1.25.dev26.dist-info → mainsequence-8.1.26.dev27.dist-info}/entry_points.txt +0 -0
- {mainsequence-8.1.25.dev26.dist-info → mainsequence-8.1.26.dev27.dist-info}/top_level.txt +0 -0
agent_scaffold/AGENTS.md
CHANGED
|
@@ -64,14 +64,13 @@ never owns or updates the `ms_tau_sdk` namespace.
|
|
|
64
64
|
`.agents/skills/mainsequence/maintenance/code_repository_maintenance/SKILL.md`
|
|
65
65
|
- Blocker analysis, failure classification, and SDK/platform contract mismatches:
|
|
66
66
|
`.agents/skills/mainsequence/maintenance/bug_auditor/SKILL.md`
|
|
67
|
-
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
`.agents/skills/mainsequence/data_publishing/meta_table_migrations/SKILL.md`
|
|
67
|
+
- MetaTable modeling, queries, external registration, table updates, Alembic
|
|
68
|
+
schema changes, and data discovery: use the skills the `metatables` package
|
|
69
|
+
installs under `.agents/skills/metatables/` and its documentation.
|
|
70
|
+
- Code that still imports `mainsequence.meta_tables` or
|
|
71
|
+
`mainsequence.client.metatables`, or calls the retired `mainsequence` table
|
|
72
|
+
and migration commands:
|
|
73
|
+
`.agents/skills/mainsequence/maintenance/metatables_transition/SKILL.md`
|
|
75
74
|
- FastAPI APIs serving the Command Center frontend:
|
|
76
75
|
`.agents/skills/mainsequence/application_surfaces/api_surfaces/SKILL.md`
|
|
77
76
|
- Jobs, schedules, images, resources, releases, and Artifacts:
|
|
@@ -96,7 +95,7 @@ never owns or updates the `ms_tau_sdk` namespace.
|
|
|
96
95
|
not ask users to inject CodeRepositoryBranch or Environment identity.
|
|
97
96
|
- Use the `mainsequence` CLI as the default platform control surface. Prefer
|
|
98
97
|
`--json` when output will be parsed or used as evidence.
|
|
99
|
-
- Use the
|
|
98
|
+
- Use the owning domain package before designing against an unfamiliar domain contract.
|
|
100
99
|
- Keep reusable business logic under `src/` and keep API, job, and other
|
|
101
100
|
integration layers thin.
|
|
102
101
|
- Verify only the platform objects relevant to the requested outcome.
|
|
@@ -88,7 +88,7 @@ Record:
|
|
|
88
88
|
administrative, webhook, external integration, or backend-to-backend
|
|
89
89
|
- the exact contract ID and role for each request or response body
|
|
90
90
|
- route paths, HTTP methods, authentication expectations, and error semantics
|
|
91
|
-
- upstream
|
|
91
|
+
- upstream domain-package, service, or external data dependencies
|
|
92
92
|
- whether the API uses backend transport or a contract-defined direct
|
|
93
93
|
development transport
|
|
94
94
|
|
|
@@ -52,10 +52,8 @@ This skill audits. It does not implement by default.
|
|
|
52
52
|
platform catalog; do not assume its filesystem path
|
|
53
53
|
- bootstrap, routing, and repository structure:
|
|
54
54
|
`.agents/skills/mainsequence/sdk_code_repository_execution/SKILL.md`
|
|
55
|
-
-
|
|
56
|
-
|
|
57
|
-
- MetaTable implementation issues:
|
|
58
|
-
`.agents/skills/mainsequence/data_publishing/meta_tables/SKILL.md`
|
|
55
|
+
- MetaTable and table-update implementation issues: use the installed
|
|
56
|
+
`metatables` package skill that owns the affected contract
|
|
59
57
|
- Command Center FastAPI contract or release issues:
|
|
60
58
|
`.agents/skills/mainsequence/application_surfaces/api_surfaces/SKILL.md`
|
|
61
59
|
- jobs, images, releases, and runtime environment issues:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
2
|
+
name: mainsequence-code-repository-maintenance
|
|
3
3
|
description: Maintain an existing Main Sequence CodeRepository checkout using the SDK-version-matched CLI. Use for inspecting repository state, building or repairing .venv, refreshing local authentication, performing explicitly requested SDK, skill, or AGENTS.md updates, publishing changes with CodeRepository sync, or diagnosing a partially completed maintenance workflow.
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -22,7 +22,7 @@ Own:
|
|
|
22
22
|
Do not own:
|
|
23
23
|
|
|
24
24
|
- platform ontology or CodeRepository Blueprint design;
|
|
25
|
-
- domain implementation for
|
|
25
|
+
- domain implementation for data packages, APIs, jobs, or releases;
|
|
26
26
|
- backend repository reconciliation;
|
|
27
27
|
- MCP authorization policy, OAuth token storage, or access-token extraction;
|
|
28
28
|
- repository-owned skills outside `.agents/skills/mainsequence/`.
|
|
@@ -91,10 +91,10 @@ mainsequence code-repository build-local-venv --path . --recreate
|
|
|
91
91
|
Treat `.venv` as generated state, never as source code or durable repository
|
|
92
92
|
documentation.
|
|
93
93
|
|
|
94
|
-
## Refresh
|
|
94
|
+
## Refresh Authentication
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
existing authentication lane:
|
|
96
|
+
Authentication belongs to the machine, not to a CodeRepository. Establish the
|
|
97
|
+
CLI session through exactly one existing authentication lane:
|
|
98
98
|
|
|
99
99
|
- When `MAINSEQUENCE_AUTH_MODE=runtime_credential`, run `mainsequence login`.
|
|
100
100
|
The CLI exchanges the injected runtime credential without a browser or a
|
|
@@ -114,24 +114,39 @@ terminal. If `auth.cli_authorize` returns an error, preserve the pending local
|
|
|
114
114
|
workflow output and report that exact error rather than starting multiple
|
|
115
115
|
handoffs blindly.
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
The session is one record per backend in the operating system credential
|
|
118
|
+
store. A login made from any CodeRepository serves every other one on the
|
|
119
|
+
machine, and the SDK reads the saved session when it is imported. No
|
|
120
|
+
CodeRepository holds a copy: `.env` has the backend endpoint and no credential.
|
|
121
|
+
|
|
122
|
+
Renew the saved session and confirm that it works:
|
|
119
123
|
|
|
120
124
|
```bash
|
|
121
|
-
mainsequence
|
|
125
|
+
mainsequence refresh-token
|
|
122
126
|
```
|
|
123
127
|
|
|
128
|
+
The command takes no path, because the session does not belong to a checkout.
|
|
129
|
+
It renews the access token, saves it, and reports the session without printing
|
|
130
|
+
a token value. When the directory it runs in has a `.env` with an access token,
|
|
131
|
+
a refresh token, or a runtime credential left by an earlier version or another
|
|
132
|
+
tool, it removes those entries and reports them by name only; it changes
|
|
133
|
+
nothing else in that file.
|
|
134
|
+
|
|
124
135
|
Require one supported Main Sequence CLI login lane first. Never print,
|
|
125
136
|
inspect, summarize, copy, or return access and refresh token values. Do not
|
|
126
137
|
attempt to extract the calling MCP host's protected bearer token: the handoff
|
|
127
138
|
authorizes a new PKCE grant and the backend returns credentials directly to
|
|
128
139
|
the waiting CLI process.
|
|
129
140
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
141
|
+
Never write a token into `.env` to make a tool work. `mainsequence auth status`
|
|
142
|
+
reports whether a session exists, when it expires, and whether the process
|
|
143
|
+
takes its credentials from its environment or from the saved session; it
|
|
144
|
+
prints no token value. `mainsequence auth token` exists for local tools that
|
|
145
|
+
consume a short-lived access token programmatically. Do not run it to read a
|
|
146
|
+
token into the conversation.
|
|
147
|
+
|
|
148
|
+
The Git checkout supplies source identity; switching branches changes context
|
|
149
|
+
on the next process run without rewriting `.env`.
|
|
135
150
|
|
|
136
151
|
## Update The CodeRepository SDK
|
|
137
152
|
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mainsequence-metatables-transition
|
|
3
|
+
description: "Use when a repository still depends on the MetaTables code that used to ship inside `mainsequence`: imports from `mainsequence.meta_tables` or `mainsequence.client.metatables`, table classes imported from `mainsequence.client`, or the retired `mainsequence meta-table`, `time-index-table`, `code-repository time-index-table-updates`, and `migrations` commands. Covers only the one-time move to the `mainsequence-metatable` package; all MetaTables usage after the move belongs to the skills that package installs."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Move a repository to the `metatables` package
|
|
7
|
+
|
|
8
|
+
MetaTables no longer ships inside `mainsequence`. This skill moves one
|
|
9
|
+
repository's code and dependencies to the package that now owns it, and stops
|
|
10
|
+
there. It does not move tables or catalog records. For table modeling, queries,
|
|
11
|
+
DataSources, updaters, and Alembic migrations, use the skills installed in
|
|
12
|
+
step 2.
|
|
13
|
+
|
|
14
|
+
## 1. Find what the repository uses
|
|
15
|
+
|
|
16
|
+
Search code, scripts, workflow files, and `pyproject.toml` for:
|
|
17
|
+
|
|
18
|
+
- `mainsequence.meta_tables` and `mainsequence.client.metatables`
|
|
19
|
+
- `MetaTable`, `TimeIndexMetaTable`, `TimeIndexTableUpdate`, or `DataSource`
|
|
20
|
+
imported from `mainsequence.client`
|
|
21
|
+
- `mainsequence meta-table`, `mainsequence time-index-table`,
|
|
22
|
+
`mainsequence code-repository time-index-table-updates`, and
|
|
23
|
+
`mainsequence migrations`
|
|
24
|
+
- the `mainsequence[local-data]` extra
|
|
25
|
+
|
|
26
|
+
Report what you found before editing. If nothing matches, there is nothing to
|
|
27
|
+
move.
|
|
28
|
+
|
|
29
|
+
## 2. Install the package and its skills
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
uv add mainsequence-metatable
|
|
33
|
+
uv run python -m metatables.sdk_compat
|
|
34
|
+
uv run metatables copy-metatables-skills --path .
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The distribution is `mainsequence-metatable`; the import and the command are
|
|
38
|
+
`metatables`. Do not install the PyPI project named `metatables`: it is
|
|
39
|
+
unrelated. The compatibility check must pass before you continue. If it fails,
|
|
40
|
+
the installed `mainsequence` is not compatible; upgrading it is an update the
|
|
41
|
+
user has to request.
|
|
42
|
+
|
|
43
|
+
The last command copies the package's skills into `.agents/skills/metatables/`.
|
|
44
|
+
|
|
45
|
+
`mainsequence-metatable` brings back `alembic`, `sqlalchemy`, `pandas`,
|
|
46
|
+
`numpy`, `psycopg2-binary`, and `tqdm`, which the SDK no longer installs. The
|
|
47
|
+
`local-data` extra is gone: remove it, and declare `duckdb` and `pyarrow`
|
|
48
|
+
directly if the repository imports them.
|
|
49
|
+
|
|
50
|
+
## 3. Rewrite imports
|
|
51
|
+
|
|
52
|
+
| Old | New |
|
|
53
|
+
| --- | --- |
|
|
54
|
+
| `mainsequence.meta_tables` | `metatables` |
|
|
55
|
+
| `mainsequence.meta_tables.<module>` | `metatables.<module>` |
|
|
56
|
+
| `mainsequence.meta_tables.time_index_table_updates.<module>` | `metatables.updaters.<module>` |
|
|
57
|
+
| `mainsequence.client.metatables`, `mainsequence.client.metatables.core` | `metatables.models` |
|
|
58
|
+
| table classes from `mainsequence.client` | `metatables` |
|
|
59
|
+
|
|
60
|
+
Change module paths only. In an existing Alembic provider, update the provider
|
|
61
|
+
module and `env.py` the same way, and leave applied revision files untouched.
|
|
62
|
+
If a name is missing from `metatables`, report it instead of guessing a
|
|
63
|
+
substitute.
|
|
64
|
+
|
|
65
|
+
`CodeRepositoryBranch.get_time_index_table_updates()` and DataSource resolution
|
|
66
|
+
through `CodeRepositoryContext` have no SDK replacement. The `metatables` skills
|
|
67
|
+
cover what to use instead.
|
|
68
|
+
|
|
69
|
+
## 4. Replace commands
|
|
70
|
+
|
|
71
|
+
The four command groups keep their names: `mainsequence <group> ...` becomes
|
|
72
|
+
`metatables <group> ...`. Confirm each one with `metatables <group> --help`. If
|
|
73
|
+
a subcommand is missing or refuses to run, stop and report it. Do not pin an
|
|
74
|
+
older `mainsequence`, connect to the database directly, or register tables by
|
|
75
|
+
hand to get around it.
|
|
76
|
+
|
|
77
|
+
## 5. Check the result
|
|
78
|
+
|
|
79
|
+
- The search from step 1 returns nothing.
|
|
80
|
+
- The changed modules import and the repository's tests pass.
|
|
81
|
+
- `.agents/skills/metatables/` exists.
|
|
82
|
+
|
|
83
|
+
Then hand over to those skills.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: mainsequence-access-control-and-sharing
|
|
3
|
-
description: Use this skill when the task is about RBAC, resource sharing, or access verification in a Main Sequence CodeRepository. This skill owns organization and team access concepts, view and edit semantics, choosing the correct shareable resource boundary, and access checks across CodeRepositories,
|
|
3
|
+
description: Use this skill when the task is about RBAC, resource sharing, or access verification in a Main Sequence CodeRepository. This skill owns organization and team access concepts, view and edit semantics, choosing the correct shareable resource boundary, and access checks across CodeRepositories, constants, secrets, buckets, artifacts, and releases. It does not own job scheduling, domain-package data behavior, or API route design.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Main Sequence Access Control And Sharing
|
|
@@ -26,13 +26,11 @@ This skill is for:
|
|
|
26
26
|
- decide whether a user needs `view` or `edit`
|
|
27
27
|
- identify the correct shareable object boundary:
|
|
28
28
|
- `CodeRepository`
|
|
29
|
-
- `TimeIndexMetaTable`
|
|
30
29
|
- `Constant`
|
|
31
30
|
- `Secret`
|
|
32
31
|
- `Bucket`
|
|
33
32
|
- `Artifact`
|
|
34
33
|
- `ResourceRelease`
|
|
35
|
-
- explain that sharing an updater's published output means sharing its `TimeIndexMetaTable`
|
|
36
34
|
- choose whether configuration belongs in a `Constant` or a `Secret`
|
|
37
35
|
- review CLI sharing flows for existing resources
|
|
38
36
|
- verify access assumptions before claiming a workflow is shareable
|
|
@@ -42,8 +40,7 @@ This skill is for:
|
|
|
42
40
|
This skill must not claim ownership of:
|
|
43
41
|
|
|
44
42
|
- job scheduling or image pinning
|
|
45
|
-
-
|
|
46
|
-
- MetaTable schema design
|
|
43
|
+
- domain-package data production and schema design
|
|
47
44
|
- FastAPI route design
|
|
48
45
|
- application UI design or implementation
|
|
49
46
|
|
|
@@ -51,10 +48,8 @@ This skill must not claim ownership of:
|
|
|
51
48
|
|
|
52
49
|
- jobs, schedules, images, code repository resources, releases, and Artifacts as operational workflows:
|
|
53
50
|
`.agents/skills/mainsequence/platform_operations/orchestration_and_releases/SKILL.md`
|
|
54
|
-
-
|
|
55
|
-
|
|
56
|
-
- MetaTables:
|
|
57
|
-
`.agents/skills/mainsequence/data_publishing/meta_tables/SKILL.md`
|
|
51
|
+
- MetaTables and table updates: use the installed `metatables` package skills
|
|
52
|
+
and documentation
|
|
58
53
|
- Command Center-serving FastAPI providers:
|
|
59
54
|
`.agents/skills/mainsequence/application_surfaces/api_surfaces/SKILL.md`
|
|
60
55
|
This skill only reasons about access to deployed resources such as `ResourceRelease`.
|
|
@@ -108,7 +103,6 @@ Do not speak loosely about sharing "the code" when the operational boundary is a
|
|
|
108
103
|
|
|
109
104
|
Examples:
|
|
110
105
|
|
|
111
|
-
- sharing an updater's published output usually means sharing the `TimeIndexMetaTable`
|
|
112
106
|
- sharing a deployed experience usually means sharing the `ResourceRelease`
|
|
113
107
|
- sharing runtime configuration means sharing the `Constant` or `Secret`
|
|
114
108
|
|
|
@@ -32,18 +32,15 @@ This skill is for:
|
|
|
32
32
|
|
|
33
33
|
This skill must not claim ownership of:
|
|
34
34
|
|
|
35
|
-
-
|
|
36
|
-
- MetaTable schema and row semantics
|
|
35
|
+
- domain-package data production and schema semantics
|
|
37
36
|
- Command Center FastAPI wire contracts
|
|
38
37
|
- RBAC or sharing policy
|
|
39
38
|
- application UI implementation details
|
|
40
39
|
|
|
41
40
|
## Route Adjacent Work
|
|
42
41
|
|
|
43
|
-
-
|
|
44
|
-
|
|
45
|
-
- MetaTables:
|
|
46
|
-
`.agents/skills/mainsequence/data_publishing/meta_tables/SKILL.md`
|
|
42
|
+
- MetaTables, table updates, and table schemas: use the installed `metatables`
|
|
43
|
+
package skills and documentation
|
|
47
44
|
- Command Center FastAPI provider implementation and contract validation:
|
|
48
45
|
`.agents/skills/mainsequence/application_surfaces/api_surfaces/SKILL.md`
|
|
49
46
|
- RBAC and sharing:
|
|
@@ -30,14 +30,12 @@ This skill is for:
|
|
|
30
30
|
- enforce standard Main Sequence repository structure expectations
|
|
31
31
|
- separate verified facts from assumptions
|
|
32
32
|
- surface documentation mismatches to the user
|
|
33
|
-
- enforce the namespace-first safety rule for new or modified TimeIndexTableUpdaters
|
|
34
33
|
|
|
35
34
|
## This Skill Must Not Claim
|
|
36
35
|
|
|
37
36
|
This skill must not claim ownership of:
|
|
38
37
|
|
|
39
|
-
-
|
|
40
|
-
- MetaTable design
|
|
38
|
+
- domain-package data modeling and execution
|
|
41
39
|
- Command Center-serving FastAPI contract and release design
|
|
42
40
|
- jobs, schedules, images, resources, or releases
|
|
43
41
|
- RBAC or sharing semantics
|
|
@@ -49,12 +47,8 @@ Do not let this skill become a domain manual.
|
|
|
49
47
|
|
|
50
48
|
## Route Adjacent Work
|
|
51
49
|
|
|
52
|
-
-
|
|
53
|
-
|
|
54
|
-
- MetaTables:
|
|
55
|
-
`.agents/skills/mainsequence/data_publishing/meta_tables/SKILL.md`
|
|
56
|
-
- platform data discovery before implementation:
|
|
57
|
-
`.agents/skills/mainsequence/data_access/exploration/SKILL.md`
|
|
50
|
+
- MetaTables, table updates, and domain data discovery: use the installed
|
|
51
|
+
`metatables` package skills and documentation
|
|
58
52
|
- FastAPI APIs serving the Command Center frontend:
|
|
59
53
|
`.agents/skills/mainsequence/application_surfaces/api_surfaces/SKILL.md`
|
|
60
54
|
- CodeRepository audits, blocker analysis, and upstream SDK assessment:
|
|
@@ -122,11 +116,9 @@ Keep the platform boundaries explicit:
|
|
|
122
116
|
For ordinary local implementation, work naturally in the current Git branch.
|
|
123
117
|
Do not make CodeRepositoryBranch selection a separate user workflow.
|
|
124
118
|
An unregistered local branch remains valid for ordinary local development, but
|
|
125
|
-
it has no CodeRepositoryBranch
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
pods, or other branch-owned platform APIs. Never fall back to another branch or
|
|
129
|
-
to an aggregate-level default DataSource.
|
|
119
|
+
it has no CodeRepositoryBranch or Environment. Only branch-owned operations
|
|
120
|
+
fail. Register the branch before using Jobs, images, releases, resources, pods,
|
|
121
|
+
or other branch-owned platform APIs. Never fall back to another branch.
|
|
130
122
|
|
|
131
123
|
## Required Decisions
|
|
132
124
|
|
|
@@ -190,14 +182,20 @@ Do not start domain work with a vague target.
|
|
|
190
182
|
|
|
191
183
|
### 4. Verify code repository context before making platform claims
|
|
192
184
|
|
|
193
|
-
Use the CLI to confirm the active CodeRepository and
|
|
185
|
+
Use the CLI to confirm the active CodeRepository and the saved session before live checks when needed.
|
|
194
186
|
|
|
195
187
|
When the result will be consumed programmatically or used as machine-readable evidence, prefer the CLI `--json` flag.
|
|
196
188
|
|
|
197
189
|
Typical bootstrap checks:
|
|
198
190
|
|
|
199
191
|
- `mainsequence code-repository current --debug`
|
|
200
|
-
- `mainsequence
|
|
192
|
+
- `mainsequence auth status --check`
|
|
193
|
+
- `mainsequence refresh-token`
|
|
194
|
+
|
|
195
|
+
The session lives in the operating system credential store, not in `.env`, and
|
|
196
|
+
belongs to the machine, not to a checkout. `auth status` reports it without
|
|
197
|
+
printing a token value. `refresh-token` renews it; run in a checkout, it also
|
|
198
|
+
removes credential entries an earlier version left in `.env`.
|
|
201
199
|
|
|
202
200
|
Do not proceed with a live branch-owned check unless `code-repository current` reports
|
|
203
201
|
the current Git branch and a resolved CodeRepositoryBranch UID.
|
|
@@ -208,10 +206,6 @@ Once the task boundary is clear, move into the correct specialized skill.
|
|
|
208
206
|
|
|
209
207
|
Do not teach domain semantics here.
|
|
210
208
|
|
|
211
|
-
### 6. Use namespaces first for new or modified TimeIndexTableUpdaters
|
|
212
|
-
|
|
213
|
-
Before first-running or validating a new or changed TimeIndexTableUpdater, use an explicit namespace before any non-namespaced run.
|
|
214
|
-
|
|
215
209
|
## Review Rules
|
|
216
210
|
|
|
217
211
|
When reviewing bootstrap behavior, look for:
|
mainsequence/__init__.py
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
# ruff: noqa: E402
|
|
1
2
|
from .bootstrap import prime_runtime_env
|
|
2
3
|
|
|
4
|
+
# Restore CLI credentials before any client module freezes its endpoint/provider.
|
|
3
5
|
prime_runtime_env()
|
|
4
6
|
|
|
5
|
-
from .logconf import
|
|
7
|
+
from .logconf import (
|
|
8
|
+
logger as logger,
|
|
9
|
+
)
|
|
10
|
+
from .logconf import (
|
|
11
|
+
refresh_application_logger_bindings as refresh_application_logger_bindings,
|
|
12
|
+
)
|
|
13
|
+
from .logconf import (
|
|
14
|
+
set_local_run_app as set_local_run_app,
|
|
15
|
+
)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""Private lifecycle shared by the request integration and the public user getter."""
|
|
2
|
+
|
|
3
|
+
from contextlib import contextmanager
|
|
4
|
+
from contextvars import ContextVar
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class RequestIdentityError(RuntimeError):
|
|
10
|
+
"""No authenticated caller is bound to the current request."""
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass
|
|
14
|
+
class _RequestScope:
|
|
15
|
+
user: Any = None
|
|
16
|
+
active: bool = True
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
_current_scope: ContextVar[_RequestScope | None] = ContextVar(
|
|
20
|
+
"mainsequence_request_identity", default=None
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@contextmanager
|
|
25
|
+
def _request_scope():
|
|
26
|
+
scope = _RequestScope()
|
|
27
|
+
token = _current_scope.set(scope)
|
|
28
|
+
try:
|
|
29
|
+
yield scope
|
|
30
|
+
finally:
|
|
31
|
+
# Copied child-task contexts hold this same frame and must also expire.
|
|
32
|
+
scope.active = False
|
|
33
|
+
scope.user = None
|
|
34
|
+
_current_scope.reset(token)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _get_request_identity():
|
|
38
|
+
scope = _current_scope.get()
|
|
39
|
+
if scope is None or not scope.active or scope.user is None:
|
|
40
|
+
raise RequestIdentityError(
|
|
41
|
+
"No authenticated request user is available. Install request identity "
|
|
42
|
+
"once in the application and call User.get_logged_user() inside a request."
|
|
43
|
+
)
|
|
44
|
+
return scope.user
|
mainsequence/bootstrap.py
CHANGED
|
@@ -4,6 +4,26 @@ import os
|
|
|
4
4
|
import pathlib
|
|
5
5
|
import re
|
|
6
6
|
|
|
7
|
+
CREDENTIALS_FROM_ENVIRONMENT = "environment"
|
|
8
|
+
CREDENTIALS_FROM_STORE = "store"
|
|
9
|
+
_TOKEN_ENVIRONMENT_NAMES = (
|
|
10
|
+
"MAINSEQUENCE_ACCESS_TOKEN",
|
|
11
|
+
"MAINSEQUENCE_REFRESH_TOKEN",
|
|
12
|
+
"MAIN_SEQUENCE_USER_TOKEN",
|
|
13
|
+
"MAIN_SEQUENCE_REFRESH_TOKEN",
|
|
14
|
+
)
|
|
15
|
+
_credential_source: str | None = None
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def credential_source() -> str | None:
|
|
19
|
+
"""
|
|
20
|
+
Say where this process's JWT credentials came from.
|
|
21
|
+
|
|
22
|
+
`environment` when a token was already set before the SDK started, `store`
|
|
23
|
+
when the SDK filled it from the saved CLI session, None when it found neither.
|
|
24
|
+
"""
|
|
25
|
+
return _credential_source
|
|
26
|
+
|
|
7
27
|
|
|
8
28
|
def _set_if_missing(key: str, value: str | None) -> None:
|
|
9
29
|
if value and not os.environ.get(key):
|
|
@@ -31,7 +51,16 @@ def prime_runtime_env() -> None:
|
|
|
31
51
|
"""
|
|
32
52
|
Best-effort bootstrap so CLI/SDK imports can discover runtime config without
|
|
33
53
|
requiring the user to source the checkout `.env` manually.
|
|
54
|
+
|
|
55
|
+
Only the endpoint is read from the checkout `.env`. Credentials come from the
|
|
56
|
+
process environment when it already has them, and otherwise from the saved
|
|
57
|
+
CLI session.
|
|
34
58
|
"""
|
|
59
|
+
global _credential_source
|
|
60
|
+
|
|
61
|
+
had_tokens = any((os.environ.get(name) or "").strip() for name in _TOKEN_ENVIRONMENT_NAMES)
|
|
62
|
+
_credential_source = CREDENTIALS_FROM_ENVIRONMENT if had_tokens else None
|
|
63
|
+
|
|
35
64
|
local_values = _read_local_env_values(pathlib.Path.cwd() / ".env")
|
|
36
65
|
|
|
37
66
|
_set_if_missing("MAINSEQUENCE_ENDPOINT", local_values.get("MAINSEQUENCE_ENDPOINT"))
|
|
@@ -53,5 +82,13 @@ def prime_runtime_env() -> None:
|
|
|
53
82
|
except Exception:
|
|
54
83
|
tokens = {}
|
|
55
84
|
|
|
56
|
-
|
|
57
|
-
|
|
85
|
+
access = (tokens.get("access") or "").strip()
|
|
86
|
+
refresh = (tokens.get("refresh") or "").strip()
|
|
87
|
+
if not had_tokens and (access or refresh):
|
|
88
|
+
_credential_source = CREDENTIALS_FROM_STORE
|
|
89
|
+
# The saved session's user name goes with its tokens. A renewal saves the
|
|
90
|
+
# session again, and without the name it would save it nameless.
|
|
91
|
+
_set_if_missing("MAINSEQUENCE_USERNAME", (tokens.get("username") or "").strip())
|
|
92
|
+
|
|
93
|
+
_set_if_missing("MAINSEQUENCE_ACCESS_TOKEN", access)
|
|
94
|
+
_set_if_missing("MAINSEQUENCE_REFRESH_TOKEN", refresh)
|
mainsequence/cli/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
from .cli import app
|
|
1
|
+
from .cli import app as app
|