Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
utopia/migrations/0053_a_clash_is_keyed_by_its_facts.sql at main · deeplethe/utopia · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
deeplethe
utopia
Repository navigation
Code
Issues
55
(55)
Pull requests
18
(18)
Discussions
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
utopia
/
migrations
/
0053_a_clash_is_keyed_by_its_facts.sql
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
55 lines (49 loc) · 2.53 KB
main
Breadcrumbs
utopia
/
migrations
/
0053_a_clash_is_keyed_by_its_facts.sql
Copy path
Top
File metadata and controls
Code
Blame
55 lines (49 loc) · 2.53 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
--
互斥违规按组里的事实定键,并且只有同时成立才算(#624、#634)。
--
--
asymmetry、functional 从前以扫描时遇到的头两条做 `(left_fact, right_fact)`:同一处
--
冲突换个取数顺序就是另一个键,而 `axiom_violations` 按 `(kb_id, kind, left_fact,
--
right_fact)` 唯一——人裁过的那一行被绕开,与 #618 的环同一个病(0052)。代码那边
--
改成:一处违规是一组同时成立、彼此冲突的事实,`path` 是整组按 id 排序,left/right
--
是它的首尾。
--
--
同一刀里还有两件:检查开始看有效期(前后相接的两个值是接任),inverse_functional
--
有了自己的种类(从前与 functional 共用一个)。这里修既有的行。
ALTER
TABLE
axiom_violations
DROP
CONSTRAINT
axiom_violations_kind_check,
ADD
CONSTRAINT
axiom_violations_kind_check
CHECK
(kind
IN
(
'
self_loop
'
,
'
asymmetry
'
,
'
cycle
'
,
'
functional
'
,
'
inverse_functional
'
,
'
signature
'
,
'
derived_contradiction
'
));
--
open 的删掉:下一轮推理以新形状算回来。其中那些接任被报成的矛盾不会再回来。
DELETE
FROM
axiom_violations
WHERE
kind
IN
(
'
asymmetry
'
,
'
functional
'
)
AND
status
=
'
open
'
;
--
裁过的不能删——那是人的决定。先把记成 functional 的宾语侧违规改回它的种类:
--
两条事实宾语相同、主语不同,那是 inverse_functional 算出来的。
UPDATE
axiom_violations v
SET
kind
=
'
inverse_functional
'
FROM
facts l, facts r
WHERE
v
.
kind
=
'
functional
'
AND
l
.
id
=
v
.
left_fact
AND
r
.
id
=
v
.
right_fact
AND
l
.
object_id
=
r
.
object_id
AND
l
.
subject_id
<>
r
.
subject_id
;
--
再规范成新形状。从前记的都是一对,所以组就是这两条。
CREATE TEMP TABLE clash_canon
ON
COMMIT
DROP
AS
SELECT
id, kb_id, kind, detected_at,
LEAST(left_fact, right_fact)
AS
lo,
GREATEST(left_fact, right_fact)
AS
hi
FROM
axiom_violations
WHERE
kind
IN
(
'
asymmetry
'
,
'
functional
'
,
'
inverse_functional
'
)
AND
status
<>
'
open
'
;
--
规范完可能两行撞在一起:同一对被两种顺序各裁过一次。留最早发现的那一行。
DELETE
FROM
axiom_violations
WHERE
id
IN
(
SELECT
id
FROM
(
SELECT
id,
row_number() OVER (
PARTITION BY kb_id, kind, lo, hi
ORDER BY
detected_at, id)
AS
rn
FROM
clash_canon) t
WHERE
t
.
rn
>
1
);
UPDATE
axiom_violations v
SET
left_fact
=
c
.
lo
,
right_fact
=
c
.
hi
,
path
=
ARRAY[
c
.
lo
,
c
.
hi
]
FROM
clash_canon c
WHERE
v
.
id
=
c
.
id
;
You can’t perform that action at this time.