Repository navigation
fix(ontogeny): harden runtime consistency and lifecycle contracts - #391
Conversation
bitflicker64
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: The automatic outbox loop scans all delivered history on every tick, one failing derivation row stalls derived values for its whole object type, and the bootstrap admin password drops to six digits while the password floor for every account drops to 6.
bitflicker64
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: Document extraction drops non-snake_case properties, rewrites numeric-looking strings, breaks a store when a removed file returns, re-raises rejected candidates and mixes attempt ids with run ids; the three earlier comments still apply at this head.
The earlier review comments below still apply at 0e0b6ab; this head does not fix them.
- Important: this anti-join starts at the first outbox row and nothing prunes
ontogeny_outboxorontogeny_outbox_receipt, so each 1-second tick runs four scans whose cost grows with all delivered history (every sync adds one row per source row). A local SQLite run with 1M delivered events spends about 1 s per idle tick. Keep a per-consumer floor below which every ID is acknowledged and addOutboxRow.id > floorto the query. (#391 (comment)) - Important: a row whose function raises fails the whole
map_rowsbatch, and its pending entry now persists, so every later drain includes it and no row of that type gets new derived values while it stays pending. Retry a failed batch row by row and leave only the rows that still fail pending. (#391 (comment)) - Important: the generated admin password has 10^6 values, the username defaults to
admin, and/auth/loginhas no attempt limit, whileMIN_PASSWORD = 6lowers the floor for every account. Generate a high-entropy bootstrap secret such assecrets.token_urlsafe(24)and keepMIN_PASSWORD = 8. (#391 (comment))
|
Follow-up at head Remaining confirmed boundaries:
Validation: 156 targeted backend tests passed and 4 PostgreSQL-dependent tests were skipped in that run; a separate run against a real PostgreSQL 16 instance passed 12 outbox/lifespan tests, and the frontend access tests passed (19 tests). The combined backend run emitted three aiosqlite event-loop-closed warnings. No production deployment or old-data migration was validated. |
|
Independent follow-up score: 9.2/10 for the reviewed fixes in The document ID collision, historical data and deployment boundaries remain. The exact-head CI is still running, and #380 remains open. |
|
Follow-up: the cross-store document ID collision noted above is fixed in Rollback is not seamless: back up the database and corpus together before upgrading, and restore the matching backup if downgrading; that loses changes since the backup. If both legacy and scoped records already exist for the same document, scanning stops before altering references and requires deliberate reconciliation. This change does not guess or rewrite historical attempt/run associations. CI for this exact head is pending. |
|
Follow-up at This does not reconstruct or migrate the ambiguous historical attempt/run associations described above: the original rows do not contain enough information to identify their provenance reliably. Existing limitations on rollback, single-process dispatch, and the open #380 dependency still apply. The 77 evolve and query-service tests passed after integrating the concurrent branch changes; CI for this new head is pending. |
Independent review follow-upReviewed head
No further actionable findings were identified in those scopes. These scores are not a review of all files in the PR. The reviewers performed static inspection and did not independently run tests. The implementation team reports 77 related evolve/query tests passing, plus targeted PostgreSQL, SQLite and document-ingestion tests. Limits: stop the old worker before upgrading and run only one service process per database. Historical delivery gaps require audit and scoped replay, which can duplicate delivery; old audit records lack schema versions and cannot safely be backfilled automatically. Current-head CI is still running, and #380 remains an upstream dependency. |
|
Independent verification at Reproduction (Linux)Environment: Ubuntu 22.04 x86_64, Python 3.12.13 (uv-managed), SQLite/aiosqlite, single process. Ran the regression suites for the eight reviewed fixes plus the historical-replay fix:
Result: 104 passed, 2 skipped (the two Not covered here: the The same nine files were also run on Windows 10 (zh-CN, Python 3.12) to check platform assumptions. That surfaced the findings below. One further Windows failure, Finding 1 —
|
bitflicker64
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: The earlier outbox, derivation, bootstrap-password and ingestion fixes hold at this head, but the demo still accepts the X-Ontogeny-Principal admin header the docs now call disabled, a superseded document task can be re-confirmed over newer data, reviewer overrides bypass type checks, agent-path rule and policy refusals no longer reach the revision audit, and --reseed leaves a credential file that stops the next start. The Minor items are smaller lifecycle, message and docs issues.
|
|
||
| > [!NOTE] | ||
| > The API is session/bearer authenticated. The `X-Ontogeny-Principal` dev header is **enabled by default** for evaluation (`ONTOGENY_DEV_AUTH=0` disables it) — turn it off in production, where the agent surfaces (REST + `/mcp`) then require a signed-in driver and every session records WHO drove it. | ||
| > The API is session/bearer authenticated. The `X-Ontogeny-Principal` dev header is disabled by default; set `ONTOGENY_DEV_AUTH=1` only for development or evaluation. With it disabled, the agent surfaces (REST + `/mcp`) require a signed-in driver and every session records WHO drove it. |
There was a problem hiding this comment.
Important: ontogeny serve --demo, which the Docker CMD and the quickstart both run, still sets ONTOGENY_DEV_AUTH=1 through DemoPaths.as_env, so any client that sends X-Ontogeny-Principal: {"id":"x","is_admin":true} passes require_admin while this note says the header is disabled by default. Stop --demo from enabling dev auth unless the operator sets ONTOGENY_DEV_AUTH=1.
| task = await session.get(DocumentTaskRow, task_id) | ||
| if task is None: | ||
| raise NotFoundError(f"no task {task_id}") | ||
| if task.status == "confirmed": |
There was a problem hiding this comment.
Important: confirm refuses only confirmed tasks, so a superseded revision can be confirmed again and rewrites its older graph over the newer confirmed one, leaving both tasks confirmed; TasksTab.tsx shows the Confirm button for it. Refuse confirm, save_graph and run unless the task is still open for review.
| try: | ||
| props[prop] = coerce_value(ptype.ptype(), value, prop=prop) | ||
| except Exception: | ||
| props[prop] = value |
There was a problem hiding this comment.
Important: when coerce_value rejects a reviewer override, this fallback writes the raw value, so {"risk_level": "CATASTROPHIC"} is stored on an enum[LOW, MEDIUM, HIGH] property and effective_date: "not a date" fails later as a 500. Raise a DocumentError on a coercion failure instead of storing the raw value.
| params, | ||
| target_id, | ||
| expected_revision=args.get("expected_revision"), | ||
| commit_rejections=False, |
There was a problem hiding this comment.
Important: with commit_rejections=False inside begin_nested(), a rule-rejected or policy-denied agent write rolls back its rejected_rule/denied_policy revision with the savepoint, here and in the approval path of decide, so agent refusals no longer reach the audit stream that REST refusals still write. Record the refusal revision after the savepoint rollback.
| try: | ||
| fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600) | ||
| except FileExistsError as exc: | ||
| raise StoreError( |
There was a problem hiding this comment.
Important: ontogeny serve --demo --copy-package --reseed deletes ontogeny.db but keeps admin-bootstrap-password, so the next start finds no admin, raises here and exits with Application startup failed. Remove the stale credential file in prepare_demo when --reseed deletes the database.
| wanted_ids = set(doc_ids or []) | ||
| async with self.sc.sessionmaker() as session: | ||
| docs = (await session.execute(select(DocumentRow).where(DocumentRow.store == store_name))).scalars().all() | ||
| selected = [d for d in docs if d.id in wanted_ids or Path(d.path).resolve() in paths] |
There was a problem hiding this comment.
Minor: this selects removed rows whose path matches, so uploading a revised file under the same name returns a second task bound to the removed document id that reads the new bytes. Select only active documents.
| issues = [{"message": "issues must be an array"}] if issues is not None else [] | ||
| status = chunk.get("status", "final") | ||
| if status not in _VALID_STATUS: | ||
| status = "failed" |
There was a problem hiding this comment.
Minor: status is reassigned before the issue is built, so the message always reads invalid status 'failed' and drops the value the agent sent. Build the message from the original value first.
| raise SkillError(f"skill examples must be a list of at most {MAX_EXAMPLES} items") | ||
| if len(json.dumps(examples, ensure_ascii=False, default=str)) > MAX_EXAMPLE_CHARS: | ||
| raise SkillError("skill examples are too large") | ||
| language = str(skill.get("language") or "en") |
There was a problem hiding this comment.
Minor: the snapshot always stores language, defaulting to en, so skill.get("language") or cfg.language in tasks.py never falls back to the store's documents.language (default zh). Leave language unset when the caller gives none.
| disabled={createDefault.isPending} | ||
| data-testid="documents-create-default" | ||
| > | ||
| {createDefault.isPending ? t('documents.default.creating') : t('documents.default.action')} |
There was a problem hiding this comment.
Minor: documents.default.action and documents.default.creating exist in neither en.ts nor zh.ts, so the create-default button shows the raw key. Add both keys to the two dictionaries.
| ``` | ||
|
|
||
| `tools/doc_agent_reference.py` is a deterministic reference agent that makes the | ||
| Product Manufacturing demo runnable without an LLM; `tools/doc_agent_openai.py` shows the |
There was a problem hiding this comment.
Minor: this names the Product Manufacturing demo, which this PR deletes in favour of chip-lifecycle, and line 23 reads Baselineal guardrails. Name the chip-lifecycle demo and fix the heading.
- Protect bootstrap credentials, agent sessions, and guarded reads. - Apply approvals, field markings, and builder validation before writes. - Persist generated IDs and guard live writes during evaluation.
- Preserve typed snapshots, watermarks, and ordered action effects. - Manage independent outbox acknowledgements and delivery lifecycle. - Strengthen deployment defaults, projection behavior, and PostgreSQL coverage.
- Commit schemas before publishing runtime snapshots. - Enforce typed keys, scoped idempotency, and administrator invariants. - Preserve sandbox frames, derived values, and query result ordering.
- Add the extraction, review, provenance, and task runtime. - Expose document workflow and ontology taxonomy APIs. - Introduce the chip-lifecycle demo, fixtures, and module guides.
- Expose document tasks and extraction review in the web console. - Display ontology resource kinds and document provenance. - Cover the workflows with console and integration tests.
- Link Ontogeny guides from the repository documentation. - Wire Ontogeny into selective CI and validate Python version floors. - Record the registry ownership rules for DSL kinds.
- Address runtime and document ingestion review findings. - Index pending outbox deliveries for efficient retry. - Scope newly discovered document identities by store.
- Scope evidence to matching extraction targets and mappings. - Apply deny decisions while retaining document provenance. - Retract withdrawn relationships and preserve those outside the extraction scope.
- Handle incomplete historical results and validate runtime targets. - Make evaluation replay and teardown handle partial state. - Add regression coverage for the reviewed failure paths.
- Require evaluation evidence before accepting evolution candidates. - Distinguish empty and coverage-only results from valid evaluations. - Cover acceptance, scope, and evaluation edge cases. Co-authored-by: imbajin <jin@apache.org>
- Batch table updates, document assertion writes, and related object lookups. - Limit relationship reads to the current page and traversal anchors. - Resolve typed relationship aliases while preserving declared string keys. Co-authored-by: imbajin <jin@apache.org>
- Apply document selectors and cache reads within the selected corpus. - Retire verified deletions while preserving stable document identities. - Signal subscription overflow so clients can resume from a fresh snapshot. - Document the affected scan and stream behavior. Co-authored-by: z <3042372703@qq.com> Co-authored-by: imbajin <jin@apache.org>
- Validate keyed replays against the current action schema and policy. - Recover the persisted replay winner after a contended SQLite write. - Recognize legacy logical selector names and prune unselected paths. - Preserve evidence when filesystem access prevents verification. - Report incomplete scans to listing, task, and ingest callers. Co-authored-by: z <3042372703@qq.com>
Before → After
Before: The pending Ontogeny proposal needs further review fixes for runtime consistency, lifecycle handling and compatibility.
After: Apply the follow-up fixes and regression coverage from the existing fork branch: object/version and idempotency consistency, transaction/outbox lifecycle, policy and identity handling, typed synchronization, and console/deployment behavior.
Dependency and scope
Depends on 🔗 AI #380. This stacked PR targets
apache:ontogeny, notmain, and contains 55 commits beyond that proposal's current head (155 changed files). It preserves the existinghugegraph:ontogenysource branch and avoids duplicating the original platform introduction as a second PR intomain. Recheck the base and remaining diff after #380 merges; do not assume squash or branch deletion preserves this comparison.Validation and upgrade boundaries
The author reports backend/frontend CI, PostgreSQL concurrency checks and isolated HugeGraph projection smoke tests. These results have not been independently reproduced by this submission check. Existing databases may require explicit migrations/backfills, and automatic outbox processing can deliver queued external events. See the source PR's detailed compatibility and deployment notes before adoption. This submission is not release, live-cluster or UI acceptance.
Source and detailed evidence: 🔗 hugegraph/hugegraph-ai #90
Visual overview
The diagram illustrates the shared architecture and the proposed stacked relationship between #391 and #380; it does not indicate that either PR has merged or that release acceptance has passed.